aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBin Meng2017-07-19 21:51:11 +0800
committerMarek Vasut2017-07-28 23:34:30 +0200
commit46c1d49330fe21b3f9d2f7577ee4268248e7b666 (patch)
tree68584c48afb9880819e0b16eb985f047ce047092 /common
parenta199a7244899f6385035459cbc62409bd9bbcc23 (diff)
usb: hub: Add a new API to test if a hub device is root hub
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this. This removes the xHCI driver's own version is_root_hub() and change to use the new API. While we are here, remove the unused/commented out get_usb_device() in the xHCI driver too. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/usb_hub.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 086b155cb74..a8c2f560068 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -67,6 +67,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;