Message ID | 1498211673-18715-6-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
On 06/23/2017 11:54 AM, Bin Meng wrote: > Sometimes we need know if a given hub device is root hub or not. > Add a new API to test this. > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com> > --- > > common/usb_hub.c | 10 ++++++++++ > include/usb.h | 8 ++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/common/usb_hub.c b/common/usb_hub.c > index 18bd827..d780251 100644 > --- a/common/usb_hub.c > +++ b/common/usb_hub.c > @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) > return hdev->descriptor.bDeviceProtocol == 3; > } > > +#ifdef CONFIG_DM_USB > +bool usb_hub_is_root_hub(struct udevice *hub) > +{ > + if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) Can this call fail ? > + return true; > + > + return false; > +} > +#endif > + > static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size) > { > unsigned short dtype = USB_DT_HUB; > diff --git a/include/usb.h b/include/usb.h > index eb82cc2..c504d71 100644 > --- a/include/usb.h > +++ b/include/usb.h > @@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, > struct usb_device *parent); > > /** > + * usb_hub_is_root_hub() - Test whether a hub device is root hub or not > + * > + * @hub: USB hub device to test > + * @return: true if the hub device is root hub, false otherwise. > + */ > +bool usb_hub_is_root_hub(struct udevice *hub); > + > +/** > * usb_hub_scan() - Scan a hub and find its devices > * > * @hub: Hub device to scan >
On 06/23/2017 11:54 AM, Bin Meng wrote: > Sometimes we need know if a given hub device is root hub or not. > Add a new API to test this. > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com> > --- > > common/usb_hub.c | 10 ++++++++++ > include/usb.h | 8 ++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/common/usb_hub.c b/common/usb_hub.c > index 18bd827..d780251 100644 > --- a/common/usb_hub.c > +++ b/common/usb_hub.c > @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) > return hdev->descriptor.bDeviceProtocol == 3; > } > > +#ifdef CONFIG_DM_USB > +bool usb_hub_is_root_hub(struct udevice *hub) Actually , this is the is_root_hub() from the 6/16 , right , not a new API. If you want to factor out stuff , just do that , but also remove the is_root_hub() and do the conversion in the same patch. > +{ > + if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) > + return true; > + > + return false; > +} > +#endif > + > static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size) > { > unsigned short dtype = USB_DT_HUB; > diff --git a/include/usb.h b/include/usb.h > index eb82cc2..c504d71 100644 > --- a/include/usb.h > +++ b/include/usb.h > @@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, > struct usb_device *parent); > > /** > + * usb_hub_is_root_hub() - Test whether a hub device is root hub or not > + * > + * @hub: USB hub device to test > + * @return: true if the hub device is root hub, false otherwise. > + */ > +bool usb_hub_is_root_hub(struct udevice *hub); > + > +/** > * usb_hub_scan() - Scan a hub and find its devices > * > * @hub: Hub device to scan >
Hi Marek, On Sat, Jun 24, 2017 at 1:57 AM, Marek Vasut <marex@denx.de> wrote: > On 06/23/2017 11:54 AM, Bin Meng wrote: >> Sometimes we need know if a given hub device is root hub or not. >> Add a new API to test this. >> >> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> >> --- >> >> common/usb_hub.c | 10 ++++++++++ >> include/usb.h | 8 ++++++++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/common/usb_hub.c b/common/usb_hub.c >> index 18bd827..d780251 100644 >> --- a/common/usb_hub.c >> +++ b/common/usb_hub.c >> @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) >> return hdev->descriptor.bDeviceProtocol == 3; >> } >> >> +#ifdef CONFIG_DM_USB >> +bool usb_hub_is_root_hub(struct udevice *hub) > > Actually , this is the is_root_hub() from the 6/16 , right , not a new > API. If you want to factor out stuff , just do that , but also remove > the is_root_hub() and do the conversion in the same patch. > Correct, is_root_hub() is static within xhci.c and only used by part of the xHCI driver. To other USB codes, this is a new API. The two patches (5/16, 6/16) are still self-contained, as each is against a single module. But if you would like to do the two in one patch, let me know and I will do in v2. [snip] Regards, Bin
On 06/24/2017 03:41 AM, Bin Meng wrote: > Hi Marek, > > On Sat, Jun 24, 2017 at 1:57 AM, Marek Vasut <marex@denx.de> wrote: >> On 06/23/2017 11:54 AM, Bin Meng wrote: >>> Sometimes we need know if a given hub device is root hub or not. >>> Add a new API to test this. >>> >>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> >>> --- >>> >>> common/usb_hub.c | 10 ++++++++++ >>> include/usb.h | 8 ++++++++ >>> 2 files changed, 18 insertions(+) >>> >>> diff --git a/common/usb_hub.c b/common/usb_hub.c >>> index 18bd827..d780251 100644 >>> --- a/common/usb_hub.c >>> +++ b/common/usb_hub.c >>> @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) >>> return hdev->descriptor.bDeviceProtocol == 3; >>> } >>> >>> +#ifdef CONFIG_DM_USB >>> +bool usb_hub_is_root_hub(struct udevice *hub) >> >> Actually , this is the is_root_hub() from the 6/16 , right , not a new >> API. If you want to factor out stuff , just do that , but also remove >> the is_root_hub() and do the conversion in the same patch. >> > > Correct, is_root_hub() is static within xhci.c and only used by part > of the xHCI driver. To other USB codes, this is a new API. The two > patches (5/16, 6/16) are still self-contained, as each is against a > single module. But if you would like to do the two in one patch, let > me know and I will do in v2. I'd like a patch which pulls this out of xhci driver, yes. > [snip] > > Regards, > Bin >
Hi Marek, On Sat, Jun 24, 2017 at 1:55 AM, Marek Vasut <marex@denx.de> wrote: > On 06/23/2017 11:54 AM, Bin Meng wrote: >> Sometimes we need know if a given hub device is root hub or not. >> Add a new API to test this. >> >> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> >> --- >> >> common/usb_hub.c | 10 ++++++++++ >> include/usb.h | 8 ++++++++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/common/usb_hub.c b/common/usb_hub.c >> index 18bd827..d780251 100644 >> --- a/common/usb_hub.c >> +++ b/common/usb_hub.c >> @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) >> return hdev->descriptor.bDeviceProtocol == 3; >> } >> >> +#ifdef CONFIG_DM_USB >> +bool usb_hub_is_root_hub(struct udevice *hub) >> +{ >> + if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) > > Can this call fail ? No, Regards, Bin
diff --git a/common/usb_hub.c b/common/usb_hub.c index 18bd827..d780251 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) return hdev->descriptor.bDeviceProtocol == 3; } +#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub(struct udevice *hub) +{ + if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) + return true; + + return false; +} +#endif + static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size) { unsigned short dtype = USB_DT_HUB; diff --git a/include/usb.h b/include/usb.h index eb82cc2..c504d71 100644 --- a/include/usb.h +++ b/include/usb.h @@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, struct usb_device *parent); /** + * usb_hub_is_root_hub() - Test whether a hub device is root hub or not + * + * @hub: USB hub device to test + * @return: true if the hub device is root hub, false otherwise. + */ +bool usb_hub_is_root_hub(struct udevice *hub); + +/** * usb_hub_scan() - Scan a hub and find its devices * * @hub: Hub device to scan
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> --- common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)