[PATCH 3/9] usb-serial: use new registration API in [d-h]* drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch (as1524) modifies the following usb-serial drivers to
utilize the new usb_serial_{de}register_drivers() routines:

	digi_acceleport, empeg, ftdi_sio, funsoft, garmin_gps,
	and hp4x.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

---

 drivers/usb/serial/digi_acceleport.c |   32 +++++++++-----------------------
 drivers/usb/serial/empeg.c           |   26 ++++++++++----------------
 drivers/usb/serial/ftdi_sio.c        |   26 +++++++++-----------------
 drivers/usb/serial/funsoft.c         |   19 ++++++-------------
 drivers/usb/serial/garmin_gps.c      |   25 ++++++++-----------------
 drivers/usb/serial/hp4x.c            |   26 ++++++++++----------------
 6 files changed, 52 insertions(+), 102 deletions(-)

Index: usb-3.3/drivers/usb/serial/digi_acceleport.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/digi_acceleport.c
+++ usb-3.3/drivers/usb/serial/digi_acceleport.c
@@ -276,7 +276,6 @@ static struct usb_driver digi_driver = {
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table_combined,
-	.no_dynamic_id = 	1,
 };
 
 
@@ -288,7 +287,6 @@ static struct usb_serial_driver digi_acc
 		.name =			"digi_2",
 	},
 	.description =			"Digi 2 port USB adapter",
-	.usb_driver = 			&digi_driver,
 	.id_table =			id_table_2,
 	.num_ports =			3,
 	.open =				digi_open,
@@ -316,7 +314,6 @@ static struct usb_serial_driver digi_acc
 		.name =			"digi_4",
 	},
 	.description =			"Digi 4 port USB adapter",
-	.usb_driver = 			&digi_driver,
 	.id_table =			id_table_4,
 	.num_ports =			4,
 	.open =				digi_open,
@@ -337,6 +334,9 @@ static struct usb_serial_driver digi_acc
 	.release =			digi_release,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&digi_acceleport_2_device, &digi_acceleport_4_device, NULL
+};
 
 /* Functions */
 
@@ -1583,31 +1583,17 @@ static int digi_read_oob_callback(struct
 static int __init digi_init(void)
 {
 	int retval;
-	retval = usb_serial_register(&digi_acceleport_2_device);
-	if (retval)
-		goto failed_acceleport_2_device;
-	retval = usb_serial_register(&digi_acceleport_4_device);
-	if (retval)
-		goto failed_acceleport_4_device;
-	retval = usb_register(&digi_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(&digi_acceleport_4_device);
-failed_acceleport_4_device:
-	usb_serial_deregister(&digi_acceleport_2_device);
-failed_acceleport_2_device:
+
+	retval = usb_serial_register_drivers(&digi_driver, serial_drivers);
+	if (retval == 0)
+		printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+			       DRIVER_DESC "\n");
 	return retval;
 }
 
 static void __exit digi_exit (void)
 {
-	usb_deregister(&digi_driver);
-	usb_serial_deregister(&digi_acceleport_2_device);
-	usb_serial_deregister(&digi_acceleport_4_device);
+	usb_serial_deregister_drivers(&digi_driver, serial_drivers);
 }
 
 
Index: usb-3.3/drivers/usb/serial/empeg.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/empeg.c
+++ usb-3.3/drivers/usb/serial/empeg.c
@@ -56,7 +56,6 @@ static struct usb_driver empeg_driver =
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table,
-	.no_dynamic_id =	1,
 };
 
 static struct usb_serial_driver empeg_device = {
@@ -65,7 +64,6 @@ static struct usb_serial_driver empeg_de
 		.name =		"empeg",
 	},
 	.id_table =		id_table,
-	.usb_driver =		&empeg_driver,
 	.num_ports =		1,
 	.bulk_out_size =	256,
 	.throttle =		usb_serial_generic_throttle,
@@ -74,6 +72,10 @@ static struct usb_serial_driver empeg_de
 	.init_termios =		empeg_init_termios,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&empeg_device, NULL
+};
+
 static int empeg_startup(struct usb_serial *serial)
 {
 	int r;
@@ -140,24 +142,16 @@ static int __init empeg_init(void)
 {
 	int retval;
 
-	retval = usb_serial_register(&empeg_device);
-	if (retval)
-		return retval;
-	retval = usb_register(&empeg_driver);
-	if (retval) {
-		usb_serial_deregister(&empeg_device);
-		return retval;
-	}
-	printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
-	       DRIVER_DESC "\n");
-
-	return 0;
+	retval = usb_serial_register_drivers(&empeg_driver, serial_drivers);
+	if (retval == 0)
+		printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+			       DRIVER_DESC "\n");
+	return retval;
 }
 
 static void __exit empeg_exit(void)
 {
-	usb_deregister(&empeg_driver);
-	usb_serial_deregister(&empeg_device);
+	usb_serial_deregister_drivers(&empeg_driver, serial_drivers);
 }
 
 
Index: usb-3.3/drivers/usb/serial/ftdi_sio.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/ftdi_sio.c
+++ usb-3.3/drivers/usb/serial/ftdi_sio.c
@@ -857,7 +857,6 @@ static struct usb_driver ftdi_driver = {
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table_combined,
-	.no_dynamic_id =	1,
 };
 
 static const char *ftdi_chip_name[] = {
@@ -915,7 +914,6 @@ static struct usb_serial_driver ftdi_sio
 		.name =		"ftdi_sio",
 	},
 	.description =		"FTDI USB Serial Device",
-	.usb_driver = 		&ftdi_driver,
 	.id_table =		id_table_combined,
 	.num_ports =		1,
 	.bulk_in_size =		512,
