aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/serial.h
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:09:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:22 -0400
commit95da310e66ee8090119596c70ca8432e57f9a97f (patch)
tree7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /include/linux/usb/serial.h
parent1aa3692da57c773e5c76de55c5c4a953962d360e (diff)
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r--include/linux/usb/serial.h56
1 files changed, 30 insertions, 26 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 8f891cbaf9ab..09a3e6a7518f 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -62,7 +62,7 @@
62 */ 62 */
63struct usb_serial_port { 63struct usb_serial_port {
64 struct usb_serial *serial; 64 struct usb_serial *serial;
65 struct tty_struct *tty; 65 struct tty_port port;
66 spinlock_t lock; 66 spinlock_t lock;
67 struct mutex mutex; 67 struct mutex mutex;
68 unsigned char number; 68 unsigned char number;
@@ -89,7 +89,6 @@ struct usb_serial_port {
89 89
90 wait_queue_head_t write_wait; 90 wait_queue_head_t write_wait;
91 struct work_struct work; 91 struct work_struct work;
92 int open_count;
93 char throttled; 92 char throttled;
94 char throttle_req; 93 char throttle_req;
95 char console; 94 char console;
@@ -217,22 +216,27 @@ struct usb_serial_driver {
217 int (*resume)(struct usb_serial *serial); 216 int (*resume)(struct usb_serial *serial);
218 217
219 /* serial function calls */ 218 /* serial function calls */
220 int (*open)(struct usb_serial_port *port, struct file *filp); 219 /* Called by console with tty = NULL and by tty */
221 void (*close)(struct usb_serial_port *port, struct file *filp); 220 int (*open)(struct tty_struct *tty,
222 int (*write)(struct usb_serial_port *port, const unsigned char *buf, 221 struct usb_serial_port *port, struct file *filp);
223 int count); 222 void (*close)(struct tty_struct *tty,
224 int (*write_room)(struct usb_serial_port *port); 223 struct usb_serial_port *port, struct file *filp);
225 int (*ioctl)(struct usb_serial_port *port, struct file *file, 224 int (*write)(struct tty_struct *tty, struct usb_serial_port *port,
225 const unsigned char *buf, int count);
226 /* Called only by the tty layer */
227 int (*write_room)(struct tty_struct *tty);
228 int (*ioctl)(struct tty_struct *tty, struct file *file,
226 unsigned int cmd, unsigned long arg); 229 unsigned int cmd, unsigned long arg);
227 void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); 230 void (*set_termios)(struct tty_struct *tty,
228 void (*break_ctl)(struct usb_serial_port *port, int break_state); 231 struct usb_serial_port *port, struct ktermios *old);
229 int (*chars_in_buffer)(struct usb_serial_port *port); 232 void (*break_ctl)(struct tty_struct *tty, int break_state);
230 void (*throttle)(struct usb_serial_port *port); 233 int (*chars_in_buffer)(struct tty_struct *tty);
231 void (*unthrottle)(struct usb_serial_port *port); 234 void (*throttle)(struct tty_struct *tty);
232 int (*tiocmget)(struct usb_serial_port *port, struct file *file); 235 void (*unthrottle)(struct tty_struct *tty);
233 int (*tiocmset)(struct usb_serial_port *port, struct file *file, 236 int (*tiocmget)(struct tty_struct *tty, struct file *file);
237 int (*tiocmset)(struct tty_struct *tty, struct file *file,
234 unsigned int set, unsigned int clear); 238 unsigned int set, unsigned int clear);
235 239 /* USB events */
236 void (*read_int_callback)(struct urb *urb); 240 void (*read_int_callback)(struct urb *urb);
237 void (*write_int_callback)(struct urb *urb); 241 void (*write_int_callback)(struct urb *urb);
238 void (*read_bulk_callback)(struct urb *urb); 242 void (*read_bulk_callback)(struct urb *urb);
@@ -270,19 +274,19 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
270/* Functions needed by other parts of the usbserial core */ 274/* Functions needed by other parts of the usbserial core */
271extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); 275extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
272extern void usb_serial_put(struct usb_serial *serial); 276extern void usb_serial_put(struct usb_serial *serial);
273extern int usb_serial_generic_open(struct usb_serial_port *port, 277extern int usb_serial_generic_open(struct tty_struct *tty,
274 struct file *filp); 278 struct usb_serial_port *port, struct file *filp);
275extern int usb_serial_generic_write(struct usb_serial_port *port, 279extern int usb_serial_generic_write(struct tty_struct *tty,
276 const unsigned char *buf, int count); 280 struct usb_serial_port *port, const unsigned char *buf, int count);
277extern void usb_serial_generic_close(struct usb_serial_port *port, 281extern void usb_serial_generic_close(struct tty_struct *tty,
278 struct file *filp); 282 struct usb_serial_port *port, struct file *filp);
279extern int usb_serial_generic_resume(struct usb_serial *serial); 283extern int usb_serial_generic_resume(struct usb_serial *serial);
280extern int usb_serial_generic_write_room(struct usb_serial_port *port); 284extern int usb_serial_generic_write_room(struct tty_struct *tty);
281extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); 285extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty);
282extern void usb_serial_generic_read_bulk_callback(struct urb *urb); 286extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
283extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 287extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
284extern void usb_serial_generic_throttle(struct usb_serial_port *port); 288extern void usb_serial_generic_throttle(struct tty_struct *tty);
285extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); 289extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
286extern void usb_serial_generic_shutdown(struct usb_serial *serial); 290extern void usb_serial_generic_shutdown(struct usb_serial *serial);
287extern int usb_serial_generic_register(int debug); 291extern int usb_serial_generic_register(int debug);
288extern void usb_serial_generic_deregister(void); 292extern void usb_serial_generic_deregister(void);