usb-serial: use new registration API in [t-z]* drivers
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 23 Feb 2012 19:57:32 +0000 (14:57 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Feb 2012 20:39:21 +0000 (12:39 -0800)
This patch (as1529) modifies the following usb-serial drivers to
utilize the new usb_serial_{de}register_drivers() routines:

ti_usb_3410_5052, usb_debug, visor, vivopay-serial,
whiteheat, and zio.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb_debug.c
drivers/usb/serial/visor.c
drivers/usb/serial/vivopay-serial.c
drivers/usb/serial/whiteheat.c
drivers/usb/serial/zio.c

index 74f2c7746cc4d95993f1b70037622f18fa2fefc5..ab74123d658eba545bcb47b25478689243f973c3 100644 (file)
@@ -216,7 +216,6 @@ static struct usb_driver ti_usb_driver = {
        .probe                  = usb_serial_probe,
        .disconnect             = usb_serial_disconnect,
        .id_table               = ti_id_table_combined,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver ti_1port_device = {
@@ -225,7 +224,6 @@ static struct usb_serial_driver ti_1port_device = {
                .name           = "ti_usb_3410_5052_1",
        },
        .description            = "TI USB 3410 1 port adapter",
-       .usb_driver             = &ti_usb_driver,
        .id_table               = ti_id_table_3410,
        .num_ports              = 1,
        .attach                 = ti_startup,
@@ -254,7 +252,6 @@ static struct usb_serial_driver ti_2port_device = {
                .name           = "ti_usb_3410_5052_2",
        },
        .description            = "TI USB 5052 2 port adapter",
-       .usb_driver             = &ti_usb_driver,
        .id_table               = ti_id_table_5052,
        .num_ports              = 2,
        .attach                 = ti_startup,
@@ -277,6 +274,9 @@ static struct usb_serial_driver ti_2port_device = {
        .write_bulk_callback    = ti_bulk_out_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &ti_1port_device, &ti_2port_device, NULL
+};
 
 /* Module */
 
@@ -344,36 +344,17 @@ static int __init ti_init(void)
                ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
        }
 
-       ret = usb_serial_register(&ti_1port_device);
-       if (ret)
-               goto failed_1port;
-       ret = usb_serial_register(&ti_2port_device);
-       if (ret)
-               goto failed_2port;
-
-       ret = usb_register(&ti_usb_driver);
-       if (ret)
-               goto failed_usb;
-
-       printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":"
-              TI_DRIVER_DESC "\n");
-
-       return 0;
-
-failed_usb:
-       usb_serial_deregister(&ti_2port_device);
-failed_2port:
-       usb_serial_deregister(&ti_1port_device);
-failed_1port:
+       ret = usb_serial_register_drivers(&ti_usb_driver, serial_drivers);
+       if (ret == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":"
+                              TI_DRIVER_DESC "\n");
        return ret;
 }
 
 
 static void __exit ti_exit(void)
 {
-       usb_deregister(&ti_usb_driver);
-       usb_serial_deregister(&ti_1port_device);
-       usb_serial_deregister(&ti_2port_device);
+       usb_serial_deregister_drivers(&ti_usb_driver, serial_drivers);
 }
 
 
