diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2009-06-11 07:26:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-11 11:50:56 -0400 |
commit | 335f8514f200e63d689113d29cb7253a5c282967 (patch) | |
tree | 11504d090e8e2cd3c1ada3e6765f69f216065d00 /drivers/usb/serial/ch341.c | |
parent | 1ec739be75a6cb961a46ba0b1982d0edb7f27558 (diff) |
tty: Bring the usb tty port structure into more use
This allows us to clean stuff up, but is probably also going to cause
some app breakage with buggy apps as we now implement proper POSIX behaviour
for USB ports matching all the other ports. This does also mean other apps
that break on USB will now work properly.
Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/ch341.c')
-rw-r--r-- | drivers/usb/serial/ch341.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index ab4cc277aa65..2830766f5b39 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -262,32 +262,40 @@ error: kfree(priv); | |||
262 | return r; | 262 | return r; |
263 | } | 263 | } |
264 | 264 | ||
265 | static void ch341_close(struct tty_struct *tty, struct usb_serial_port *port, | 265 | static int ch341_carrier_raised(struct usb_serial_port *port) |
266 | struct file *filp) | 266 | { |
267 | struct ch341_private *priv = usb_get_serial_port_data(port); | ||
268 | if (priv->line_status & CH341_BIT_DCD) | ||
269 | return 1; | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static void ch341_dtr_rts(struct usb_serial_port *port, int on) | ||
267 | { | 274 | { |
268 | struct ch341_private *priv = usb_get_serial_port_data(port); | 275 | struct ch341_private *priv = usb_get_serial_port_data(port); |
269 | unsigned long flags; | 276 | unsigned long flags; |
270 | unsigned int c_cflag; | ||
271 | 277 | ||
272 | dbg("%s - port %d", __func__, port->number); | 278 | dbg("%s - port %d", __func__, port->number); |
279 | /* drop DTR and RTS */ | ||
280 | spin_lock_irqsave(&priv->lock, flags); | ||
281 | if (on) | ||
282 | priv->line_control |= CH341_BIT_RTS | CH341_BIT_DTR; | ||
283 | else | ||
284 | priv->line_control &= ~(CH341_BIT_RTS | CH341_BIT_DTR); | ||
285 | spin_unlock_irqrestore(&priv->lock, flags); | ||
286 | ch341_set_handshake(port->serial->dev, priv->line_control); | ||
287 | wake_up_interruptible(&priv->delta_msr_wait); | ||
288 | } | ||
289 | |||
290 | static void ch341_close(struct usb_serial_port *port) | ||
291 | { | ||
292 | dbg("%s - port %d", __func__, port->number); | ||
273 | 293 | ||
274 | /* shutdown our urbs */ | 294 | /* shutdown our urbs */ |
275 | dbg("%s - shutting down urbs", __func__); | 295 | dbg("%s - shutting down urbs", __func__); |
276 | usb_kill_urb(port->write_urb); | 296 | usb_kill_urb(port->write_urb); |
277 | usb_kill_urb(port->read_urb); | 297 | usb_kill_urb(port->read_urb); |
278 | usb_kill_urb(port->interrupt_in_urb); | 298 | usb_kill_urb(port->interrupt_in_urb); |
279 | |||
280 | if (tty) { | ||
281 | c_cflag = tty->termios->c_cflag; | ||
282 | if (c_cflag & HUPCL) { | ||
283 | /* drop DTR and RTS */ | ||
284 | spin_lock_irqsave(&priv->lock, flags); | ||
285 | priv->line_control = 0; | ||
286 | spin_unlock_irqrestore(&priv->lock, flags); | ||
287 | ch341_set_handshake(port->serial->dev, 0); | ||
288 | } | ||
289 | } | ||
290 | wake_up_interruptible(&priv->delta_msr_wait); | ||
291 | } | 299 | } |
292 | 300 | ||
293 | 301 | ||
@@ -302,7 +310,6 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
302 | dbg("ch341_open()"); | 310 | dbg("ch341_open()"); |
303 | 311 | ||
304 | priv->baud_rate = DEFAULT_BAUD_RATE; | 312 | priv->baud_rate = DEFAULT_BAUD_RATE; |
305 | priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; | ||
306 | 313 | ||
307 | r = ch341_configure(serial->dev, priv); | 314 | r = ch341_configure(serial->dev, priv); |
308 | if (r) | 315 | if (r) |
@@ -322,7 +329,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
322 | if (r) { | 329 | if (r) { |
323 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | 330 | dev_err(&port->dev, "%s - failed submitting interrupt urb," |
324 | " error %d\n", __func__, r); | 331 | " error %d\n", __func__, r); |
325 | ch341_close(tty, port, NULL); | 332 | ch341_close(port); |
326 | return -EPROTO; | 333 | return -EPROTO; |
327 | } | 334 | } |
328 | 335 | ||
@@ -343,9 +350,6 @@ static void ch341_set_termios(struct tty_struct *tty, | |||
343 | 350 | ||
344 | dbg("ch341_set_termios()"); | 351 | dbg("ch341_set_termios()"); |
345 | 352 | ||
346 | if (!tty || !tty->termios) | ||
347 | return; | ||
348 | |||
349 | baud_rate = tty_get_baud_rate(tty); | 353 | baud_rate = tty_get_baud_rate(tty); |
350 | 354 | ||
351 | priv->baud_rate = baud_rate; | 355 | priv->baud_rate = baud_rate; |
@@ -568,6 +572,8 @@ static struct usb_serial_driver ch341_device = { | |||
568 | .usb_driver = &ch341_driver, | 572 | .usb_driver = &ch341_driver, |
569 | .num_ports = 1, | 573 | .num_ports = 1, |
570 | .open = ch341_open, | 574 | .open = ch341_open, |
575 | .dtr_rts = ch341_dtr_rts, | ||
576 | .carrier_raised = ch341_carrier_raised, | ||
571 | .close = ch341_close, | 577 | .close = ch341_close, |
572 | .ioctl = ch341_ioctl, | 578 | .ioctl = ch341_ioctl, |
573 | .set_termios = ch341_set_termios, | 579 | .set_termios = ch341_set_termios, |