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

aircable, ark3116, belkin_sa, ch341, cp210x, cyberjack,
and cypress_m8.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/aircable.c
drivers/usb/serial/ark3116.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/ch341.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c

index 123bf9155339c88ff8c0e428c323b08238dbe10b..dbf3bddc1b515c79a2b00677379465f5426a3873 100644 (file)
@@ -175,7 +175,6 @@ static struct usb_driver aircable_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver aircable_device = {
@@ -183,7 +182,6 @@ static struct usb_serial_driver aircable_device = {
                .owner =        THIS_MODULE,
                .name =         "aircable",
        },
-       .usb_driver =           &aircable_driver,
        .id_table =             id_table,
        .num_ports =            1,
        .bulk_out_size =        HCI_COMPLETE_FRAME,
@@ -194,27 +192,18 @@ static struct usb_serial_driver aircable_device = {
        .unthrottle =           usb_serial_generic_unthrottle,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &aircable_device, NULL
+};
+
 static int __init aircable_init(void)
 {
-       int retval;
-       retval = usb_serial_register(&aircable_device);
-       if (retval)
-               goto failed_serial_register;
-       retval = usb_register(&aircable_driver);
-       if (retval)
-               goto failed_usb_register;
-       return 0;
-
-failed_usb_register:
-       usb_serial_deregister(&aircable_device);
-failed_serial_register:
-       return retval;
+       return usb_serial_register_drivers(&aircable_driver, serial_drivers);
 }
 
 static void __exit aircable_exit(void)
 {
-       usb_deregister(&aircable_driver);
-       usb_serial_deregister(&aircable_device);
+       usb_serial_deregister_drivers(&aircable_driver, serial_drivers);
 }
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
index 69328dcfd91ada46bbe4c5bbc43cbd212c72cc11..ab2cf1165c60125ad592df873839849dcd84a139 100644 (file)
@@ -719,7 +719,6 @@ static struct usb_driver ark3116_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver ark3116_device = {
@@ -728,7 +727,6 @@ static struct usb_serial_driver ark3116_device = {
                .name =         "ark3116",
        },
        .id_table =             id_table,
-       .usb_driver =           &ark3116_driver,
        .num_ports =            1,
        .attach =               ark3116_attach,
        .release =              ark3116_release,
@@ -745,28 +743,27 @@ static struct usb_serial_driver ark3116_device = {
        .process_read_urb =     ark3116_process_read_urb,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &ark3116_device, NULL
+};
+
 static int __init ark3116_init(void)
 {
        int retval;
 
-       retval = usb_serial_register(&ark3116_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&ark3116_driver);
+       retval = usb_serial_register_drivers(&ark3116_driver, serial_drivers);
        if (retval == 0) {
                printk(KERN_INFO "%s:"
                       DRIVER_VERSION ":"
                       DRIVER_DESC "\n",
                       KBUILD_MODNAME);
-       } else
-               usb_serial_deregister(&ark3116_device);
+       }
        return retval;
 }
 
 static void __exit ark3116_exit(void)
 {
-       usb_deregister(&ark3116_driver);
-       usb_serial_deregister(&ark3116_device);
+       usb_serial_deregister_drivers(&ark3116_driver, serial_drivers);
 }
 
 module_init(ark3116_init);
index 29ffeb6279c7cd80cba7cdd46de9671085055d1a..e8b473f5acf7a1941f614fcc10bd0614f578b930 100644 (file)
@@ -78,7 +78,6 @@ static struct usb_driver belkin_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 serial converters */
@@ -88,7 +87,6 @@ static struct usb_serial_driver belkin_device = {
                .name =         "belkin",
        },
        .description =          "Belkin / Peracom / GoHubs USB Serial Adapter",
-       .usb_driver =           &belkin_driver,
        .id_table =             id_table_combined,
        .num_ports =            1,
        .open =                 belkin_sa_open,
@@ -103,6 +101,10 @@ static struct usb_serial_driver belkin_device = {
        .release =              belkin_sa_release,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &belkin_device, NULL
+};
+
 struct belkin_sa_private {
        spinlock_t              lock;
        unsigned long           control_state;
@@ -526,25 +528,17 @@ exit:
 static int __init belkin_sa_init(void)
 {
        int retval;
-       retval = usb_serial_register(&belkin_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&belkin_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(&belkin_device);
-failed_usb_serial_register:
+
+       retval = usb_serial_register_drivers(&belkin_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit belkin_sa_exit (void)
 {
-       usb_deregister(&belkin_driver);
-       usb_serial_deregister(&belkin_device);
+       usb_serial_deregister_drivers(&belkin_driver, serial_drivers);
 }
 
 
index 5e53cc59e652c406926fc6a5f37fe8e86c975a04..23de3b039a28af03fa89a00595a9f8c568e8e326 100644 (file)
@@ -625,7 +625,6 @@ static struct usb_driver ch341_driver = {
        .resume         = usb_serial_resume,
        .reset_resume   = ch341_reset_resume,
        .id_table       = id_table,
-       .no_dynamic_id  = 1,
        .supports_autosuspend = 1,
 };
 
@@ -635,7 +634,6 @@ static struct usb_serial_driver ch341_device = {
                .name   = "ch341-uart",
        },
        .id_table          = id_table,
-       .usb_driver        = &ch341_driver,
        .num_ports         = 1,
        .open              = ch341_open,
        .dtr_rts           = ch341_dtr_rts,
@@ -650,23 +648,18 @@ static struct usb_serial_driver ch341_device = {
        .attach            = ch341_attach,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &ch341_device, NULL
+};
+
 static int __init ch341_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&ch341_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&ch341_driver);
-       if (retval)
-               usb_serial_deregister(&ch341_device);
-       return retval;
+       return usb_serial_register_drivers(&ch341_driver, serial_drivers);
 }
 
 static void __exit ch341_exit(void)
 {
-       usb_deregister(&ch341_driver);
-       usb_serial_deregister(&ch341_device);
+       usb_serial_deregister_drivers(&ch341_driver, serial_drivers);
 }
 
 module_init(ch341_init);
index ec9dc4e9a3ff9fa1bb070589f701f7e485e3702e..01a9374357f13d719be250ba8d56270a7fb8374b 100644 (file)
@@ -154,7 +154,6 @@ static struct usb_driver cp210x_driver = {
        .probe          = usb_serial_probe,
        .disconnect     = usb_serial_disconnect,
        .id_table       = id_table,
-       .no_dynamic_id  =       1,
 };
 
 static struct usb_serial_driver cp210x_device = {
@@ -162,7 +161,6 @@ static struct usb_serial_driver cp210x_device = {
                .owner =        THIS_MODULE,
                .name =         "cp210x",
        },
-       .usb_driver             = &cp210x_driver,
        .id_table               = id_table,
        .num_ports              = 1,
        .bulk_in_size           = 256,
@@ -177,6 +175,10 @@ static struct usb_serial_driver cp210x_device = {
        .dtr_rts                = cp210x_dtr_rts
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &cp210x_device, NULL
+};
+
 /* Config request types */
 #define REQTYPE_HOST_TO_DEVICE 0x41
 #define REQTYPE_DEVICE_TO_HOST 0xc1
@@ -852,27 +854,16 @@ static int __init cp210x_init(void)
 {
        int retval;
 
-       retval = usb_serial_register(&cp210x_device);
-       if (retval)
-               return retval; /* Failed to register */
-
-       retval = usb_register(&cp210x_driver);
-       if (retval) {
-               /* Failed to register */
-               usb_serial_deregister(&cp210x_device);
-               return retval;
-       }
-
-       /* Success */
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-              DRIVER_DESC "\n");
-       return 0;
+       retval = usb_serial_register_drivers(&cp210x_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
+       return retval;
 }
 
 static void __exit cp210x_exit(void)
 {
-       usb_deregister(&cp210x_driver);
-       usb_serial_deregister(&cp210x_device);
+       usb_serial_deregister_drivers(&cp210x_driver, serial_drivers);
 }
 
 module_init(cp210x_init);
index 6bc3802a581af7f43239869864146e69bc20c3e4..d2e536f649ba7c24f0be02e6c0249d6b622fcf2e 100644 (file)
@@ -82,7 +82,6 @@ static struct usb_driver cyberjack_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver cyberjack_device = {
@@ -91,7 +90,6 @@ static struct usb_serial_driver cyberjack_device = {
                .name =         "cyberjack",
        },
        .description =          "Reiner SCT Cyberjack USB card reader",
-       .usb_driver =           &cyberjack_driver,
        .id_table =             id_table,
        .num_ports =            1,
        .attach =               cyberjack_startup,
@@ -106,6 +104,10 @@ static struct usb_serial_driver cyberjack_device = {
        .write_bulk_callback =  cyberjack_write_bulk_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &cyberjack_device, NULL
+};
+
 struct cyberjack_private {
        spinlock_t      lock;           /* Lock for SMP */
        short           rdtodo;         /* Bytes still to read */
@@ -476,28 +478,19 @@ exit:
 static int __init cyberjack_init(void)
 {
        int retval;
-       retval  = usb_serial_register(&cyberjack_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&cyberjack_driver);
-       if (retval)
-               goto failed_usb_register;
-
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " "
-              DRIVER_AUTHOR "\n");
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
 
-       return 0;
-failed_usb_register:
-       usb_serial_deregister(&cyberjack_device);
-failed_usb_serial_register:
+       retval = usb_serial_register_drivers(&cyberjack_driver, serial_drivers);
+       if (retval == 0) {
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " "
+                              DRIVER_AUTHOR "\n");
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
+       }
        return retval;
 }
 
 static void __exit cyberjack_exit(void)
 {
-       usb_deregister(&cyberjack_driver);
-       usb_serial_deregister(&cyberjack_device);
+       usb_serial_deregister_drivers(&cyberjack_driver, serial_drivers);
 }
 
 module_init(cyberjack_init);
index 5ae86b349cad7871d0e03926c24b81142ef31329..bc5057513d5d69963b33abd9296d2e0ca5253613 100644 (file)
@@ -94,7 +94,6 @@ static struct usb_driver cypress_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
-       .no_dynamic_id =        1,
 };
 
 enum packet_format {
@@ -163,7 +162,6 @@ static struct usb_serial_driver cypress_earthmate_device = {
                .name =                 "earthmate",
        },
        .description =                  "DeLorme Earthmate USB",
-       .usb_driver =                   &cypress_driver,
        .id_table =                     id_table_earthmate,
        .num_ports =                    1,
        .attach =                       cypress_earthmate_startup,
@@ -190,7 +188,6 @@ static struct usb_serial_driver cypress_hidcom_device = {
                .name =                 "cyphidcom",
        },
        .description =                  "HID->COM RS232 Adapter",
-       .usb_driver =                   &cypress_driver,
        .id_table =                     id_table_cyphidcomrs232,
        .num_ports =                    1,
        .attach =                       cypress_hidcom_startup,
@@ -217,7 +214,6 @@ static struct usb_serial_driver cypress_ca42v2_device = {
                .name =                 "nokiaca42v2",
        },
        .description =                  "Nokia CA-42 V2 Adapter",
-       .usb_driver =                   &cypress_driver,
        .id_table =                     id_table_nokiaca42v2,
        .num_ports =                    1,
        .attach =                       cypress_ca42v2_startup,
@@ -238,6 +234,11 @@ static struct usb_serial_driver cypress_ca42v2_device = {
        .write_int_callback =           cypress_write_int_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &cypress_earthmate_device, &cypress_hidcom_device,
+       &cypress_ca42v2_device, NULL
+};
+
 /*****************************************************************************
  * Cypress serial helper functions
  *****************************************************************************/
@@ -1356,30 +1357,10 @@ static int __init cypress_init(void)
 
        dbg("%s", __func__);
 
-       retval = usb_serial_register(&cypress_earthmate_device);
-       if (retval)
-               goto failed_em_register;
-       retval = usb_serial_register(&cypress_hidcom_device);
-       if (retval)
-               goto failed_hidcom_register;
-       retval = usb_serial_register(&cypress_ca42v2_device);
-       if (retval)
-               goto failed_ca42v2_register;
-       retval = usb_register(&cypress_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(&cypress_ca42v2_device);
-failed_ca42v2_register:
-       usb_serial_deregister(&cypress_hidcom_device);
-failed_hidcom_register:
-       usb_serial_deregister(&cypress_earthmate_device);
-failed_em_register:
+       retval = usb_serial_register_drivers(&cypress_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
@@ -1388,10 +1369,7 @@ static void __exit cypress_exit(void)
 {
        dbg("%s", __func__);
 
-       usb_deregister(&cypress_driver);
-       usb_serial_deregister(&cypress_earthmate_device);
-       usb_serial_deregister(&cypress_hidcom_device);
-       usb_serial_deregister(&cypress_ca42v2_device);
+       usb_serial_deregister_drivers(&cypress_driver, serial_drivers);
 }