index 9b632e753210fcdab6124b4ff8e4e6c0c1406175..5b29b4a2ebc78a5fd41733bada59295fdf631af7 100644 (file)
@@ -40,7 +40,6 @@ static struct usb_driver debug_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 /* This HW really does not support a serial break, so one will be
@@ -74,30 +73,24 @@ static struct usb_serial_driver debug_device = {
                .name =         "debug",
        },
        .id_table =             id_table,
-       .usb_driver =           &debug_driver,
        .num_ports =            1,
        .bulk_out_size =        USB_DEBUG_MAX_PACKET_SIZE,
        .break_ctl =            usb_debug_break_ctl,
        .process_read_urb =     usb_debug_process_read_urb,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &debug_device, NULL
+};
+
 static int __init debug_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&debug_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&debug_driver);
-       if (retval)
-               usb_serial_deregister(&debug_device);
-       return retval;
+       return usb_serial_register_drivers(&debug_driver, serial_drivers);
 }
 
 static void __exit debug_exit(void)
 {
-       usb_deregister(&debug_driver);
-       usb_serial_deregister(&debug_device);
+       usb_serial_deregister_drivers(&debug_driver, serial_drivers);
 }
 
 module_init(debug_init);
index 210e4b10dc1126ade0a1ba9e04ea7a0485362404..71d696474f24d500ecd59af248a1e7f6e4dd0282 100644 (file)
@@ -173,7 +173,6 @@ static struct usb_driver visor_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
-       .no_dynamic_id =        1,
 };
 
 /* All of the device info needed for the Handspring Visor,
@@ -184,7 +183,6 @@ static struct usb_serial_driver handspring_device = {
                .name =         "visor",
        },
        .description =          "Handspring Visor / Palm OS",
-       .usb_driver =           &visor_driver,
        .id_table =             id_table,
        .num_ports =            2,
        .bulk_out_size =        256,
@@ -205,7 +203,6 @@ static struct usb_serial_driver clie_5_device = {
                .name =         "clie_5",
        },
        .description =          "Sony Clie 5.0",
-       .usb_driver =           &visor_driver,
        .id_table =             clie_id_5_table,
        .num_ports =            2,
        .bulk_out_size =        256,
@@ -226,7 +223,6 @@ static struct usb_serial_driver clie_3_5_device = {
                .name =         "clie_3.5",
        },
        .description =          "Sony Clie 3.5",
-       .usb_driver =           &visor_driver,
        .id_table =             clie_id_3_5_table,
        .num_ports =            1,
        .bulk_out_size =        256,
@@ -237,6 +233,10 @@ static struct usb_serial_driver clie_3_5_device = {
        .attach =               clie_3_5_startup,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &handspring_device, &clie_5_device, &clie_3_5_device, NULL
+};
+
 /******************************************************************************
  * Handspring Visor specific driver functions
  ******************************************************************************/
@@ -685,38 +685,17 @@ static int __init visor_init(void)
                       ": Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x\n",
                        vendor, product);
        }
-       retval = usb_serial_register(&handspring_device);
-       if (retval)
-               goto failed_handspring_register;
-       retval = usb_serial_register(&clie_3_5_device);
-       if (retval)
-               goto failed_clie_3_5_register;
-       retval = usb_serial_register(&clie_5_device);
-       if (retval)
-               goto failed_clie_5_register;
-       retval = usb_register(&visor_driver);
-       if (retval)
-               goto failed_usb_register;
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
 
-       return 0;
-failed_usb_register:
-       usb_serial_deregister(&clie_5_device);
-failed_clie_5_register:
-       usb_serial_deregister(&clie_3_5_device);
-failed_clie_3_5_register:
-       usb_serial_deregister(&handspring_device);
-failed_handspring_register:
+       retval = usb_serial_register_drivers(&visor_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
        return retval;
 }
 
 
 static void __exit visor_exit (void)
 {
-       usb_deregister(&visor_driver);
-       usb_serial_deregister(&handspring_device);
-       usb_serial_deregister(&clie_3_5_device);
-       usb_serial_deregister(&clie_5_device);
+       usb_serial_deregister_drivers(&visor_driver, serial_drivers);
 }
 
 
