driver.c (cb54b53adae70701bdd77d848cea4b9b39b61cf9) | driver.c (626f090c5cbbe557379978c7a9525011ad7fbbf6) |
---|---|
1/* 2 * drivers/usb/driver.c - most of the driver model stuff for usb 3 * 4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de> 5 * 6 * based on drivers/usb/usb.c which had the following copyrights: 7 * (C) Copyright Linus Torvalds 1999 8 * (C) Copyright Johannes Erdfelt 1999-2001 --- 103 unchanged lines hidden (view full) --- 112 113/** 114 * store_remove_id - remove a USB device ID from this driver 115 * @driver: target device driver 116 * @buf: buffer for scanning device ID data 117 * @count: input size 118 * 119 * Removes a dynamic usb device ID from this driver. | 1/* 2 * drivers/usb/driver.c - most of the driver model stuff for usb 3 * 4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de> 5 * 6 * based on drivers/usb/usb.c which had the following copyrights: 7 * (C) Copyright Linus Torvalds 1999 8 * (C) Copyright Johannes Erdfelt 1999-2001 --- 103 unchanged lines hidden (view full) --- 112 113/** 114 * store_remove_id - remove a USB device ID from this driver 115 * @driver: target device driver 116 * @buf: buffer for scanning device ID data 117 * @count: input size 118 * 119 * Removes a dynamic usb device ID from this driver. |
120 * 121 * Return: @count on success. A negative error code otherwise. |
|
120 */ 121static ssize_t 122store_remove_id(struct device_driver *driver, const char *buf, size_t count) 123{ 124 struct usb_dynid *dynid, *n; 125 struct usb_driver *usb_driver = to_usb_driver(driver); 126 u32 idVendor; 127 u32 idProduct; --- 324 unchanged lines hidden (view full) --- 452 * 453 * Few drivers should need to use this routine, since the most natural 454 * way to bind to an interface is to return the private data from 455 * the driver's probe() method. 456 * 457 * Callers must own the device lock, so driver probe() entries don't need 458 * extra locking, but other call contexts may need to explicitly claim that 459 * lock. | 122 */ 123static ssize_t 124store_remove_id(struct device_driver *driver, const char *buf, size_t count) 125{ 126 struct usb_dynid *dynid, *n; 127 struct usb_driver *usb_driver = to_usb_driver(driver); 128 u32 idVendor; 129 u32 idProduct; --- 324 unchanged lines hidden (view full) --- 454 * 455 * Few drivers should need to use this routine, since the most natural 456 * way to bind to an interface is to return the private data from 457 * the driver's probe() method. 458 * 459 * Callers must own the device lock, so driver probe() entries don't need 460 * extra locking, but other call contexts may need to explicitly claim that 461 * lock. |
462 * 463 * Return: 0 on success. |
|
460 */ 461int usb_driver_claim_interface(struct usb_driver *driver, 462 struct usb_interface *iface, void *priv) 463{ 464 struct device *dev = &iface->dev; 465 struct usb_device *udev; 466 int retval = 0; 467 int lpm_disable_error; --- 185 unchanged lines hidden (view full) --- 653 * usb_match_id searches an array of usb_device_id's and returns 654 * the first one matching the device or interface, or null. 655 * This is used when binding (or rebinding) a driver to an interface. 656 * Most USB device drivers will use this indirectly, through the usb core, 657 * but some layered driver frameworks use it directly. 658 * These device tables are exported with MODULE_DEVICE_TABLE, through 659 * modutils, to support the driver loading functionality of USB hotplugging. 660 * | 464 */ 465int usb_driver_claim_interface(struct usb_driver *driver, 466 struct usb_interface *iface, void *priv) 467{ 468 struct device *dev = &iface->dev; 469 struct usb_device *udev; 470 int retval = 0; 471 int lpm_disable_error; --- 185 unchanged lines hidden (view full) --- 657 * usb_match_id searches an array of usb_device_id's and returns 658 * the first one matching the device or interface, or null. 659 * This is used when binding (or rebinding) a driver to an interface. 660 * Most USB device drivers will use this indirectly, through the usb core, 661 * but some layered driver frameworks use it directly. 662 * These device tables are exported with MODULE_DEVICE_TABLE, through 663 * modutils, to support the driver loading functionality of USB hotplugging. 664 * |
665 * Return: The first matching usb_device_id, or %NULL. 666 * |
|
661 * What Matches: 662 * 663 * The "match_flags" element in a usb_device_id controls which 664 * members are used. If the corresponding bit is set, the 665 * value in the device_id must match its corresponding member 666 * in the device or interface descriptor, or else the device_id 667 * does not match. 668 * --- 149 unchanged lines hidden (view full) --- 818/** 819 * usb_register_device_driver - register a USB device (not interface) driver 820 * @new_udriver: USB operations for the device driver 821 * @owner: module owner of this driver. 822 * 823 * Registers a USB device driver with the USB core. The list of 824 * unattached devices will be rescanned whenever a new driver is 825 * added, allowing the new driver to attach to any recognized devices. | 667 * What Matches: 668 * 669 * The "match_flags" element in a usb_device_id controls which 670 * members are used. If the corresponding bit is set, the 671 * value in the device_id must match its corresponding member 672 * in the device or interface descriptor, or else the device_id 673 * does not match. 674 * --- 149 unchanged lines hidden (view full) --- 824/** 825 * usb_register_device_driver - register a USB device (not interface) driver 826 * @new_udriver: USB operations for the device driver 827 * @owner: module owner of this driver. 828 * 829 * Registers a USB device driver with the USB core. The list of 830 * unattached devices will be rescanned whenever a new driver is 831 * added, allowing the new driver to attach to any recognized devices. |
826 * Returns a negative error code on failure and 0 on success. | 832 * 833 * Return: A negative error code on failure and 0 on success. |
827 */ 828int usb_register_device_driver(struct usb_device_driver *new_udriver, 829 struct module *owner) 830{ 831 int retval = 0; 832 833 if (usb_disabled()) 834 return -ENODEV; --- 39 unchanged lines hidden (view full) --- 874 * usb_register_driver - register a USB interface driver 875 * @new_driver: USB operations for the interface driver 876 * @owner: module owner of this driver. 877 * @mod_name: module name string 878 * 879 * Registers a USB interface driver with the USB core. The list of 880 * unattached interfaces will be rescanned whenever a new driver is 881 * added, allowing the new driver to attach to any recognized interfaces. | 834 */ 835int usb_register_device_driver(struct usb_device_driver *new_udriver, 836 struct module *owner) 837{ 838 int retval = 0; 839 840 if (usb_disabled()) 841 return -ENODEV; --- 39 unchanged lines hidden (view full) --- 881 * usb_register_driver - register a USB interface driver 882 * @new_driver: USB operations for the interface driver 883 * @owner: module owner of this driver. 884 * @mod_name: module name string 885 * 886 * Registers a USB interface driver with the USB core. The list of 887 * unattached interfaces will be rescanned whenever a new driver is 888 * added, allowing the new driver to attach to any recognized interfaces. |
882 * Returns a negative error code on failure and 0 on success. | |
883 * | 889 * |
890 * Return: A negative error code on failure and 0 on success. 891 * |
|
884 * NOTE: if you want your driver to use the USB major number, you must call 885 * usb_register_dev() to enable that functionality. This function no longer 886 * takes care of that. 887 */ 888int usb_register_driver(struct usb_driver *new_driver, struct module *owner, 889 const char *mod_name) 890{ 891 int retval = 0; --- 316 unchanged lines hidden (view full) --- 1208 * Autosuspend requests originating from a child device or an interface 1209 * driver may be made without the protection of @udev's device lock, but 1210 * all other suspend calls will hold the lock. Usbcore will insure that 1211 * method calls do not arrive during bind, unbind, or reset operations. 1212 * However drivers must be prepared to handle suspend calls arriving at 1213 * unpredictable times. 1214 * 1215 * This routine can run only in process context. | 892 * NOTE: if you want your driver to use the USB major number, you must call 893 * usb_register_dev() to enable that functionality. This function no longer 894 * takes care of that. 895 */ 896int usb_register_driver(struct usb_driver *new_driver, struct module *owner, 897 const char *mod_name) 898{ 899 int retval = 0; --- 316 unchanged lines hidden (view full) --- 1216 * Autosuspend requests originating from a child device or an interface 1217 * driver may be made without the protection of @udev's device lock, but 1218 * all other suspend calls will hold the lock. Usbcore will insure that 1219 * method calls do not arrive during bind, unbind, or reset operations. 1220 * However drivers must be prepared to handle suspend calls arriving at 1221 * unpredictable times. 1222 * 1223 * This routine can run only in process context. |
1224 * 1225 * Return: 0 if the suspend succeeded. |
|
1216 */ 1217static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) 1218{ 1219 int status = 0; 1220 int i = 0, n = 0; 1221 struct usb_interface *intf; 1222 1223 if (udev->state == USB_STATE_NOTATTACHED || --- 65 unchanged lines hidden (view full) --- 1289 * Autoresume requests originating from a child device or an interface 1290 * driver may be made without the protection of @udev's device lock, but 1291 * all other resume calls will hold the lock. Usbcore will insure that 1292 * method calls do not arrive during bind, unbind, or reset operations. 1293 * However drivers must be prepared to handle resume calls arriving at 1294 * unpredictable times. 1295 * 1296 * This routine can run only in process context. | 1226 */ 1227static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) 1228{ 1229 int status = 0; 1230 int i = 0, n = 0; 1231 struct usb_interface *intf; 1232 1233 if (udev->state == USB_STATE_NOTATTACHED || --- 65 unchanged lines hidden (view full) --- 1299 * Autoresume requests originating from a child device or an interface 1300 * driver may be made without the protection of @udev's device lock, but 1301 * all other resume calls will hold the lock. Usbcore will insure that 1302 * method calls do not arrive during bind, unbind, or reset operations. 1303 * However drivers must be prepared to handle resume calls arriving at 1304 * unpredictable times. 1305 * 1306 * This routine can run only in process context. |
1307 * 1308 * Return: 0 on success. |
|
1297 */ 1298static int usb_resume_both(struct usb_device *udev, pm_message_t msg) 1299{ 1300 int status = 0; 1301 int i; 1302 struct usb_interface *intf; 1303 1304 if (udev->state == USB_STATE_NOTATTACHED) { --- 181 unchanged lines hidden (view full) --- 1486 * request is received. 1487 * 1488 * @udev's usage counter is incremented to prevent subsequent autosuspends. 1489 * However if the autoresume fails then the usage counter is re-decremented. 1490 * 1491 * The caller must hold @udev's device lock. 1492 * 1493 * This routine can run only in process context. | 1309 */ 1310static int usb_resume_both(struct usb_device *udev, pm_message_t msg) 1311{ 1312 int status = 0; 1313 int i; 1314 struct usb_interface *intf; 1315 1316 if (udev->state == USB_STATE_NOTATTACHED) { --- 181 unchanged lines hidden (view full) --- 1498 * request is received. 1499 * 1500 * @udev's usage counter is incremented to prevent subsequent autosuspends. 1501 * However if the autoresume fails then the usage counter is re-decremented. 1502 * 1503 * The caller must hold @udev's device lock. 1504 * 1505 * This routine can run only in process context. |
1506 * 1507 * Return: 0 on success. A negative error code otherwise. |
|
1494 */ 1495int usb_autoresume_device(struct usb_device *udev) 1496{ 1497 int status; 1498 1499 status = pm_runtime_get_sync(&udev->dev); 1500 if (status < 0) 1501 pm_runtime_put_sync(&udev->dev); --- 93 unchanged lines hidden (view full) --- 1595 * This prevention will persist until usb_autopm_put_interface() is called 1596 * or @intf is unbound. A typical example would be a character-device 1597 * driver when its device file is opened. 1598 * 1599 * @intf's usage counter is incremented to prevent subsequent autosuspends. 1600 * However if the autoresume fails then the counter is re-decremented. 1601 * 1602 * This routine can run only in process context. | 1508 */ 1509int usb_autoresume_device(struct usb_device *udev) 1510{ 1511 int status; 1512 1513 status = pm_runtime_get_sync(&udev->dev); 1514 if (status < 0) 1515 pm_runtime_put_sync(&udev->dev); --- 93 unchanged lines hidden (view full) --- 1609 * This prevention will persist until usb_autopm_put_interface() is called 1610 * or @intf is unbound. A typical example would be a character-device 1611 * driver when its device file is opened. 1612 * 1613 * @intf's usage counter is incremented to prevent subsequent autosuspends. 1614 * However if the autoresume fails then the counter is re-decremented. 1615 * 1616 * This routine can run only in process context. |
1617 * 1618 * Return: 0 on success. |
|
1603 */ 1604int usb_autopm_get_interface(struct usb_interface *intf) 1605{ 1606 int status; 1607 1608 status = pm_runtime_get_sync(&intf->dev); 1609 if (status < 0) 1610 pm_runtime_put_sync(&intf->dev); --- 17 unchanged lines hidden (view full) --- 1628 * queues an autoresume request if the device is suspended. The 1629 * differences are that it does not perform any synchronization (callers 1630 * should hold a private lock and handle all synchronization issues 1631 * themselves), and it does not autoresume the device directly (it only 1632 * queues a request). After a successful call, the device may not yet be 1633 * resumed. 1634 * 1635 * This routine can run in atomic context. | 1619 */ 1620int usb_autopm_get_interface(struct usb_interface *intf) 1621{ 1622 int status; 1623 1624 status = pm_runtime_get_sync(&intf->dev); 1625 if (status < 0) 1626 pm_runtime_put_sync(&intf->dev); --- 17 unchanged lines hidden (view full) --- 1644 * queues an autoresume request if the device is suspended. The 1645 * differences are that it does not perform any synchronization (callers 1646 * should hold a private lock and handle all synchronization issues 1647 * themselves), and it does not autoresume the device directly (it only 1648 * queues a request). After a successful call, the device may not yet be 1649 * resumed. 1650 * 1651 * This routine can run in atomic context. |
1652 * 1653 * Return: 0 on success. A negative error code otherwise. |
|
1636 */ 1637int usb_autopm_get_interface_async(struct usb_interface *intf) 1638{ 1639 int status; 1640 1641 status = pm_runtime_get(&intf->dev); 1642 if (status < 0 && status != -EINPROGRESS) 1643 pm_runtime_put_noidle(&intf->dev); --- 149 unchanged lines hidden --- | 1654 */ 1655int usb_autopm_get_interface_async(struct usb_interface *intf) 1656{ 1657 int status; 1658 1659 status = pm_runtime_get(&intf->dev); 1660 if (status < 0 && status != -EINPROGRESS) 1661 pm_runtime_put_noidle(&intf->dev); --- 149 unchanged lines hidden --- |