]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/usb/serial/usb-serial.c
USB: serial: remove usb_serial_disconnect call in all drivers
[linux-beck.git] / drivers / usb / serial / usb-serial.c
index 97355a15bbea8b5a36f3c7e52fd0eb5d4c3caa8a..9791312052e96438fa947515c0f28bc7367f7c9e 100644 (file)
 #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
 #define DRIVER_DESC "USB Serial Driver core"
 
-/* Driver structure we register with the USB core */
-static struct usb_driver usb_serial_driver = {
-       .name =         "usbserial",
-       .probe =        usb_serial_probe,
-       .disconnect =   usb_serial_disconnect,
-       .suspend =      usb_serial_suspend,
-       .resume =       usb_serial_resume,
-       .no_dynamic_id =        1,
-       .supports_autosuspend = 1,
-};
-
 /* There is no MODULE_DEVICE_TABLE for usbserial.c.  Instead
    the MODULE_DEVICE_TABLE declarations in each serial driver
    cause the "hotplug" program to pull in whatever module is necessary
@@ -1043,6 +1032,8 @@ int usb_serial_probe(struct usb_interface *interface,
                dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
        }
 
+       usb_set_intfdata(interface, serial);
+
        /* if this device type has an attach function, call it */
        if (type->attach) {
                retval = type->attach(serial);
@@ -1087,10 +1078,7 @@ int usb_serial_probe(struct usb_interface *interface,
        serial->disconnected = 0;
 
        usb_serial_console_init(debug, minor);
-
 exit:
-       /* success */
-       usb_set_intfdata(interface, serial);
        module_put(type->driver.owner);
        return 0;
 
@@ -1099,9 +1087,8 @@ probe_error:
        module_put(type->driver.owner);
        return -EIO;
 }
-EXPORT_SYMBOL_GPL(usb_serial_probe);
 
-void usb_serial_disconnect(struct usb_interface *interface)
+static void usb_serial_disconnect(struct usb_interface *interface)
 {
        int i;
        struct usb_serial *serial = usb_get_intfdata(interface);
@@ -1112,7 +1099,6 @@ void usb_serial_disconnect(struct usb_interface *interface)
        dbg("%s", __func__);
 
        mutex_lock(&serial->disc_mutex);
-       usb_set_intfdata(interface, NULL);
        /* must set a flag, to signal subdrivers */
        serial->disconnected = 1;
        mutex_unlock(&serial->disc_mutex);
@@ -1137,7 +1123,6 @@ void usb_serial_disconnect(struct usb_interface *interface)
        usb_serial_put(serial);
        dev_info(dev, "device disconnected\n");
 }
-EXPORT_SYMBOL_GPL(usb_serial_disconnect);
 
 int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
 {
@@ -1204,6 +1189,17 @@ static const struct tty_operations serial_ops = {
 
 struct tty_driver *usb_serial_tty_driver;
 
+/* Driver structure we register with the USB core */
+static struct usb_driver usb_serial_driver = {
+       .name =         "usbserial",
+       .probe =        usb_serial_probe,
+       .disconnect =   usb_serial_disconnect,
+       .suspend =      usb_serial_suspend,
+       .resume =       usb_serial_resume,
+       .no_dynamic_id =        1,
+       .supports_autosuspend = 1,
+};
+
 static int __init usb_serial_init(void)
 {
        int i;
@@ -1338,7 +1334,6 @@ static int usb_serial_register(struct usb_serial_driver *driver)
                                driver->description);
                return -EINVAL;
        }
-       driver->usb_driver->supports_autosuspend = 1;
 
        /* Add this device to our list of devices */
        mutex_lock(&table_lock);
@@ -1373,7 +1368,7 @@ static void usb_serial_deregister(struct usb_serial_driver *device)
  * @serial_drivers: NULL-terminated array of pointers to drivers to be registered
  *
  * Registers @udriver and all the drivers in the @serial_drivers array.
- * Automatically fills in the .no_dynamic_id field in @udriver and
+ * Automatically fills in the .no_dynamic_id and PM fields in @udriver and
  * the .usb_driver field in each serial driver.
  */
 int usb_serial_register_drivers(struct usb_driver *udriver,
@@ -1392,11 +1387,19 @@ int usb_serial_register_drivers(struct usb_driver *udriver,
         * the serial drivers are registered, because the probe would
         * simply fail for lack of a matching serial driver.
         * Therefore save off udriver's id_table until we are all set.
+        *
+        * Suspend/resume support is implemented in the usb-serial core,
+        * so fill in the PM-related fields in udriver.
         */
        saved_id_table = udriver->id_table;
        udriver->id_table = NULL;
 
        udriver->no_dynamic_id = 1;
+       udriver->supports_autosuspend = 1;
+       udriver->suspend = usb_serial_suspend;
+       udriver->resume = usb_serial_resume;
+       udriver->probe = usb_serial_probe;
+       udriver->disconnect = usb_serial_disconnect;
        rc = usb_register(udriver);
        if (rc)
                return rc;