[PATCH] USB console: fix disconnection issues
[pandora-kernel.git] / drivers / usb / serial / usb-serial.h
index 4ca5e0c..c07ece3 100644 (file)
@@ -1,53 +1,13 @@
 /*
  * USB Serial Converter driver
  *
- *     Copyright (C) 1999 - 2004
+ *     Copyright (C) 1999 - 2005
  *         Greg Kroah-Hartman (greg@kroah.com)
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
+ *     the Free Software Foundation; either version 2 of the License.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
- *
- * (03/26/2002) gkh
- *     removed the port->tty check from port_paranoia_check() due to serial
- *     consoles not having a tty device assigned to them.
- *
- * (12/03/2001) gkh
- *     removed active from the port structure.
- *     added documentation to the usb_serial_device_type structure
- *
- * (10/10/2001) gkh
- *     added vendor and product to serial structure.  Needed to determine device
- *     owner when the device is disconnected.
- *
- * (05/30/2001) gkh
- *     added sem to port structure and removed port_lock
- *
- * (10/05/2000) gkh
- *     Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help
- *     fix bug with urb->dev not being set properly, now that the usb core
- *     needs it.
- * 
- * (09/11/2000) gkh
- *     Added usb_serial_debug_data function to help get rid of #DEBUG in the
- *     drivers.
- *
- * (08/28/2000) gkh
- *     Added port_lock to port structure.
- *
- * (08/08/2000) gkh
- *     Added open_count to port structure.
- *
- * (07/23/2000) gkh
- *     Added bulk_out_endpointAddress to port structure.
- *
- * (07/19/2000) gkh, pberger, and borchers
- *     Modifications to allow usb-serial drivers to be modules.
- *
- * 
  */
 
 
@@ -56,6 +16,7 @@
 
 #include <linux/config.h>
 #include <linux/kref.h>
+#include <linux/mutex.h>
 
 #define SERIAL_TTY_MAJOR       188     /* Nice legal number now */
 #define SERIAL_TTY_MINORS      255     /* loads of devices :) */
@@ -70,6 +31,8 @@
  * @serial: pointer back to the struct usb_serial owner of this port.
  * @tty: pointer to the corresponding tty for this port.
  * @lock: spinlock to grab when updating portions of this structure.
+ * @mutex: mutex used to synchronize serial_open() and serial_close()
+ *     access for this port.
  * @number: the number of the port (the minor number).
  * @interrupt_in_buffer: pointer to the interrupt in buffer for this port.
  * @interrupt_in_urb: pointer to the interrupt in struct urb for this port.
@@ -100,6 +63,7 @@ struct usb_serial_port {
        struct usb_serial *     serial;
        struct tty_struct *     tty;
        spinlock_t              lock;
+       struct mutex            mutex;
        unsigned char           number;
 
        unsigned char *         interrupt_in_buffer;
@@ -189,11 +153,8 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
 
 /**
  * usb_serial_driver - describes a usb serial driver
- * @name: pointer to a string that describes this driver.  This string used
+ * @description: pointer to a string that describes this driver.  This string used
  *     in the syslog messages when a device is inserted or removed.
- * @short_name: a pointer to a string that describes this driver in
- *     KOBJ_NAME_LEN characters or less.  This is used for the sysfs interface
- *     to describe the driver.
  * @id_table: pointer to a list of usb_device_id structures that define all
  *     of the devices this structure can support.
  * @num_interrupt_in: the number of interrupt in endpoints this device will
@@ -227,11 +188,12 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
  * called, the generic serial function will be used instead.
  *
  * The driver.owner field should be set to the module owner of this driver.
- *
+ * The driver.name field should be set to the name of this driver (remember
+ * it will show up in sysfs, so it needs to be short and to the point.
+ * Useing the module name is a good idea.)
  */
 struct usb_serial_driver {
-       char    *name;
-       char    *short_name;
+       const char *description;
        const struct usb_device_id *id_table;
        char    num_interrupt_in;
        char    num_interrupt_out;
@@ -286,13 +248,16 @@ extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);
 #ifdef CONFIG_USB_SERIAL_CONSOLE
 extern void usb_serial_console_init (int debug, int minor);
 extern void usb_serial_console_exit (void);
+extern void usb_serial_console_disconnect(struct usb_serial *serial);
 #else
 static inline void usb_serial_console_init (int debug, int minor) { }
 static inline void usb_serial_console_exit (void) { }
+static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
 #endif
 
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial *usb_serial_get_by_index (unsigned int minor);
+extern void usb_serial_put(struct usb_serial *serial);
 extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);
 extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);
 extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);