bind/unbind USB ports
/sys/bus/pci/drivers/${driver}_hcd
${driver} could be ehci ohci uhci
the file with : is the id,
#to unbind
echo -n ${id} > unbind
#bind
echo -n ${id} > bind
#Note that after unbind, the id file will be gone, the id should be somehow saved to re-bind
script to bind/unbind:
function unbind_usb {
for driver in ehci ohci uhci; do
cd "/sys/bus/pci/drivers/${driver}_hcd";
ids=$(ls | grep :);
echo $ids > /tmp/DISABLED_$driver;
for id in $ids; do
echo "Unbinding $id";
echo -n "$id" > unbind;
disabled="$disabled $id";
done;
done;
}
function bind_usb {
for driver in ehci ohci uhci; do
cd "/sys/bus/pci/drivers/${driver}_hcd";
for id in $(cat /tmp/DISABLED_$driver); do
echo "Binding $id";
echo -n "$id" > bind;
done;
rm /tmp/DISABLED_$driver;
done;
}