From 7dbe2460989b10644651e779b17b683627feea48 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 23 Feb 2012 14:56:57 -0500 Subject: [PATCH] usb-serial: use new registration API in [i-j]* drivers This patch (as1525) modifies the following usb-serial drivers to utilize the new usb_serial_{de}register_drivers() routines: io_edgeport, io_ti, ipaq, ipw, ir-usb, and iuu_phoenix. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/io_edgeport.c | 41 ++++++-------------------------- drivers/usb/serial/io_tables.h | 10 ++++---- drivers/usb/serial/io_ti.c | 33 ++++++++----------------- drivers/usb/serial/ipaq.c | 28 +++++++++------------- drivers/usb/serial/ipw.c | 24 +++++++------------ drivers/usb/serial/ir-usb.c | 30 +++++++---------------- drivers/usb/serial/iuu_phoenix.c | 26 ++++++++------------ 7 files changed, 61 insertions(+), 131 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 616b07862771..55afa233aacd 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -3189,35 +3189,12 @@ static int __init edgeport_init(void) { int retval; - retval = usb_serial_register(&edgeport_2port_device); - if (retval) - goto failed_2port_device_register; - retval = usb_serial_register(&edgeport_4port_device); - if (retval) - goto failed_4port_device_register; - retval = usb_serial_register(&edgeport_8port_device); - if (retval) - goto failed_8port_device_register; - retval = usb_serial_register(&epic_device); - if (retval) - goto failed_epic_device_register; - retval = usb_register(&io_driver); - if (retval) - goto failed_usb_register; - atomic_set(&CmdUrbs, 0); - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return 0; - -failed_usb_register: - usb_serial_deregister(&epic_device); -failed_epic_device_register: - usb_serial_deregister(&edgeport_8port_device); -failed_8port_device_register: - usb_serial_deregister(&edgeport_4port_device); -failed_4port_device_register: - usb_serial_deregister(&edgeport_2port_device); -failed_2port_device_register: + retval = usb_serial_register_drivers(&io_driver, serial_drivers); + if (retval == 0) { + atomic_set(&CmdUrbs, 0); + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); + } return retval; } @@ -3228,11 +3205,7 @@ static int __init edgeport_init(void) ****************************************************************************/ static void __exit edgeport_exit (void) { - usb_deregister(&io_driver); - usb_serial_deregister(&edgeport_2port_device); - usb_serial_deregister(&edgeport_4port_device); - usb_serial_deregister(&edgeport_8port_device); - usb_serial_deregister(&epic_device); + usb_serial_deregister_drivers(&io_driver, serial_drivers); } module_init(edgeport_init); diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 178b22eb32b1..d0e7c9affb6f 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h @@ -100,7 +100,6 @@ static struct usb_driver io_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, - .no_dynamic_id = 1, }; static struct usb_serial_driver edgeport_2port_device = { @@ -109,7 +108,6 @@ static struct usb_serial_driver edgeport_2port_device = { .name = "edgeport_2", }, .description = "Edgeport 2 port adapter", - .usb_driver = &io_driver, .id_table = edgeport_2port_id_table, .num_ports = 2, .open = edge_open, @@ -139,7 +137,6 @@ static struct usb_serial_driver edgeport_4port_device = { .name = "edgeport_4", }, .description = "Edgeport 4 port adapter", - .usb_driver = &io_driver, .id_table = edgeport_4port_id_table, .num_ports = 4, .open = edge_open, @@ -169,7 +166,6 @@ static struct usb_serial_driver edgeport_8port_device = { .name = "edgeport_8", }, .description = "Edgeport 8 port adapter", - .usb_driver = &io_driver, .id_table = edgeport_8port_id_table, .num_ports = 8, .open = edge_open, @@ -199,7 +195,6 @@ static struct usb_serial_driver epic_device = { .name = "epic", }, .description = "EPiC device", - .usb_driver = &io_driver, .id_table = Epic_port_id_table, .num_ports = 1, .open = edge_open, @@ -223,5 +218,10 @@ static struct usb_serial_driver epic_device = { .write_bulk_callback = edge_bulk_out_data_callback, }; +static struct usb_serial_driver * const serial_drivers[] = { + &edgeport_2port_device, &edgeport_4port_device, + &edgeport_8port_device, &epic_device, NULL +}; + #endif diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 58a3697246a8..484db3331f88 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -202,7 +202,6 @@ static struct usb_driver io_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, - .no_dynamic_id = 1, }; @@ -2725,7 +2724,6 @@ static struct usb_serial_driver edgeport_1port_device = { .name = "edgeport_ti_1", }, .description = "Edgeport TI 1 port adapter", - .usb_driver = &io_driver, .id_table = edgeport_1port_id_table, .num_ports = 1, .open = edge_open, @@ -2757,7 +2755,6 @@ static struct usb_serial_driver edgeport_2port_device = { .name = "edgeport_ti_2", }, .description = "Edgeport TI 2 port adapter", - .usb_driver = &io_driver, .id_table = edgeport_2port_id_table, .num_ports = 2, .open = edge_open, @@ -2782,35 +2779,25 @@ static struct usb_serial_driver edgeport_2port_device = { .write_bulk_callback = edge_bulk_out_callback, }; +static struct usb_serial_driver * const serial_drivers[] = { + &edgeport_1port_device, &edgeport_2port_device, NULL +}; + static int __init edgeport_init(void) { int retval; - retval = usb_serial_register(&edgeport_1port_device); - if (retval) - goto failed_1port_device_register; - retval = usb_serial_register(&edgeport_2port_device); - if (retval) - goto failed_2port_device_register; - retval = usb_register(&io_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(&edgeport_2port_device); -failed_2port_device_register: - usb_serial_deregister(&edgeport_1port_device); -failed_1port_device_register: + + retval = usb_serial_register_drivers(&io_driver, serial_drivers); + if (retval == 0) + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); return retval; } static void __exit edgeport_exit(void) { - usb_deregister(&io_driver); - usb_serial_deregister(&edgeport_1port_device); - usb_serial_deregister(&edgeport_2port_device); + usb_serial_deregister_drivers(&io_driver, serial_drivers); } module_init(edgeport_init); diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 06053a920dd8..10c02b8b5664 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -510,7 +510,6 @@ static struct usb_driver ipaq_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = ipaq_id_table, - .no_dynamic_id = 1, }; @@ -521,7 +520,6 @@ static struct usb_serial_driver ipaq_device = { .name = "ipaq", }, .description = "PocketPC PDA", - .usb_driver = &ipaq_driver, .id_table = ipaq_id_table, .bulk_in_size = 256, .bulk_out_size = 256, @@ -530,6 +528,10 @@ static struct usb_serial_driver ipaq_device = { .calc_num_ports = ipaq_calc_num_ports, }; +static struct usb_serial_driver * const serial_drivers[] = { + &ipaq_device, NULL +}; + static int ipaq_open(struct tty_struct *tty, struct usb_serial_port *port) { @@ -624,30 +626,22 @@ static int ipaq_startup(struct usb_serial *serial) static int __init ipaq_init(void) { int retval; - retval = usb_serial_register(&ipaq_device); - if (retval) - goto failed_usb_serial_register; + if (vendor) { ipaq_id_table[0].idVendor = vendor; ipaq_id_table[0].idProduct = product; } - retval = usb_register(&ipaq_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(&ipaq_device); -failed_usb_serial_register: + + retval = usb_serial_register_drivers(&ipaq_driver, serial_drivers); + if (retval == 0) + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); return retval; } static void __exit ipaq_exit(void) { - usb_deregister(&ipaq_driver); - usb_serial_deregister(&ipaq_device); + usb_serial_deregister_drivers(&ipaq_driver, serial_drivers); } diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 6f9356f3f99e..27b8886f1055 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -144,7 +144,6 @@ static struct usb_driver usb_ipw_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = usb_ipw_ids, - .no_dynamic_id = 1, }; static bool debug; @@ -318,7 +317,6 @@ static struct usb_serial_driver ipw_device = { .name = "ipw", }, .description = "IPWireless converter", - .usb_driver = &usb_ipw_driver, .id_table = usb_ipw_ids, .num_ports = 1, .disconnect = usb_wwan_disconnect, @@ -331,29 +329,25 @@ static struct usb_serial_driver ipw_device = { .write = usb_wwan_write, }; +static struct usb_serial_driver * const serial_drivers[] = { + &ipw_device, NULL +}; static int __init usb_ipw_init(void) { int retval; - retval = usb_serial_register(&ipw_device); - if (retval) - return retval; - retval = usb_register(&usb_ipw_driver); - if (retval) { - usb_serial_deregister(&ipw_device); - return retval; - } - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return 0; + retval = usb_serial_register_drivers(&usb_ipw_driver, serial_drivers); + if (retval == 0) + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); + return retval; } static void __exit usb_ipw_exit(void) { - usb_deregister(&usb_ipw_driver); - usb_serial_deregister(&ipw_device); + usb_serial_deregister_drivers(&usb_ipw_driver, serial_drivers); } module_init(usb_ipw_init); diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 84a396e83671..84965cd65c76 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -82,7 +82,6 @@ static struct usb_driver ir_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = ir_id_table, - .no_dynamic_id = 1, }; static struct usb_serial_driver ir_device = { @@ -91,7 +90,6 @@ static struct usb_serial_driver ir_device = { .name = "ir-usb", }, .description = "IR Dongle", - .usb_driver = &ir_driver, .id_table = ir_id_table, .num_ports = 1, .set_termios = ir_set_termios, @@ -101,6 +99,10 @@ static struct usb_serial_driver ir_device = { .process_read_urb = ir_process_read_urb, }; +static struct usb_serial_driver * const serial_drivers[] = { + &ir_device, NULL +}; + static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) { dbg("bLength=%x", desc->bLength); @@ -445,30 +447,16 @@ static int __init ir_init(void) ir_device.bulk_out_size = buffer_size; } - retval = usb_serial_register(&ir_device); - if (retval) - goto failed_usb_serial_register; - - retval = usb_register(&ir_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(&ir_device); - -failed_usb_serial_register: + retval = usb_serial_register_drivers(&ir_driver, serial_drivers); + if (retval == 0) + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); return retval; } static void __exit ir_exit(void) { - usb_deregister(&ir_driver); - usb_serial_deregister(&ir_device); + usb_serial_deregister_drivers(&ir_driver, serial_drivers); } diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 3077a4436976..97a7ea2a5e4f 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -56,7 +56,6 @@ static struct usb_driver iuu_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, - .no_dynamic_id = 1, }; /* turbo parameter */ @@ -1274,7 +1273,6 @@ static struct usb_serial_driver iuu_device = { .name = "iuu_phoenix", }, .id_table = id_table, - .usb_driver = &iuu_driver, .num_ports = 1, .bulk_in_size = 512, .bulk_out_size = 512, @@ -1292,28 +1290,24 @@ static struct usb_serial_driver iuu_device = { .release = iuu_release, }; +static struct usb_serial_driver * const serial_drivers[] = { + &iuu_device, NULL +}; + static int __init iuu_init(void) { int retval; - retval = usb_serial_register(&iuu_device); - if (retval) - goto failed_usb_serial_register; - retval = usb_register(&iuu_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(&iuu_device); -failed_usb_serial_register: + + retval = usb_serial_register_drivers(&iuu_driver, serial_drivers); + if (retval == 0) + printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" + DRIVER_DESC "\n"); return retval; } static void __exit iuu_exit(void) { - usb_deregister(&iuu_driver); - usb_serial_deregister(&iuu_device); + usb_serial_deregister_drivers(&iuu_driver, serial_drivers); } module_init(iuu_init); -- GitLab