[SLOF] [PATCH 3/4] usb: Initialize USB3 devices on a hub and keep track of hub topology
Thomas Huth
thuth at redhat.com
Tue Aug 2 18:23:00 AEST 2016
On 02.08.2016 04:01, Nikunj A Dadhania wrote:
> Thomas Huth <thuth at redhat.com> writes:
>
>> USB3 devices need to be initialized with usb3_dev_init(), so that
>> they get assigned a proper slot ID. And for USB3 devices that are
>> attached to a (non-root) hub, we also need to keep track of the
>> hub topology, so a new field called "hub" is added to the struct
>> usb_dev which references the hub devices where the current USB
>> devices is attached to. The hub topology will be used later to
>> build the so-called "route string" for the USB3 devices.
>>
>> Signed-off-by: Thomas Huth <thuth at redhat.com>
>> ---
>> lib/libusb/usb-core.h | 1 +
>> lib/libusb/usb-hub.c | 29 ++++++++++++++++++++++-------
>> lib/libusb/usb-xhci.c | 10 ++++++----
>> lib/libusb/usb-xhci.h | 3 +++
>> 4 files changed, 32 insertions(+), 11 deletions(-)
>>
>> diff --git a/lib/libusb/usb-core.h b/lib/libusb/usb-core.h
>> index a35df34..070aab5 100644
>> --- a/lib/libusb/usb-core.h
>> +++ b/lib/libusb/usb-core.h
>> @@ -79,6 +79,7 @@ enum USB_SPEED_TYPE {
>>
>> struct usb_dev {
>> struct usb_dev *next;
>> + struct usb_dev *hub;
>> struct usb_hcd_dev *hcidev;
>> struct usb_pipe *intr;
>> struct usb_pipe *control;
>> diff --git a/lib/libusb/usb-hub.c b/lib/libusb/usb-hub.c
>> index bb8a309..eeb347c 100644
>> --- a/lib/libusb/usb-hub.c
>> +++ b/lib/libusb/usb-hub.c
>> @@ -13,6 +13,7 @@
>> #include <stdio.h>
>> #include <string.h>
>> #include "usb-core.h"
>> +#include "usb-xhci.h"
>>
>> #undef HUB_DEBUG
>> //#define HUB_DEBUG
>> @@ -151,11 +152,30 @@ static int hub_check_port(struct usb_dev *dev, int port)
>> return false;
>> }
>>
>> +static bool usb_hub_init_dev(struct usb_dev *hub_dev, int port)
>> +{
>> + struct usb_dev *newdev;
>> +
>> + if (hub_dev->hcidev->type == USB_XHCI) {
>> + return usb3_dev_init(hub_dev->hcidev->priv, hub_dev, port);
>
> As you are returning from here, its not obvious here that the device
> setup is done or not. A comment here will help, saying that the new
> device is setup and populated within usb3_dev_init.
OK, I'll add a comment.
Thomas
More information about the SLOF
mailing list