aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/serial.h
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-03-21 07:36:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 16:50:51 -0400
commit980373b7918b8023be6b7df03857f494ae124d0b (patch)
tree0859105788cf8495327e8727a29779b7029024d0 /include/linux/usb/serial.h
parent143d9d961608b737d90a813deaaf91affb41c83c (diff)
USB: serial: add generic TIOCMIWAIT implementation
Add generic TIOCMIWAIT implementation which correctly handles hangup, USB-device disconnect, does not rely on the deprecated sleep_on functions and hence does not suffer from the races currently affecting several usb-serial drivers. This makes it much easier to add TIOCMIWAIT support to subdrivers as the tricky details related to hangup and disconnect (e.g. atomicity, that the private port data may have been freed when woken up, and waking up processes at disconnect) have been handled once and for all. To add support to a subdriver, simply set the tiocmiwait-port-operation field, update the port icount fields and wake up any process sleeping on the tty-port modem-status-change wait queue on changes. Note that the tty-port initialised flag can be used to detect disconnected as the port will be hung up as part of disconnect (and cannot be reactivated due to the disconnected flag). However, as the tty-port implementation currently wakes up processes before calling port shutdown, the tty-hupping flag must also be checked to detect hangup for now. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r--include/linux/usb/serial.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 9c8b53f80f48..47c8d2c506c8 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/kref.h> 16#include <linux/kref.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/serial.h>
18#include <linux/sysrq.h> 19#include <linux/sysrq.h>
19#include <linux/kfifo.h> 20#include <linux/kfifo.h>
20 21
@@ -61,6 +62,7 @@
61 * @bulk_out_buffers: pointers to the bulk out buffers for this port 62 * @bulk_out_buffers: pointers to the bulk out buffers for this port
62 * @write_urbs: pointers to the bulk out urbs for this port 63 * @write_urbs: pointers to the bulk out urbs for this port
63 * @write_urbs_free: status bitmap the for bulk out urbs 64 * @write_urbs_free: status bitmap the for bulk out urbs
65 * @icount: interrupt counters
64 * @tx_bytes: number of bytes currently in host stack queues 66 * @tx_bytes: number of bytes currently in host stack queues
65 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this 67 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this
66 * port. 68 * port.
@@ -109,6 +111,7 @@ struct usb_serial_port {
109 unsigned long write_urbs_free; 111 unsigned long write_urbs_free;
110 __u8 bulk_out_endpointAddress; 112 __u8 bulk_out_endpointAddress;
111 113
114 struct async_icount icount;
112 int tx_bytes; 115 int tx_bytes;
113 116
114 unsigned long flags; 117 unsigned long flags;
@@ -330,6 +333,8 @@ extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
330extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 333extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
331extern void usb_serial_generic_throttle(struct tty_struct *tty); 334extern void usb_serial_generic_throttle(struct tty_struct *tty);
332extern void usb_serial_generic_unthrottle(struct tty_struct *tty); 335extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
336extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty,
337 unsigned long arg);
333extern int usb_serial_generic_register(void); 338extern int usb_serial_generic_register(void);
334extern void usb_serial_generic_deregister(void); 339extern void usb_serial_generic_deregister(void);
335extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, 340extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,