2024-01-12 11:19:51 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Resets all USB host controllers of the system.
|
|
|
|
# This is useful in case one stopped working
|
|
|
|
# due to a faulty device having been connected to it.
|
|
|
|
|
|
|
|
base="/sys/bus/pci/drivers"
|
|
|
|
sleep_secs="1"
|
|
|
|
|
|
|
|
# This might find a sub-set of these:
|
|
|
|
# * 'ohci_hcd' - USB 3.0
|
|
|
|
# * 'ehci-pci' - USB 2.0
|
|
|
|
# * 'xhci_hcd' - USB 3.0
|
|
|
|
echo "Looking for USB standards ..."
|
2024-10-06 19:25:34 +00:00
|
|
|
for usb_std in "$base/"?hci[-_]?c*; do
|
2024-01-12 11:19:51 +00:00
|
|
|
echo "* USB standard '$usb_std' ..."
|
2024-10-06 19:25:34 +00:00
|
|
|
|
|
|
|
for dev_path in "$usb_std/"*:*; do
|
2024-01-12 11:19:51 +00:00
|
|
|
dev="$(basename "$dev_path")"
|
|
|
|
echo " - Resetting device '$dev' ..."
|
2024-10-06 19:25:34 +00:00
|
|
|
printf '%s' "$dev" | sudo tee "$usb_std/unbind" >/dev/null
|
2024-01-12 11:19:51 +00:00
|
|
|
sleep "$sleep_secs"
|
2024-10-06 19:25:34 +00:00
|
|
|
printf '%s' "$dev" | sudo tee "$usb_std/bind" >/dev/null
|
2024-01-12 11:19:51 +00:00
|
|
|
echo " done."
|
|
|
|
done
|
2024-10-06 19:25:34 +00:00
|
|
|
|
2024-01-12 11:19:51 +00:00
|
|
|
echo " done."
|
|
|
|
done
|
|
|
|
echo "done."
|