[PATCH 2/2] usb: hub: Mark devices downstream a removable hub, as removable

From: Rajat Jain
Date: Wed Sep 29 2021 - 18:48:35 EST


If a usb device sits below a removable hub, mark the device also as
removable. This helps with devices inserted on a standard removable hub or
also thunderbold docks, to be shown as removable.

Signed-off-by: Rajat Jain <rajatja@xxxxxxxxxx>
---
drivers/usb/core/hub.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 45d1c81b121d..901d74bcdbd9 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2449,6 +2449,13 @@ static void set_usb_port_removable(struct usb_device *udev)
if (udev->dev.parent && dev_is_removable(udev->dev.parent))
dev_set_removable(&udev->dev, DEVICE_REMOVABLE);
return;
+ } else if (dev_is_removable(&hdev->dev)) {
+ /*
+ * If this USB device sits downstream a removable hub, then mark
+ * this device also as removable.
+ */
+ dev_set_removable(&udev->dev, DEVICE_REMOVABLE);
+ return;
}

hub = usb_hub_to_struct_hub(udev->parent);
--
2.33.0.685.g46640cef36-goog