index f719d00972fc1ba0b9914ed021bf7992019f8c47..a6f113bd4fae5ee88ca81002ed3021f1f00e7ffb 100644 (file)
@@ -30,7 +30,6 @@ static struct usb_driver vivopay_serial_driver = {
        .probe =                usb_serial_probe,
        .disconnect =           usb_serial_disconnect,
        .id_table =             id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver vivopay_serial_device = {
@@ -39,32 +38,28 @@ static struct usb_serial_driver vivopay_serial_device = {
                .name =         "vivopay-serial",
        },
        .id_table =             id_table,
-       .usb_driver =           &vivopay_serial_driver,
        .num_ports =            1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &vivopay_serial_device, NULL
+};
+
 static int __init vivopay_serial_init(void)
 {
        int retval;
-       retval = usb_serial_register(&vivopay_serial_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&vivopay_serial_driver);
-       if (retval)
-               goto failed_usb_register;
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-           DRIVER_DESC "\n");
-       return 0;
-failed_usb_register:
-       usb_serial_deregister(&vivopay_serial_device);
-failed_usb_serial_register:
+
+       retval = usb_serial_register_drivers(&vivopay_serial_driver,
+                       serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                               DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit vivopay_serial_exit(void)
 {
-       usb_deregister(&vivopay_serial_driver);
-       usb_serial_deregister(&vivopay_serial_device);
+       usb_serial_deregister_drivers(&vivopay_serial_driver, serial_drivers);
 }
 
 module_init(vivopay_serial_init);
index 007cf3a2481aa55298785928aff437290990071e..a29be37a3a6714f3b2c4be3aa7159e13c3cbf88b 100644 (file)
@@ -83,7 +83,6 @@ static struct usb_driver whiteheat_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
-       .no_dynamic_id =        1,
 };
 
 /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
@@ -121,7 +120,6 @@ static struct usb_serial_driver whiteheat_fake_device = {
                .name =         "whiteheatnofirm",
        },
        .description =          "Connect Tech - WhiteHEAT - (prerenumeration)",
-       .usb_driver =           &whiteheat_driver,
        .id_table =             id_table_prerenumeration,
        .num_ports =            1,
        .probe =                whiteheat_firmware_download,
@@ -134,7 +132,6 @@ static struct usb_serial_driver whiteheat_device = {
                .name =         "whiteheat",
        },
        .description =          "Connect Tech - WhiteHEAT",
-       .usb_driver =           &whiteheat_driver,
        .id_table =             id_table_std,
        .num_ports =            4,
        .attach =               whiteheat_attach,
@@ -155,6 +152,9 @@ static struct usb_serial_driver whiteheat_device = {
        .write_bulk_callback =  whiteheat_write_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &whiteheat_fake_device, &whiteheat_device, NULL
+};
 
 struct whiteheat_command_private {
        struct mutex            mutex;
@@ -1461,32 +1461,18 @@ out:
 static int __init whiteheat_init(void)
 {
        int retval;
-       retval = usb_serial_register(&whiteheat_fake_device);
-       if (retval)
-               goto failed_fake_register;
-       retval = usb_serial_register(&whiteheat_device);
-       if (retval)
-               goto failed_device_register;
-       retval = usb_register(&whiteheat_driver);
-       if (retval)
-               goto failed_usb_register;
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-              DRIVER_DESC "\n");
-       return 0;
-failed_usb_register:
-       usb_serial_deregister(&whiteheat_device);
-failed_device_register:
-       usb_serial_deregister(&whiteheat_fake_device);
-failed_fake_register:
+
+       retval = usb_serial_register_drivers(&whiteheat_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                               DRIVER_DESC "\n");
        return retval;
 }
 
 
 static void __exit whiteheat_exit(void)
 {
-       usb_deregister(&whiteheat_driver);
-       usb_serial_deregister(&whiteheat_fake_device);
-       usb_serial_deregister(&whiteheat_device);
+       usb_serial_deregister_drivers(&whiteheat_driver, serial_drivers);
 }
 
 
index f57967278833b34955edabd75fac7b0bf0f8c9aa..ae8115aab77d63e80b2704b6067efa05d50368a1 100644 (file)
@@ -27,7 +27,6 @@ static struct usb_driver zio_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver zio_device = {
@@ -36,27 +35,21 @@ static struct usb_serial_driver zio_device = {
                .name =         "zio",
        },
        .id_table =             id_table,
-       .usb_driver =           &zio_driver,
        .num_ports =            1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &zio_device, NULL
+};
+
 static int __init zio_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&zio_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&zio_driver);
-       if (retval)
-               usb_serial_deregister(&zio_device);
-       return retval;
+       return usb_serial_register_drivers(&zio_driver, serial_drivers);
 }
 
 static void __exit zio_exit(void)
 {
-       usb_deregister(&zio_driver);
-       usb_serial_deregister(&zio_device);
+       usb_serial_deregister_drivers(&zio_driver, serial_drivers);
 }
 
 module_init(zio_init);