aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 14:26:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 14:26:30 -0400
commited378a52dabf77b406b447fd3238f83ea24b71fa (patch)
tree07e1a7ec2d1c08767ee81b9910f5912b80502632 /drivers/usb/serial/usb-serial.c
parent843ec558f91b8e8fdb6efc908f2c0506407cc750 (diff)
parent11207b6fe05438b2e87a26435cd98db3d55e6fa7 (diff)
Merge tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB merge for 3.4-rc1 from Greg KH: "Here's the big USB merge for the 3.4-rc1 merge window. Lots of gadget driver reworks here, driver updates, xhci changes, some new drivers added, usb-serial core reworking to fix some bugs, and other various minor things. There are some patches touching arch code, but they have all been acked by the various arch maintainers." * tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (302 commits) net: qmi_wwan: add support for ZTE MF820D USB: option: add ZTE MF820D usb: gadget: f_fs: Remove lock is held before freeing checks USB: option: make interface blacklist work again usb/ub: deprecate & schedule for removal the "Low Performance USB Block" driver USB: ohci-pxa27x: add clk_prepare/clk_unprepare calls USB: use generic platform driver on ath79 USB: EHCI: Add a generic platform device driver USB: OHCI: Add a generic platform device driver USB: ftdi_sio: new PID: LUMEL PD12 USB: ftdi_sio: add support for FT-X series devices USB: serial: mos7840: Fixed MCS7820 device attach problem usb: Don't make USB_ARCH_HAS_{XHCI,OHCI,EHCI} depend on USB_SUPPORT. usb gadget: fix a section mismatch when compiling g_ffs with CONFIG_USB_FUNCTIONFS_ETH USB: ohci-nxp: Remove i2c_write(), use smbus USB: ohci-nxp: Support for LPC32xx USB: ohci-nxp: Rename symbols from pnx4008 to nxp USB: OHCI-HCD: Rename ohci-pnx4008 to ohci-nxp usb: gadget: Kconfig: fix typo for 'different' usb: dwc3: pci: fix another failure path in dwc3_pci_probe() ...
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c77
1 files changed, 72 insertions, 5 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index d4e724d9b1f4..69230f01056a 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1333,7 +1333,7 @@ static void fixup_generic(struct usb_serial_driver *device)
1333 set_to_generic_if_null(device, prepare_write_buffer); 1333 set_to_generic_if_null(device, prepare_write_buffer);
1334} 1334}
1335 1335
1336int usb_serial_register(struct usb_serial_driver *driver) 1336static int usb_serial_register(struct usb_serial_driver *driver)
1337{ 1337{
1338 int retval; 1338 int retval;
1339 1339
@@ -1367,10 +1367,8 @@ int usb_serial_register(struct usb_serial_driver *driver)
1367 mutex_unlock(&table_lock); 1367 mutex_unlock(&table_lock);
1368 return retval; 1368 return retval;
1369} 1369}
1370EXPORT_SYMBOL_GPL(usb_serial_register);
1371 1370
1372 1371static void usb_serial_deregister(struct usb_serial_driver *device)
1373void usb_serial_deregister(struct usb_serial_driver *device)
1374{ 1372{
1375 printk(KERN_INFO "USB Serial deregistering driver %s\n", 1373 printk(KERN_INFO "USB Serial deregistering driver %s\n",
1376 device->description); 1374 device->description);
@@ -1379,7 +1377,76 @@ void usb_serial_deregister(struct usb_serial_driver *device)
1379 usb_serial_bus_deregister(device); 1377 usb_serial_bus_deregister(device);
1380 mutex_unlock(&table_lock); 1378 mutex_unlock(&table_lock);
1381} 1379}
1382EXPORT_SYMBOL_GPL(usb_serial_deregister); 1380
1381/**
1382 * usb_serial_register_drivers - register drivers for a usb-serial module
1383 * @udriver: usb_driver used for matching devices/interfaces
1384 * @serial_drivers: NULL-terminated array of pointers to drivers to be registered
1385 *
1386 * Registers @udriver and all the drivers in the @serial_drivers array.
1387 * Automatically fills in the .no_dynamic_id field in @udriver and
1388 * the .usb_driver field in each serial driver.
1389 */
1390int usb_serial_register_drivers(struct usb_driver *udriver,
1391 struct usb_serial_driver * const serial_drivers[])
1392{
1393 int rc;
1394 const struct usb_device_id *saved_id_table;
1395 struct usb_serial_driver * const *sd;
1396
1397 /*
1398 * udriver must be registered before any of the serial drivers,
1399 * because the store_new_id() routine for the serial drivers (in
1400 * bus.c) probes udriver.
1401 *
1402 * Performance hack: We don't want udriver to be probed until
1403 * the serial drivers are registered, because the probe would
1404 * simply fail for lack of a matching serial driver.
1405 * Therefore save off udriver's id_table until we are all set.
1406 */
1407 saved_id_table = udriver->id_table;
1408 udriver->id_table = NULL;
1409
1410 udriver->no_dynamic_id = 1;
1411 rc = usb_register(udriver);
1412 if (rc)
1413 return rc;
1414
1415 for (sd = serial_drivers; *sd; ++sd) {
1416 (*sd)->usb_driver = udriver;
1417 rc = usb_serial_register(*sd);
1418 if (rc)
1419 goto failed;
1420 }
1421
1422 /* Now restore udriver's id_table and look for matches */
1423 udriver->id_table = saved_id_table;
1424 rc = driver_attach(&udriver->drvwrap.driver);
1425 return 0;
1426
1427 failed:
1428 while (sd-- > serial_drivers)
1429 usb_serial_deregister(*sd);
1430 usb_deregister(udriver);
1431 return rc;
1432}
1433EXPORT_SYMBOL_GPL(usb_serial_register_drivers);
1434
1435/**
1436 * usb_serial_deregister_drivers - deregister drivers for a usb-serial module
1437 * @udriver: usb_driver to unregister
1438 * @serial_drivers: NULL-terminated array of pointers to drivers to be deregistered
1439 *
1440 * Deregisters @udriver and all the drivers in the @serial_drivers array.
1441 */
1442void usb_serial_deregister_drivers(struct usb_driver *udriver,
1443 struct usb_serial_driver * const serial_drivers[])
1444{
1445 for (; *serial_drivers; ++serial_drivers)
1446 usb_serial_deregister(*serial_drivers);
1447 usb_deregister(udriver);
1448}
1449EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers);
1383 1450
1384/* Module information */ 1451/* Module information */
1385MODULE_AUTHOR(DRIVER_AUTHOR); 1452MODULE_AUTHOR(DRIVER_AUTHOR);