Damjan Marion | f0ccbb0 | 2016-10-06 16:53:32 +0200 | [diff] [blame] | 1 | #!/bin/bash |
2 | |||||
3 | # Bind all unused PCI devices bound to uio drivers | ||||
4 | # back to default kernel driver | ||||
5 | |||||
6 | if [ $USER != "root" ] ; then | ||||
7 | echo "Restarting script with sudo..." | ||||
8 | sudo $0 ${*} | ||||
9 | exit | ||||
10 | fi | ||||
11 | |||||
12 | for f in /sys/bus/pci/drivers/{igb_uio,uio_pci_generic,vfio-pci}/*; do | ||||
13 | [ -e ${f}/config ] || continue | ||||
14 | fuser -s ${f}/config && continue | ||||
15 | echo 1 > ${f}/remove | ||||
16 | removed=y | ||||
17 | done | ||||
18 | |||||
19 | [ -n ${removed} ] && echo 1 > /sys/bus/pci/rescan |