[PATCH 00/13] USB: Make USB devices removable
Sascha Hauer
s.hauer at pengutronix.de
Mon Aug 31 06:20:07 PDT 2026
So far we assumed that USB devices are not disconnected during barebox
lifetime, so we would only ever add to the list of devices. This series
relaxes this assumption. USB storage devices can now be disconnected at
runtime and the disk devices associated with them properly unregister
and filesystems are unmounted. Accesses to files on dead devices are
caught and return an error. Re-plugging USB storage devices works as
well. We still don't detect changes to the USB topology automatically,
but a subsequent "usb" command will bring the barebox topology up to
date with the hardware state.
This has so far only been tested with USB storage devices, USB network
devices and keyboards likely still need some fixes, but as we assumed
USB devices to be non-removable we can still see this series as a new
feature currently limited to USB storage devices.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
Sascha Hauer (13):
usb: don't report device removal after the device name is gone
fs: devfs: count an open partition as an open device
block: propagate errors from blockdevice_unregister()
fs: add cdev_umount_all()
block: add blockdevice_unregister_removed()
usb: storage: tear the disk down properly on disconnect
usb: hub: cancel pending port scans of a removed device
usb: reuse the addresses of removed devices
usb: hub: detect disconnected devices
usb: don't keep a dangling root device on enumeration failure
usb: hub: limit the number of ports to USB_MAXCHILDREN
usb: detect unplugged devices on transfer errors
usb: storage: stop talking to a device that is gone
common/block.c | 36 +++++++++-
drivers/usb/core/hub.c | 91 +++++++++++++++++++++++---
drivers/usb/core/usb.c | 141 +++++++++++++++++++++++++++++++++++++---
drivers/usb/core/usb.h | 2 +
drivers/usb/storage/transport.c | 4 ++
drivers/usb/storage/usb.c | 31 ++++++++-
fs/devfs-core.c | 14 +++-
fs/fs.c | 31 +++++++++
include/block.h | 1 +
include/fs.h | 1 +
include/linux/usb/usb.h | 16 +++++
11 files changed, 344 insertions(+), 24 deletions(-)
---
base-commit: 39ce98f9cb1cfd4a0601147a4dffa2319d73fc3f
change-id: 20260831-usb-device-lifetime-1c1233592d01
Best regards,
--
Sascha Hauer <s.hauer at pengutronix.de>
More information about the barebox
mailing list