@@ -938,6 +936,10 @@ static struct usb_serial_driver ftdi_sio
 	.break_ctl =		ftdi_break_ctl,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&ftdi_sio_device, NULL
+};
+
 
 #define WDR_TIMEOUT 5000 /* default urb timeout */
 #define WDR_SHORT_TIMEOUT 1000	/* shorter urb timeout */
@@ -2420,19 +2422,10 @@ static int __init ftdi_init(void)
 		id_table_combined[i].idVendor = vendor;
 		id_table_combined[i].idProduct = product;
 	}
-	retval = usb_serial_register(&ftdi_sio_device);
-	if (retval)
-		goto failed_sio_register;
-	retval = usb_register(&ftdi_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(&ftdi_sio_device);
-failed_sio_register:
+	retval = usb_serial_register_drivers(&ftdi_driver, serial_drivers);
+	if (retval == 0)
+		printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+			       DRIVER_DESC "\n");
 	return retval;
 }
 
@@ -2440,8 +2433,7 @@ static void __exit ftdi_exit(void)
 {
 	dbg("%s", __func__);
 
-	usb_deregister(&ftdi_driver);
-	usb_serial_deregister(&ftdi_sio_device);
+	usb_serial_deregister_drivers(&ftdi_driver, serial_drivers);
 }
 
 
Index: usb-3.3/drivers/usb/serial/funsoft.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/funsoft.c
+++ usb-3.3/drivers/usb/serial/funsoft.c
@@ -29,7 +29,6 @@ static struct usb_driver funsoft_driver
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table,
-	.no_dynamic_id = 	1,
 };
 
 static struct usb_serial_driver funsoft_device = {
@@ -38,27 +37,21 @@ static struct usb_serial_driver funsoft_
 		.name =		"funsoft",
 	},
 	.id_table =		id_table,
-	.usb_driver = 		&funsoft_driver,
 	.num_ports =		1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&funsoft_device, NULL
+};
+
 static int __init funsoft_init(void)
 {
-	int retval;
-
-	retval = usb_serial_register(&funsoft_device);
-	if (retval)
-		return retval;
-	retval = usb_register(&funsoft_driver);
-	if (retval)
-		usb_serial_deregister(&funsoft_device);
-	return retval;
+	return usb_serial_register_drivers(&funsoft_driver, serial_drivers);
 }
 
 static void __exit funsoft_exit(void)
 {
-	usb_deregister(&funsoft_driver);
-	usb_serial_deregister(&funsoft_device);
+	usb_serial_deregister_drivers(&funsoft_driver, serial_drivers);
 }
 
 module_init(funsoft_init);
Index: usb-3.3/drivers/usb/serial/garmin_gps.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/garmin_gps.c
+++ usb-3.3/drivers/usb/serial/garmin_gps.c
@@ -224,7 +224,6 @@ static struct usb_driver garmin_driver =
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table,
-	.no_dynamic_id = 1,
 };
 
 
@@ -1497,7 +1496,6 @@ static struct usb_serial_driver garmin_d
 		.name        = "garmin_gps",
 	},
 	.description         = "Garmin GPS usb/tty",
-	.usb_driver          = &garmin_driver,
 	.id_table            = id_table,
 	.num_ports           = 1,
 	.open                = garmin_open,
@@ -1514,33 +1512,26 @@ static struct usb_serial_driver garmin_d
 	.read_int_callback   = garmin_read_int_callback,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&garmin_device, NULL
+};
 
 
 static int __init garmin_init(void)
 {
 	int retval;
 
-	retval = usb_serial_register(&garmin_device);
-	if (retval)
-		goto failed_garmin_register;
-	retval = usb_register(&garmin_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(&garmin_device);
-failed_garmin_register:
+	retval = usb_serial_register_drivers(&garmin_driver, serial_drivers);
+	if (retval == 0)
+		printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+			       DRIVER_DESC "\n");
 	return retval;
 }
 
 
 static void __exit garmin_exit(void)
 {
-	usb_deregister(&garmin_driver);
-	usb_serial_deregister(&garmin_device);
+	usb_serial_deregister_drivers(&garmin_driver, serial_drivers);
 }
 
 
Index: usb-3.3/drivers/usb/serial/hp4x.c
===================================================================
--- usb-3.3.orig/drivers/usb/serial/hp4x.c
+++ usb-3.3/drivers/usb/serial/hp4x.c
@@ -41,7 +41,6 @@ static struct usb_driver hp49gp_driver =
 	.probe =	usb_serial_probe,
 	.disconnect =	usb_serial_disconnect,
 	.id_table =	id_table,
-	.no_dynamic_id = 	1,
 };
 
 static struct usb_serial_driver hp49gp_device = {
@@ -50,32 +49,27 @@ static struct usb_serial_driver hp49gp_d
 		.name =		"hp4X",
 	},
 	.id_table =		id_table,
-	.usb_driver = 		&hp49gp_driver,
 	.num_ports =		1,
 };
 
+static struct usb_serial_driver * const serial_drivers[] = {
+	&hp49gp_device, NULL
+};
+
 static int __init hp49gp_init(void)
 {
 	int retval;
-	retval = usb_serial_register(&hp49gp_device);
-	if (retval)
-		goto failed_usb_serial_register;
-	retval = usb_register(&hp49gp_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(&hp49gp_device);
-failed_usb_serial_register:
+
+	retval = usb_serial_register_drivers(&hp49gp_driver, serial_drivers);
+	if (retval == 0)
+		printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+			       DRIVER_DESC "\n");
 	return retval;
 }
 
 static void __exit hp49gp_exit(void)
 {
-	usb_deregister(&hp49gp_driver);
-	usb_serial_deregister(&hp49gp_device);
+	usb_serial_deregister_drivers(&hp49gp_driver, serial_drivers);
 }
 
 module_init(hp49gp_init);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux