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

qcaux, qcserial, safe_serial, siemens_mpi, sierra,
spcp8x5, ssu100, and symbolserial.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/qcaux.c
drivers/usb/serial/qcserial.c
drivers/usb/serial/safe_serial.c
drivers/usb/serial/siemens_mpi.c
drivers/usb/serial/sierra.c
drivers/usb/serial/spcp8x5.c
drivers/usb/serial/ssu100.c
drivers/usb/serial/symbolserial.c

index a34819884c1ad6b82e732f069e7392f0272d766f..a2ce274b3f2874ecd8eb0877bcb3cffde35d453c 100644 (file)
@@ -82,7 +82,6 @@ static struct usb_driver qcaux_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver qcaux_device = {
@@ -91,27 +90,21 @@ static struct usb_serial_driver qcaux_device = {
                .name =         "qcaux",
        },
        .id_table =             id_table,
-       .usb_driver =           &qcaux_driver,
        .num_ports =            1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &qcaux_device, NULL
+};
+
 static int __init qcaux_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&qcaux_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&qcaux_driver);
-       if (retval)
-               usb_serial_deregister(&qcaux_device);
-       return retval;
+       return usb_serial_register_drivers(&qcaux_driver, serial_drivers);
 }
 
 static void __exit qcaux_exit(void)
 {
-       usb_deregister(&qcaux_driver);
-       usb_serial_deregister(&qcaux_device);
+       usb_serial_deregister_drivers(&qcaux_driver, serial_drivers);
 }
 
 module_init(qcaux_init);
index f98800f2324c22afda070ca85af221af64060310..70e9f1abdad1bcf1c6d1ac2053533e0178dcca28 100644 (file)
@@ -246,7 +246,6 @@ static struct usb_serial_driver qcdevice = {
        },
        .description         = "Qualcomm USB modem",
        .id_table            = id_table,
-       .usb_driver          = &qcdriver,
        .num_ports           = 1,
        .probe               = qcprobe,
        .open                = usb_wwan_open,
@@ -263,27 +262,18 @@ static struct usb_serial_driver qcdevice = {
 #endif
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &qcdevice, NULL
+};
+
 static int __init qcinit(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&qcdevice);
-       if (retval)
-               return retval;
-
-       retval = usb_register(&qcdriver);
-       if (retval) {
-               usb_serial_deregister(&qcdevice);
-               return retval;
-       }
-
-       return 0;
+       return usb_serial_register_drivers(&qcdriver, serial_drivers);
 }
 
 static void __exit qcexit(void)
 {
-       usb_deregister(&qcdriver);
-       usb_serial_deregister(&qcdevice);
+       usb_serial_deregister_drivers(&qcdriver, serial_drivers);
 }
 
 module_init(qcinit);
index d074b3740dcb8323d7b4f506c91adad21d24e354..ae4ee30c7411882dd9df3e22d436db54ee28ddcf 100644 (file)
@@ -156,7 +156,6 @@ static struct usb_driver safe_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static const __u16 crc10_table[256] = {
@@ -309,16 +308,19 @@ static struct usb_serial_driver safe_device = {
                .name =         "safe_serial",
        },
        .id_table =             id_table,
-       .usb_driver =           &safe_driver,
        .num_ports =            1,
        .process_read_urb =     safe_process_read_urb,
        .prepare_write_buffer = safe_prepare_write_buffer,
        .attach =               safe_startup,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &safe_device, NULL
+};
+
 static int __init safe_init(void)
 {
-       int i, retval;
+       int i;
 
        printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
               DRIVER_DESC "\n");
@@ -337,24 +339,12 @@ static int __init safe_init(void)
                }
        }
 
-       retval = usb_serial_register(&safe_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&safe_driver);
-       if (retval)
-               goto failed_usb_register;
-
-       return 0;
-failed_usb_register:
-       usb_serial_deregister(&safe_device);
-failed_usb_serial_register:
-       return retval;
+       return usb_serial_register_drivers(&safe_driver, serial_drivers);
 }
 
 static void __exit safe_exit(void)
 {
-       usb_deregister(&safe_driver);
-       usb_serial_deregister(&safe_device);
+       usb_serial_deregister_drivers(&safe_driver, serial_drivers);
 }
 
 module_init(safe_init);
