diff mbox

[U-Boot,v3,1/4] dm: usb: Unbind old block devices when shutting down USB

Message ID 1457878957-22697-2-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass March 13, 2016, 2:22 p.m. UTC
When 'usb start' is used, block devices are created for any USB flash sticks
and disks, etc. When 'usb stop' is used, these block devices are currently
not removed.

We don't want old block devices hanging around since they can still be
visible to U-Boot. Therefore, when USB is shut down, remove and unbind all
the block devices created by the USB subsystem.

Possibly we should unbind all devices which don't cause problems by being
unbound. Most likely we can remove everything except USB controllers, hubs
and emulators. We can consider that later.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
---

Changes in v3:
- Expand the commit message

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Simon Glass March 20, 2016, 12:26 a.m. UTC | #1
On 13 March 2016 at 08:22, Simon Glass <sjg@chromium.org> wrote:
> When 'usb start' is used, block devices are created for any USB flash sticks
> and disks, etc. When 'usb stop' is used, these block devices are currently
> not removed.
>
> We don't want old block devices hanging around since they can still be
> visible to U-Boot. Therefore, when USB is shut down, remove and unbind all
> the block devices created by the USB subsystem.
>
> Possibly we should unbind all devices which don't cause problems by being
> unbound. Most likely we can remove everything except USB controllers, hubs
> and emulators. We can consider that later.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Tested-by: Stephen Warren <swarren@nvidia.com>
> ---
>
> Changes in v3:
> - Expand the commit message
>
> Changes in v2: None
>
>  drivers/usb/host/usb-uclass.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 50538e0..69c9a50 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -159,7 +159,11 @@  int usb_stop(void)
 		if (ret && !err)
 			err = ret;
 	}
-
+#ifdef CONFIG_BLK
+	ret = blk_unbind_all(IF_TYPE_USB);
+	if (ret && !err)
+		err = ret;
+#endif
 #ifdef CONFIG_SANDBOX
 	struct udevice *dev;