aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2011-02-22 09:53:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-25 14:35:42 -0500
commit3b29b68b1627781b5eecb581d3b9d5f0043a72f2 (patch)
tree8858863f5b43804c5c61b1cbe87a0a6f3c4ab1b3 /drivers/usb/core
parent10408bb9c4bf669f56f8de380f3ce18ef601a3d4 (diff)
USB: use "device number" instead of "address"
The USB stack historically has conflated device numbers (i.e., the value of udev->devnum) with device addresses. This is understandable, because until recently the two values were always the same. But with USB-3.0 they aren't the same, so we should start calling these things by their correct names. This patch (as1449b) changes many of the references to "address" in the hub driver to "device number" or "devnum". The patch also removes some unnecessary or misleading comments. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Luben Tuikov <ltuikov@yahoo.com> Reviewed-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/hub.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d041c6826e4..c168121f9f9 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1499,6 +1499,13 @@ void usb_set_device_state(struct usb_device *udev,
1499EXPORT_SYMBOL_GPL(usb_set_device_state); 1499EXPORT_SYMBOL_GPL(usb_set_device_state);
1500 1500
1501/* 1501/*
1502 * Choose a device number.
1503 *
1504 * Device numbers are used as filenames in usbfs. On USB-1.1 and
1505 * USB-2.0 buses they are also used as device addresses, however on
1506 * USB-3.0 buses the address is assigned by the controller hardware
1507 * and it usually is not the same as the device number.
1508 *
1502 * WUSB devices are simple: they have no hubs behind, so the mapping 1509 * WUSB devices are simple: they have no hubs behind, so the mapping
1503 * device <-> virtual port number becomes 1:1. Why? to simplify the 1510 * device <-> virtual port number becomes 1:1. Why? to simplify the
1504 * life of the device connection logic in 1511 * life of the device connection logic in
@@ -1520,7 +1527,7 @@ EXPORT_SYMBOL_GPL(usb_set_device_state);
1520 * the HCD must setup data structures before issuing a set address 1527 * the HCD must setup data structures before issuing a set address
1521 * command to the hardware. 1528 * command to the hardware.
1522 */ 1529 */
1523static void choose_address(struct usb_device *udev) 1530static void choose_devnum(struct usb_device *udev)
1524{ 1531{
1525 int devnum; 1532 int devnum;
1526 struct usb_bus *bus = udev->bus; 1533 struct usb_bus *bus = udev->bus;
@@ -1545,7 +1552,7 @@ static void choose_address(struct usb_device *udev)
1545 } 1552 }
1546} 1553}
1547 1554
1548static void release_address(struct usb_device *udev) 1555static void release_devnum(struct usb_device *udev)
1549{ 1556{
1550 if (udev->devnum > 0) { 1557 if (udev->devnum > 0) {
1551 clear_bit(udev->devnum, udev->bus->devmap.devicemap); 1558 clear_bit(udev->devnum, udev->bus->devmap.devicemap);
@@ -1553,7 +1560,7 @@ static void release_address(struct usb_device *udev)
1553 } 1560 }
1554} 1561}
1555 1562
1556static void update_address(struct usb_device *udev, int devnum) 1563static void update_devnum(struct usb_device *udev, int devnum)
1557{ 1564{
1558 /* The address for a WUSB device is managed by wusbcore. */ 1565 /* The address for a WUSB device is managed by wusbcore. */
1559 if (!udev->wusb) 1566 if (!udev->wusb)
@@ -1600,7 +1607,8 @@ void usb_disconnect(struct usb_device **pdev)
1600 * this quiesces everyting except pending urbs. 1607 * this quiesces everyting except pending urbs.
1601 */ 1608 */
1602 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1609 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1603 dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum); 1610 dev_info(&udev->dev, "USB disconnect, device number %d\n",
1611 udev->devnum);
1604 1612
1605 usb_lock_device(udev); 1613 usb_lock_device(udev);
1606 1614
@@ -1630,7 +1638,7 @@ void usb_disconnect(struct usb_device **pdev)
1630 /* Free the device number and delete the parent's children[] 1638 /* Free the device number and delete the parent's children[]
1631 * (or root_hub) pointer. 1639 * (or root_hub) pointer.
1632 */ 1640 */
1633 release_address(udev); 1641 release_devnum(udev);
1634 1642
1635 /* Avoid races with recursively_mark_NOTATTACHED() */ 1643 /* Avoid races with recursively_mark_NOTATTACHED() */
1636 spin_lock_irq(&device_state_lock); 1644 spin_lock_irq(&device_state_lock);
@@ -2071,7 +2079,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2071 case 0: 2079 case 0:
2072 /* TRSTRCY = 10 ms; plus some extra */ 2080 /* TRSTRCY = 10 ms; plus some extra */
2073 msleep(10 + 40); 2081 msleep(10 + 40);
2074 update_address(udev, 0); 2082 update_devnum(udev, 0);
2075 if (hcd->driver->reset_device) { 2083 if (hcd->driver->reset_device) {
2076 status = hcd->driver->reset_device(hcd, udev); 2084 status = hcd->driver->reset_device(hcd, udev);
2077 if (status < 0) { 2085 if (status < 0) {
@@ -2634,7 +2642,7 @@ static int hub_set_address(struct usb_device *udev, int devnum)
2634 USB_REQ_SET_ADDRESS, 0, devnum, 0, 2642 USB_REQ_SET_ADDRESS, 0, devnum, 0,
2635 NULL, 0, USB_CTRL_SET_TIMEOUT); 2643 NULL, 0, USB_CTRL_SET_TIMEOUT);
2636 if (retval == 0) { 2644 if (retval == 0) {
2637 update_address(udev, devnum); 2645 update_devnum(udev, devnum);
2638 /* Device now using proper address. */ 2646 /* Device now using proper address. */
2639 usb_set_device_state(udev, USB_STATE_ADDRESS); 2647 usb_set_device_state(udev, USB_STATE_ADDRESS);
2640 usb_ep0_reinit(udev); 2648 usb_ep0_reinit(udev);
@@ -2743,9 +2751,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2743 } 2751 }
2744 if (udev->speed != USB_SPEED_SUPER) 2752 if (udev->speed != USB_SPEED_SUPER)
2745 dev_info(&udev->dev, 2753 dev_info(&udev->dev,
2746 "%s %s speed %sUSB device using %s and address %d\n", 2754 "%s %s speed %sUSB device number %d using %s\n",
2747 (udev->config) ? "reset" : "new", speed, type, 2755 (udev->config) ? "reset" : "new", speed, type,
2748 udev->bus->controller->driver->name, devnum); 2756 devnum, udev->bus->controller->driver->name);
2749 2757
2750 /* Set up TT records, if needed */ 2758 /* Set up TT records, if needed */
2751 if (hdev->tt) { 2759 if (hdev->tt) {
@@ -2775,10 +2783,6 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2775 * value. 2783 * value.
2776 */ 2784 */
2777 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 2785 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
2778 /*
2779 * An xHCI controller cannot send any packets to a device until
2780 * a set address command successfully completes.
2781 */
2782 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) { 2786 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) {
2783 struct usb_device_descriptor *buf; 2787 struct usb_device_descriptor *buf;
2784 int r = 0; 2788 int r = 0;
@@ -2861,9 +2865,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2861 if (udev->speed == USB_SPEED_SUPER) { 2865 if (udev->speed == USB_SPEED_SUPER) {
2862 devnum = udev->devnum; 2866 devnum = udev->devnum;
2863 dev_info(&udev->dev, 2867 dev_info(&udev->dev,
2864 "%s SuperSpeed USB device using %s and address %d\n", 2868 "%s SuperSpeed USB device number %d using %s\n",
2865 (udev->config) ? "reset" : "new", 2869 (udev->config) ? "reset" : "new",
2866 udev->bus->controller->driver->name, devnum); 2870 devnum, udev->bus->controller->driver->name);
2867 } 2871 }
2868 2872
2869 /* cope with hardware quirkiness: 2873 /* cope with hardware quirkiness:
@@ -2926,7 +2930,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2926fail: 2930fail:
2927 if (retval) { 2931 if (retval) {
2928 hub_port_disable(hub, port1, 0); 2932 hub_port_disable(hub, port1, 0);
2929 update_address(udev, devnum); /* for disconnect processing */ 2933 update_devnum(udev, devnum); /* for disconnect processing */
2930 } 2934 }
2931 mutex_unlock(&usb_address0_mutex); 2935 mutex_unlock(&usb_address0_mutex);
2932 return retval; 2936 return retval;
@@ -3135,15 +3139,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
3135 else 3139 else
3136 udev->speed = USB_SPEED_UNKNOWN; 3140 udev->speed = USB_SPEED_UNKNOWN;
3137 3141
3138 /* 3142 choose_devnum(udev);
3139 * Set the address.
3140 * Note xHCI needs to issue an address device command later
3141 * in the hub_port_init sequence for SS/HS/FS/LS devices,
3142 * and xHC will assign an address to the device. But use
3143 * kernel assigned address here, to avoid any address conflict
3144 * issue.
3145 */
3146 choose_address(udev);
3147 if (udev->devnum <= 0) { 3143 if (udev->devnum <= 0) {
3148 status = -ENOTCONN; /* Don't retry */ 3144 status = -ENOTCONN; /* Don't retry */
3149 goto loop; 3145 goto loop;
@@ -3235,7 +3231,7 @@ loop_disable:
3235 hub_port_disable(hub, port1, 1); 3231 hub_port_disable(hub, port1, 1);
3236loop: 3232loop:
3237 usb_ep0_reinit(udev); 3233 usb_ep0_reinit(udev);
3238 release_address(udev); 3234 release_devnum(udev);
3239 hub_free_dev(udev); 3235 hub_free_dev(udev);
3240 usb_put_dev(udev); 3236 usb_put_dev(udev);
3241 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 3237 if ((status == -ENOTCONN) || (status == -ENOTSUPP))