index 74cd4ccdb3fcc1b344de2e969df87c4882825ea4..8aa4c1aef6d1665a9b421e9228f0d4767d05bb0d 100644 (file)
@@ -42,33 +42,29 @@ static struct usb_serial_driver siemens_usb_mpi_device = {
                .name =         "siemens_mpi",
        },
        .id_table =             id_table,
-       .usb_driver =           &siemens_usb_mpi_driver,
        .num_ports =            1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &siemens_usb_mpi_device, NULL
+};
+
 static int __init siemens_usb_mpi_init(void)
 {
        int retval;
 
-       retval = usb_serial_register(&siemens_usb_mpi_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&siemens_usb_mpi_driver);
-       if (retval)
-               goto failed_usb_register;
-       printk(KERN_INFO DRIVER_DESC "\n");
-       printk(KERN_INFO DRIVER_VERSION " " DRIVER_AUTHOR "\n");
-       return retval;
-failed_usb_register:
-       usb_serial_deregister(&siemens_usb_mpi_device);
-failed_usb_serial_register:
+       retval = usb_serial_register_drivers(&siemens_usb_mpi_driver,
+                       serial_drivers);
+       if (retval == 0) {
+               printk(KERN_INFO DRIVER_DESC "\n");
+               printk(KERN_INFO DRIVER_VERSION " " DRIVER_AUTHOR "\n");
+       }
        return retval;
 }
 
 static void __exit siemens_usb_mpi_exit(void)
 {
-       usb_deregister(&siemens_usb_mpi_driver);
-       usb_serial_deregister(&siemens_usb_mpi_device);
+       usb_serial_deregister_drivers(&siemens_usb_mpi_driver, serial_drivers);
 }
 
 module_init(siemens_usb_mpi_init);
index fdae0a4407cb7b9ddbc0068e4ef2690ba4bbfcf8..d75a75b83e9f09484e23a495cc683816f99c8a01 100644 (file)
@@ -1084,7 +1084,6 @@ static struct usb_driver sierra_driver = {
        .resume     = usb_serial_resume,
        .reset_resume = sierra_reset_resume,
        .id_table   = id_table,
-       .no_dynamic_id =        1,
        .supports_autosuspend = 1,
 };
 
@@ -1095,7 +1094,6 @@ static struct usb_serial_driver sierra_device = {
        },
        .description       = "Sierra USB modem",
        .id_table          = id_table,
-       .usb_driver        = &sierra_driver,
        .calc_num_ports    = sierra_calc_num_ports,
        .probe             = sierra_probe,
        .open              = sierra_open,
@@ -1113,34 +1111,25 @@ static struct usb_serial_driver sierra_device = {
        .read_int_callback = sierra_instat_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &sierra_device, NULL
+};
+
 /* Functions used by new usb-serial code. */
 static int __init sierra_init(void)
 {
        int retval;
-       retval = usb_serial_register(&sierra_device);
-       if (retval)
-               goto failed_device_register;
-
-
-       retval = usb_register(&sierra_driver);
-       if (retval)
-               goto failed_driver_register;
-
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-              DRIVER_DESC "\n");
-
-       return 0;
 
