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

keyspan, kl5kusb105, kobil_sct, mct_u232, mos7720,
mos7840, and moto_modem.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/keyspan.c
drivers/usb/serial/keyspan.h
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/moto_modem.c

index 4cc36c76180126f80a9d81e23759318971873599..0d5d3025a6632c5660878421aa95791eafa399c7 100644 (file)
@@ -134,45 +134,17 @@ struct keyspan_port_private {
 static int __init keyspan_init(void)
 {
        int retval;
-       retval = usb_serial_register(&keyspan_pre_device);
-       if (retval)
-               goto failed_pre_device_register;
-       retval = usb_serial_register(&keyspan_1port_device);
-       if (retval)
-               goto failed_1port_device_register;
-       retval = usb_serial_register(&keyspan_2port_device);
-       if (retval)
-               goto failed_2port_device_register;
-       retval = usb_serial_register(&keyspan_4port_device);
-       if (retval)
-               goto failed_4port_device_register;
-       retval = usb_register(&keyspan_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(&keyspan_4port_device);
-failed_4port_device_register:
-       usb_serial_deregister(&keyspan_2port_device);
-failed_2port_device_register:
-       usb_serial_deregister(&keyspan_1port_device);
-failed_1port_device_register:
-       usb_serial_deregister(&keyspan_pre_device);
-failed_pre_device_register:
+       retval = usb_serial_register_drivers(&keyspan_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit keyspan_exit(void)
 {
-       usb_deregister(&keyspan_driver);
-       usb_serial_deregister(&keyspan_pre_device);
-       usb_serial_deregister(&keyspan_1port_device);
-       usb_serial_deregister(&keyspan_2port_device);
-       usb_serial_deregister(&keyspan_4port_device);
+       usb_serial_deregister_drivers(&keyspan_driver, serial_drivers);
 }
 
 module_init(keyspan_init);
index 13fa1d1cc9004b8a1bc80c3d41870d7a311f13d1..622853c9e384a3edf91624963ba729b7909a671b 100644 (file)
@@ -492,7 +492,6 @@ static struct usb_driver keyspan_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     keyspan_ids_combined,
-       .no_dynamic_id =        1,
 };
 
 /* usb_device_id table for the pre-firmware download keyspan devices */
@@ -545,7 +544,6 @@ static struct usb_serial_driver keyspan_pre_device = {
                .name           = "keyspan_no_firm",
        },
        .description            = "Keyspan - (without firmware)",
-       .usb_driver             = &keyspan_driver,
        .id_table               = keyspan_pre_ids,
        .num_ports              = 1,
        .attach                 = keyspan_fake_startup,
@@ -557,7 +555,6 @@ static struct usb_serial_driver keyspan_1port_device = {
                .name           = "keyspan_1",
        },
        .description            = "Keyspan 1 port adapter",
-       .usb_driver             = &keyspan_driver,
        .id_table               = keyspan_1port_ids,
        .num_ports              = 1,
        .open                   = keyspan_open,
@@ -580,7 +577,6 @@ static struct usb_serial_driver keyspan_2port_device = {
                .name           = "keyspan_2",
        },
        .description            = "Keyspan 2 port adapter",
-       .usb_driver             = &keyspan_driver,
        .id_table               = keyspan_2port_ids,
        .num_ports              = 2,
        .open                   = keyspan_open,
@@ -603,7 +599,6 @@ static struct usb_serial_driver keyspan_4port_device = {
                .name           = "keyspan_4",
        },
        .description            = "Keyspan 4 port adapter",
-       .usb_driver             = &keyspan_driver,
        .id_table               = keyspan_4port_ids,
        .num_ports              = 4,
        .open                   = keyspan_open,
@@ -620,4 +615,9 @@ static struct usb_serial_driver keyspan_4port_device = {
        .release                = keyspan_release,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &keyspan_pre_device, &keyspan_1port_device,
+       &keyspan_2port_device, &keyspan_4port_device, NULL
+};
+
 #endif
index fc064e1442ca988ae3330388cb4d855f023f1595..0e65e50edd50d68033a0083680291cd5ac1c6e1d 100644 (file)
@@ -91,7 +91,6 @@ static struct usb_driver kl5kusb105d_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver kl5kusb105d_device = {
@@ -100,7 +99,6 @@ static struct usb_serial_driver kl5kusb105d_device = {
                .name =         "kl5kusb105d",
        },
        .description =          "KL5KUSB105D / PalmConnect",
-       .usb_driver =           &kl5kusb105d_driver,
        .id_table =             id_table,
        .num_ports =            1,
        .bulk_out_size =        64,
@@ -118,6 +116,10 @@ static struct usb_serial_driver kl5kusb105d_device = {
        .prepare_write_buffer = klsi_105_prepare_write_buffer,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &kl5kusb105d_device, NULL
+};
+
 struct klsi_105_port_settings {
        __u8    pktlen;         /* always 5, it seems */
        __u8    baudrate;
@@ -694,26 +696,18 @@ static int klsi_105_tiocmset(struct tty_struct *tty,
 static int __init klsi_105_init(void)
 {
        int retval;
-       retval = usb_serial_register(&kl5kusb105d_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&kl5kusb105d_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(&kl5kusb105d_device);
-failed_usb_serial_register:
+
+       retval = usb_serial_register_drivers(&kl5kusb105d_driver,
+                       serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit klsi_105_exit(void)
 {
-       usb_deregister(&kl5kusb105d_driver);
-       usb_serial_deregister(&kl5kusb105d_device);
+       usb_serial_deregister_drivers(&kl5kusb105d_driver, serial_drivers);
 }
 
 
index a92a3efb507bdaa45f7134919b30c4bf8b495917..a033dd7dc2653bdbf01aaf39b2f4138245d8f7e3 100644 (file)
@@ -90,7 +90,6 @@ static struct usb_driver kobil_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 
@@ -100,7 +99,6 @@ static struct usb_serial_driver kobil_device = {
                .name =         "kobil",
        },
        .description =          "KOBIL USB smart card terminal",
-       .usb_driver =           &kobil_driver,
        .id_table =             id_table,
        .num_ports =            1,
        .attach =               kobil_startup,
@@ -117,6 +115,9 @@ static struct usb_serial_driver kobil_device = {
        .read_int_callback =    kobil_read_int_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &kobil_device, NULL
+};
 
 struct kobil_private {
        int write_int_endpoint_address;
@@ -685,28 +686,18 @@ static int kobil_ioctl(struct tty_struct *tty,
 static int __init kobil_init(void)
 {
        int retval;
-       retval = usb_serial_register(&kobil_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&kobil_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(&kobil_device);
-failed_usb_serial_register:
+       retval = usb_serial_register_drivers(&kobil_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 
 static void __exit kobil_exit(void)
 {
-       usb_deregister(&kobil_driver);
-       usb_serial_deregister(&kobil_device);
+       usb_serial_deregister_drivers(&kobil_driver, serial_drivers);
 }
 
 module_init(kobil_init);
index 27fa9c8a77b0745b7ccae628778d1b44ba9f41a7..6d9a7f8b13db0b23c828d1b10e0766e1b4be5492 100644 (file)
@@ -88,7 +88,6 @@ static struct usb_driver mct_u232_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver mct_u232_device = {
@@ -97,7 +96,6 @@ static struct usb_serial_driver mct_u232_device = {
                .name =         "mct_u232",
        },
        .description =       "MCT U232",
-       .usb_driver =        &mct_u232_driver,
        .id_table =          id_table_combined,
        .num_ports =         1,
        .open =              mct_u232_open,
@@ -116,6 +114,10 @@ static struct usb_serial_driver mct_u232_device = {
        .get_icount =        mct_u232_get_icount,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &mct_u232_device, NULL
+};
+
 struct mct_u232_private {
        spinlock_t lock;
        unsigned int         control_state; /* Modem Line Setting (TIOCM) */
@@ -907,26 +909,18 @@ static int  mct_u232_get_icount(struct tty_struct *tty,
 static int __init mct_u232_init(void)
 {
        int retval;
-       retval = usb_serial_register(&mct_u232_device);
-       if (retval)
-               goto failed_usb_serial_register;
-       retval = usb_register(&mct_u232_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(&mct_u232_device);
-failed_usb_serial_register:
+
+       retval = usb_serial_register_drivers(&mct_u232_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 
 static void __exit mct_u232_exit(void)
 {
-       usb_deregister(&mct_u232_driver);
-       usb_serial_deregister(&mct_u232_device);
+       usb_serial_deregister_drivers(&mct_u232_driver, serial_drivers);
 }
 
 module_init(mct_u232_init);
index 4fb29b4aaad6f7a5d9d20ef68759f917def20433..4dfbad80418c84dcd4520880ba79fb4c3cf5c024 100644 (file)
@@ -2169,7 +2169,6 @@ static struct usb_driver usb_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     moschip_port_id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver moschip7720_2port_driver = {
@@ -2178,7 +2177,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
                .name =         "moschip7720",
        },
        .description            = "Moschip 2 port adapter",
-       .usb_driver             = &usb_driver,
        .id_table               = moschip_port_id_table,
        .calc_num_ports         = mos77xx_calc_num_ports,
        .open                   = mos7720_open,
@@ -2201,38 +2199,26 @@ static struct usb_serial_driver moschip7720_2port_driver = {
        .read_int_callback      = NULL  /* dynamically assigned in probe() */
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &moschip7720_2port_driver, NULL
+};
+
 static int __init moschip7720_init(void)
 {
        int retval;
 
        dbg("%s: Entering ..........", __func__);
 
-       /* Register with the usb serial */
-       retval = usb_serial_register(&moschip7720_2port_driver);
-       if (retval)
-               goto failed_port_device_register;
-
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-              DRIVER_DESC "\n");
-
-       /* Register with the usb */
-       retval = usb_register(&usb_driver);
-       if (retval)
-               goto failed_usb_register;
-
-       return 0;
-
-failed_usb_register:
-       usb_serial_deregister(&moschip7720_2port_driver);
-
-failed_port_device_register:
+       retval = usb_serial_register_drivers(&usb_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
        return retval;
 }
 
 static void __exit moschip7720_exit(void)
 {
-       usb_deregister(&usb_driver);
-       usb_serial_deregister(&moschip7720_2port_driver);
+       usb_serial_deregister_drivers(&usb_driver, serial_drivers);
 }
 
 module_init(moschip7720_init);
index 19b11cece6baa4fced1743db76987607385f5fff..b45522e12f6801832440dafb742474ad2dc75b97 100644 (file)
@@ -2638,7 +2638,6 @@ static struct usb_driver io_driver = {
        .probe = usb_serial_probe,
        .disconnect = usb_serial_disconnect,
        .id_table = moschip_id_table_combined,
-       .no_dynamic_id = 1,
 };
 
 static struct usb_serial_driver moschip7840_4port_device = {
@@ -2647,7 +2646,6 @@ static struct usb_serial_driver moschip7840_4port_device = {
                   .name = "mos7840",
                   },
        .description = DRIVER_DESC,
-       .usb_driver = &io_driver,
        .id_table = moschip_port_id_table,
        .num_ports = 4,
        .open = mos7840_open,
@@ -2674,6 +2672,10 @@ static struct usb_serial_driver moschip7840_4port_device = {
        .read_int_callback = mos7840_interrupt_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &moschip7840_4port_device, NULL
+};
+
 /****************************************************************************
  * moschip7840_init
  *     This is called by the module subsystem, or on startup to initialize us
@@ -2684,24 +2686,12 @@ static int __init moschip7840_init(void)
 
        dbg("%s", " mos7840_init :entering..........");
 
-       /* Register with the usb serial */
-       retval = usb_serial_register(&moschip7840_4port_device);
-
-       if (retval)
-               goto failed_port_device_register;
-
-       dbg("%s", "Entering...");
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-              DRIVER_DESC "\n");
+       retval = usb_serial_register_drivers(&io_driver, serial_drivers);
+       if (retval == 0)
+               printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                              DRIVER_DESC "\n");
 
-       /* Register with the usb */
-       retval = usb_register(&io_driver);
-       if (retval == 0) {
-               dbg("%s", "Leaving...");
-               return 0;
-       }
-       usb_serial_deregister(&moschip7840_4port_device);
-failed_port_device_register:
+       dbg("%s", "Leaving...");
        return retval;
 }
 
@@ -2714,9 +2704,7 @@ static void __exit moschip7840_exit(void)
 
        dbg("%s", " mos7840_exit :entering..........");
 
-       usb_deregister(&io_driver);
-
-       usb_serial_deregister(&moschip7840_4port_device);
+       usb_serial_deregister_drivers(&io_driver, serial_drivers);
 
        dbg("%s", "Entering...");
 }
index e2bfecc46402468096a93b83e4b60139e58a5638..0af57d31ab82e68d3d1bd67882aba343c08114e8 100644 (file)
@@ -36,7 +36,6 @@ static struct usb_driver moto_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
-       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver moto_device = {
@@ -45,27 +44,21 @@ static struct usb_serial_driver moto_device = {
                .name =         "moto-modem",
        },
        .id_table =             id_table,
-       .usb_driver =           &moto_driver,
        .num_ports =            1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+       &moto_device, NULL
+};
+
 static int __init moto_init(void)
 {
-       int retval;
-
-       retval = usb_serial_register(&moto_device);
-       if (retval)
-               return retval;
-       retval = usb_register(&moto_driver);
-       if (retval)
-               usb_serial_deregister(&moto_device);
-       return retval;
+       return usb_serial_register_drivers(&moto_driver, serial_drivers);
 }
 
 static void __exit moto_exit(void)
 {
-       usb_deregister(&moto_driver);
-       usb_serial_deregister(&moto_device);
+       usb_serial_deregister_drivers(&moto_driver, serial_drivers);
 }
 
 module_init(moto_init);