aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_port.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2009-06-11 07:24:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:50:56 -0400
commitfcc8ac1825d3d0fb81f73bc1a80ebc863168bb56 (patch)
tree737f7209430fd319ca257df62c9b1e64587d5a8b /drivers/char/tty_port.c
parent65a29f60e121ae5116ac1736b50a237bf2db3225 (diff)
tty: Add carrier processing on close to the tty_port core
Some drivers implement this internally, others miss it out. Push the behaviour into the core code as that way everyone will do it consistently. Update the dtr rts method to raise or lower depending upon flags. Having a single method in this style fits most of the implementations more cleanly than two funtions. We need this in place before we tackle the USB side Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_port.c')
-rw-r--r--drivers/char/tty_port.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index 9b8004c72686..926d4a5593fa 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -137,7 +137,7 @@ int tty_port_carrier_raised(struct tty_port *port)
137EXPORT_SYMBOL(tty_port_carrier_raised); 137EXPORT_SYMBOL(tty_port_carrier_raised);
138 138
139/** 139/**
140 * tty_port_raise_dtr_rts - Riase DTR/RTS 140 * tty_port_raise_dtr_rts - Raise DTR/RTS
141 * @port: tty port 141 * @port: tty port
142 * 142 *
143 * Wrapper for the DTR/RTS raise logic. For the moment this is used 143 * Wrapper for the DTR/RTS raise logic. For the moment this is used
@@ -147,12 +147,28 @@ EXPORT_SYMBOL(tty_port_carrier_raised);
147 147
148void tty_port_raise_dtr_rts(struct tty_port *port) 148void tty_port_raise_dtr_rts(struct tty_port *port)
149{ 149{
150 if (port->ops->raise_dtr_rts) 150 if (port->ops->dtr_rts)
151 port->ops->raise_dtr_rts(port); 151 port->ops->dtr_rts(port, 1);
152} 152}
153EXPORT_SYMBOL(tty_port_raise_dtr_rts); 153EXPORT_SYMBOL(tty_port_raise_dtr_rts);
154 154
155/** 155/**
156 * tty_port_lower_dtr_rts - Lower DTR/RTS
157 * @port: tty port
158 *
159 * Wrapper for the DTR/RTS raise logic. For the moment this is used
160 * to hide some internal details. This will eventually become entirely
161 * internal to the tty port.
162 */
163
164void tty_port_lower_dtr_rts(struct tty_port *port)
165{
166 if (port->ops->dtr_rts)
167 port->ops->dtr_rts(port, 0);
168}
169EXPORT_SYMBOL(tty_port_lower_dtr_rts);
170
171/**
156 * tty_port_block_til_ready - Waiting logic for tty open 172 * tty_port_block_til_ready - Waiting logic for tty open
157 * @port: the tty port being opened 173 * @port: the tty port being opened
158 * @tty: the tty device being bound 174 * @tty: the tty device being bound
@@ -167,7 +183,7 @@ EXPORT_SYMBOL(tty_port_raise_dtr_rts);
167 * - port flags and counts 183 * - port flags and counts
168 * 184 *
169 * The passed tty_port must implement the carrier_raised method if it can 185 * The passed tty_port must implement the carrier_raised method if it can
170 * do carrier detect and the raise_dtr_rts method if it supports software 186 * do carrier detect and the dtr_rts method if it supports software
171 * management of these lines. Note that the dtr/rts raise is done each 187 * management of these lines. Note that the dtr/rts raise is done each
172 * iteration as a hangup may have previously dropped them while we wait. 188 * iteration as a hangup may have previously dropped them while we wait.
173 */ 189 */
@@ -302,6 +318,9 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)
302 318
303 tty_ldisc_flush(tty); 319 tty_ldisc_flush(tty);
304 320
321 if (tty->termios->c_cflag & HUPCL)
322 tty_port_lower_dtr_rts(port);
323
305 spin_lock_irqsave(&port->lock, flags); 324 spin_lock_irqsave(&port->lock, flags);
306 tty->closing = 0; 325 tty->closing = 0;
307 326