diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-06-04 07:35:23 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-12 18:50:24 -0400 |
commit | 0ba9ff846b2f4720e30ace37b028ef14fb97fb74 (patch) | |
tree | 092a1a60bb3342aa5b39379ca094543cddd25b6d /net/irda | |
parent | 38c58032f07be4dee764baa573b233e9a828c119 (diff) |
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>
Diffstat (limited to 'net/irda')
-rw-r--r-- | net/irda/ircomm/ircomm_tty.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 199d9cbf9948..3fdce18c6931 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -104,6 +104,35 @@ static const struct tty_operations ops = { | |||
104 | #endif /* CONFIG_PROC_FS */ | 104 | #endif /* CONFIG_PROC_FS */ |
105 | }; | 105 | }; |
106 | 106 | ||
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 | |||
107 | /* | 136 | /* |
108 | * Function ircomm_tty_init() | 137 | * Function ircomm_tty_init() |
109 | * | 138 | * |
@@ -290,15 +319,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
290 | port->blocked_open++; | 319 | port->blocked_open++; |
291 | 320 | ||
292 | while (1) { | 321 | while (1) { |
293 | if (tty->termios->c_cflag & CBAUD) { | 322 | if (tty->termios->c_cflag & CBAUD) |
294 | /* Here, we use to lock those two guys, but | 323 | tty_port_raise_dtr_rts(port); |
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 | } | ||
302 | 324 | ||
303 | current->state = TASK_INTERRUPTIBLE; | 325 | current->state = TASK_INTERRUPTIBLE; |
304 | 326 | ||
@@ -315,7 +337,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
315 | * ready | 337 | * ready |
316 | */ | 338 | */ |
317 | if (!test_bit(ASYNCB_CLOSING, &port->flags) && | 339 | if (!test_bit(ASYNCB_CLOSING, &port->flags) && |
318 | (do_clocal || (self->settings.dce & IRCOMM_CD)) && | 340 | (do_clocal || tty_port_carrier_raised(port)) && |
319 | self->state == IRCOMM_TTY_READY) | 341 | self->state == IRCOMM_TTY_READY) |
320 | { | 342 | { |
321 | break; | 343 | break; |
@@ -379,6 +401,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
379 | } | 401 | } |
380 | 402 | ||
381 | tty_port_init(&self->port); | 403 | tty_port_init(&self->port); |
404 | self->port.ops = &ircomm_port_ops; | ||
382 | self->magic = IRCOMM_TTY_MAGIC; | 405 | self->magic = IRCOMM_TTY_MAGIC; |
383 | self->flow = FLOW_STOP; | 406 | self->flow = FLOW_STOP; |
384 | 407 | ||