-failed_driver_register:
-       usb_serial_deregister(&sierra_device);
-failed_device_register:
+       retval = usb_serial_register_drivers(&sierra_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit sierra_exit(void)
 {
-       usb_deregister(&sierra_driver);
-       usb_serial_deregister(&sierra_device);
+       usb_serial_deregister_drivers(&sierra_driver, serial_drivers);
 }
 
 module_init(sierra_init);
index d7f5eee18f0010bc7685aef9a6ec9e848277b14e..af898937d4b1b385c40475e46d99d821e60e2b48 100644 (file)
@@ -156,7 +156,6 @@ static struct usb_driver spcp8x5_driver = {
        .probe =                usb_serial_probe,
        .disconnect =           usb_serial_disconnect,
        .id_table =             id_table,
-       .no_dynamic_id =        1,
 };
 
 
@@ -649,7 +648,6 @@ static struct usb_serial_driver spcp8x5_device = {
                .name =         "SPCP8x5",
        },
        .id_table               = id_table,
-       .usb_driver             = &spcp8x5_driver,
        .num_ports              = 1,
        .open                   = spcp8x5_open,
        .dtr_rts                = spcp8x5_dtr_rts,
@@ -664,28 +662,24 @@ static struct usb_serial_driver spcp8x5_device = {
        .process_read_urb       = spcp8x5_process_read_urb,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &spcp8x5_device, NULL
+};
+
 static int __init spcp8x5_init(void)
 {
        int retval;
-       retval = usb_serial_register(&spcp8x5_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&spcp8x5_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(&spcp8x5_device);
-failed_usb_serial_register:
+
+       retval = usb_serial_register_drivers(&spcp8x5_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit spcp8x5_exit(void)
 {
-       usb_deregister(&spcp8x5_driver);
-       usb_serial_deregister(&spcp8x5_device);
+       usb_serial_deregister_drivers(&spcp8x5_driver, serial_drivers);
 }
 
 module_init(spcp8x5_init);
index 7697858d8858abefb181e9f139a17c17b6240890..ab8842107a8b770a36a17fa653215f60c12f4813 100644 (file)
@@ -70,7 +70,6 @@ static struct usb_driver ssu100_driver = {
        .id_table                      = id_table,
        .suspend                       = usb_serial_suspend,
        .resume                        = usb_serial_resume,
-       .no_dynamic_id                 = 1,
        .supports_autosuspend          = 1,
 };
 
@@ -677,7 +676,6 @@ static struct usb_serial_driver ssu100_device = {
        },
        .description         = DRIVER_DESC,
        .id_table            = id_table,
-       .usb_driver          = &ssu100_driver,
        .num_ports           = 1,
        .open                = ssu100_open,
        .close               = ssu100_close,
@@ -693,37 +691,26 @@ static struct usb_serial_driver ssu100_device = {
        .disconnect          = usb_serial_generic_disconnect,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &ssu100_device, NULL
+};
+
 static int __init ssu100_init(void)
 {
        int retval;
 
        dbg("%s", __func__);
 
-       /* register with usb-serial */
-       retval = usb_serial_register(&ssu100_device);
-
-       if (retval)
-               goto failed_usb_sio_register;
-
-       retval = usb_register(&ssu100_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(&ssu100_device);
-failed_usb_sio_register:
+       retval = usb_serial_register_drivers(&ssu100_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit ssu100_exit(void)
 {
-       usb_deregister(&ssu100_driver);
-       usb_serial_deregister(&ssu100_device);
+       usb_serial_deregister_drivers(&ssu100_driver, serial_drivers);
 }
 
 module_init(ssu100_init);
index 50651cf4fc613bc8ab0e89de48755361d50e9936..76cd9f2a08c058555990398c480b40df227e9f04 100644 (file)
@@ -287,7 +287,6 @@ static struct usb_driver symbol_driver = {
        .probe =                usb_serial_probe,
        .disconnect =           usb_serial_disconnect,
        .id_table =             id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver symbol_device = {
@@ -296,7 +295,6 @@ static struct usb_serial_driver symbol_device = {
                .name =         "symbol",
        },
        .id_table =             id_table,
-       .usb_driver =           &symbol_driver,
        .num_ports =            1,
        .attach =               symbol_startup,
        .open =                 symbol_open,
@@ -307,23 +305,18 @@ static struct usb_serial_driver symbol_device = {
        .unthrottle =           symbol_unthrottle,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &symbol_device, NULL
+};
+
 static int __init symbol_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&symbol_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&symbol_driver);
-       if (retval)
-               usb_serial_deregister(&symbol_device);
-       return retval;
+       return usb_serial_register_drivers(&symbol_driver, serial_drivers);
 }
 
 static void __exit symbol_exit(void)
 {
-       usb_deregister(&symbol_driver);
-       usb_serial_deregister(&symbol_device);
+       usb_serial_deregister_drivers(&symbol_driver, serial_drivers);
 }
 
 module_init(symbol_init);