summaryrefslogtreecommitdiff
path: root/include/linux/usb
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-03-21 15:36:52 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-26 00:50:51 +0400
commit980373b7918b8023be6b7df03857f494ae124d0b (patch)
tree0859105788cf8495327e8727a29779b7029024d0 /include/linux/usb
parent143d9d961608b737d90a813deaaf91affb41c83c (diff)
downloadlinux-980373b7918b8023be6b7df03857f494ae124d0b.tar.xz
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')
-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 @@
#include <linux/kref.h>
#include <linux/mutex.h>
+#include <linux/serial.h>
#include <linux/sysrq.h>
#include <linux/kfifo.h>
@@ -61,6 +62,7 @@
* @bulk_out_buffers: pointers to the bulk out buffers for this port
* @write_urbs: pointers to the bulk out urbs for this port
* @write_urbs_free: status bitmap the for bulk out urbs
+ * @icount: interrupt counters
* @tx_bytes: number of bytes currently in host stack queues
* @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this
* port.
@@ -109,6 +111,7 @@ struct usb_serial_port {
unsigned long write_urbs_free;
__u8 bulk_out_endpointAddress;
+ struct async_icount icount;
int tx_bytes;
unsigned long flags;
@@ -330,6 +333,8 @@ extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
extern void usb_serial_generic_throttle(struct tty_struct *tty);
extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
+extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty,
+ unsigned long arg);
extern int usb_serial_generic_register(void);
extern void usb_serial_generic_deregister(void);
extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,