Skip to content

Commit 0ba9ff8

Browse files
Jiri Slabygregkh
authored andcommitted
TTY: ircomm, define carrier routines
These will be used by the tty_port wait_til_ready later. (Now they are used by our code.) Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Samuel Ortiz <samuel@sortiz.org> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 38c5803 commit 0ba9ff8

1 file changed

Lines changed: 33 additions & 10 deletions

File tree

‎net/irda/ircomm/ircomm_tty.c‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,35 @@ static const struct tty_operations ops = {
104104
#endif /* CONFIG_PROC_FS */
105105
};
106106

107+
static void ircomm_port_raise_dtr_rts(struct tty_port *port, int raise)
108+
{
109+
struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
110+
port);
111+
/*
112+
* Here, we use to lock those two guys, but as ircomm_param_request()
113+
* does it itself, I don't see the point (and I see the deadlock).
114+
* Jean II
115+
*/
116+
if (raise)
117+
self->settings.dte |= IRCOMM_RTS | IRCOMM_DTR;
118+
else
119+
self->settings.dte &= ~(IRCOMM_RTS | IRCOMM_DTR);
120+
121+
ircomm_param_request(self, IRCOMM_DTE, TRUE);
122+
}
123+
124+
static int ircomm_port_carrier_raised(struct tty_port *port)
125+
{
126+
struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
127+
port);
128+
return self->settings.dce & IRCOMM_CD;
129+
}
130+
131+
static const struct tty_port_operations ircomm_port_ops = {
132+
.dtr_rts = ircomm_port_raise_dtr_rts,
133+
.carrier_raised = ircomm_port_carrier_raised,
134+
};
135+
107136
/*
108137
* Function ircomm_tty_init()
109138
*
@@ -290,15 +319,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
290319
port->blocked_open++;
291320

292321
while (1) {
293-
if (tty->termios->c_cflag & CBAUD) {
294-
/* Here, we use to lock those two guys, but
295-
* as ircomm_param_request() does it itself,
296-
* I don't see the point (and I see the deadlock).
297-
* Jean II */
298-
self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR;
299-
300-
ircomm_param_request(self, IRCOMM_DTE, TRUE);
301-
}
322+
if (tty->termios->c_cflag & CBAUD)
323+
tty_port_raise_dtr_rts(port);
302324

303325
current->state = TASK_INTERRUPTIBLE;
304326

@@ -315,7 +337,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
315337
* ready
316338
*/
317339
if (!test_bit(ASYNCB_CLOSING, &port->flags) &&
318-
(do_clocal || (self->settings.dce & IRCOMM_CD)) &&
340+
(do_clocal || tty_port_carrier_raised(port)) &&
319341
self->state == IRCOMM_TTY_READY)
320342
{
321343
break;
@@ -379,6 +401,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
379401
}
380402

381403
tty_port_init(&self->port);
404+
self->port.ops = &ircomm_port_ops;
382405
self->magic = IRCOMM_TTY_MAGIC;
383406
self->flow = FLOW_STOP;
384407

0 commit comments

Comments
 (0)