aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Lin <jilin@nvidia.com>2019-06-03 06:53:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-05 05:54:38 -0400
commit4998f1efd1904dd21697aeeead270e3eb97691dd (patch)
treec099adeec7515e42f6cbdecdbd0074328fc8da80
parent32adeab3e3b5bc01ebb7746600e7c734482230d7 (diff)
usb: Add devaddr in struct usb_device
The Clear_TT_Buffer request sent to the hub includes the address of the LS/FS child device in wValue field. usb_hub_clear_tt_buffer() uses udev->devnum to set the address wValue. This won't work for devices connected to xHC. For other host controllers udev->devnum is the same as the address of the usb device, chosen and set by usb core. With xHC the controller hardware assigns the address, and won't be the same as devnum. Here we add devaddr in "struct usb_device" for usb_hub_clear_tt_buffer() to use. Signed-off-by: Jim Lin <jilin@nvidia.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/hub.c4
-rw-r--r--drivers/usb/host/xhci.c2
-rw-r--r--include/linux/usb.h2
3 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 572e8c26a129..82cc3766cb23 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -873,7 +873,7 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
873 /* info that CLEAR_TT_BUFFER needs */ 873 /* info that CLEAR_TT_BUFFER needs */
874 clear->tt = tt->multi ? udev->ttport : 1; 874 clear->tt = tt->multi ? udev->ttport : 1;
875 clear->devinfo = usb_pipeendpoint (pipe); 875 clear->devinfo = usb_pipeendpoint (pipe);
876 clear->devinfo |= udev->devnum << 4; 876 clear->devinfo |= ((u16)udev->devaddr) << 4;
877 clear->devinfo |= usb_pipecontrol(pipe) 877 clear->devinfo |= usb_pipecontrol(pipe)
878 ? (USB_ENDPOINT_XFER_CONTROL << 11) 878 ? (USB_ENDPOINT_XFER_CONTROL << 11)
879 : (USB_ENDPOINT_XFER_BULK << 11); 879 : (USB_ENDPOINT_XFER_BULK << 11);
@@ -2125,6 +2125,8 @@ static void update_devnum(struct usb_device *udev, int devnum)
2125 /* The address for a WUSB device is managed by wusbcore. */ 2125 /* The address for a WUSB device is managed by wusbcore. */
2126 if (!udev->wusb) 2126 if (!udev->wusb)
2127 udev->devnum = devnum; 2127 udev->devnum = devnum;
2128 if (!udev->devaddr)
2129 udev->devaddr = (u8)devnum;
2128} 2130}
2129 2131
2130static void hub_free_dev(struct usb_device *udev) 2132static void hub_free_dev(struct usb_device *udev)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 20db378a6012..4f92643e3a4c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4125,6 +4125,8 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
4125 /* Zero the input context control for later use */ 4125 /* Zero the input context control for later use */
4126 ctrl_ctx->add_flags = 0; 4126 ctrl_ctx->add_flags = 0;
4127 ctrl_ctx->drop_flags = 0; 4127 ctrl_ctx->drop_flags = 0;
4128 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
4129 udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK);
4128 4130
4129 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 4131 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
4130 "Internal device address = %d", 4132 "Internal device address = %d",
diff --git a/include/linux/usb.h b/include/linux/usb.h
index ae82d9d1112b..83d35d993e8c 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -578,6 +578,7 @@ struct usb3_lpm_parameters {
578 * @bus_mA: Current available from the bus 578 * @bus_mA: Current available from the bus
579 * @portnum: parent port number (origin 1) 579 * @portnum: parent port number (origin 1)
580 * @level: number of USB hub ancestors 580 * @level: number of USB hub ancestors
581 * @devaddr: device address, XHCI: assigned by HW, others: same as devnum
581 * @can_submit: URBs may be submitted 582 * @can_submit: URBs may be submitted
582 * @persist_enabled: USB_PERSIST enabled for this device 583 * @persist_enabled: USB_PERSIST enabled for this device
583 * @have_langid: whether string_langid is valid 584 * @have_langid: whether string_langid is valid
@@ -661,6 +662,7 @@ struct usb_device {
661 unsigned short bus_mA; 662 unsigned short bus_mA;
662 u8 portnum; 663 u8 portnum;
663 u8 level; 664 u8 level;
665 u8 devaddr;
664 666
665 unsigned can_submit:1; 667 unsigned can_submit:1;
666 unsigned persist_enabled:1; 668 unsigned persist_enabled:1;