Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jim Lin and committed by
Greg Kroah-Hartman
4998f1ef 32adeab3

+7 -1
+3 -1
drivers/usb/core/hub.c
··· 873 873 /* info that CLEAR_TT_BUFFER needs */ 874 874 clear->tt = tt->multi ? udev->ttport : 1; 875 875 clear->devinfo = usb_pipeendpoint (pipe); 876 - clear->devinfo |= udev->devnum << 4; 876 + clear->devinfo |= ((u16)udev->devaddr) << 4; 877 877 clear->devinfo |= usb_pipecontrol(pipe) 878 878 ? (USB_ENDPOINT_XFER_CONTROL << 11) 879 879 : (USB_ENDPOINT_XFER_BULK << 11); ··· 2125 2125 /* The address for a WUSB device is managed by wusbcore. */ 2126 2126 if (!udev->wusb) 2127 2127 udev->devnum = devnum; 2128 + if (!udev->devaddr) 2129 + udev->devaddr = (u8)devnum; 2128 2130 } 2129 2131 2130 2132 static void hub_free_dev(struct usb_device *udev)
+2
drivers/usb/host/xhci.c
··· 4125 4125 /* Zero the input context control for later use */ 4126 4126 ctrl_ctx->add_flags = 0; 4127 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 4131 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 4130 4132 "Internal device address = %d",
+2
include/linux/usb.h
··· 578 578 * @bus_mA: Current available from the bus 579 579 * @portnum: parent port number (origin 1) 580 580 * @level: number of USB hub ancestors 581 + * @devaddr: device address, XHCI: assigned by HW, others: same as devnum 581 582 * @can_submit: URBs may be submitted 582 583 * @persist_enabled: USB_PERSIST enabled for this device 583 584 * @have_langid: whether string_langid is valid ··· 662 661 unsigned short bus_mA; 663 662 u8 portnum; 664 663 u8 level; 664 + u8 devaddr; 665 665 666 666 unsigned can_submit:1; 667 667 unsigned persist_enabled:1;