Reputation: 43
I want to load and unload linux drivers in the device terminal,and I have two options but I do not want to do the first one
Build driver as a module CONFIG_DRIVER = m and I can use rmmod and modprobe to unload and load device driver.
Build device driver into kernel itself CONFIG_DRIVER = Y
I want to follow the 2nd option but I do not know how to unload and load the device driver, can the open source community please help me out here !
Upvotes: 3
Views: 9520
Reputation: 4709
It's easy as that. You find a device and driver which you want to unbind. For example, on my Intel Minnownboard (v1) I have PCH UDC controller (a PCI device):
% lspci -nk
...
02:02.4 0c03: 8086:8808 (rev 02)
Subsystem: 1cc8:0001
Kernel driver in use: pch_udc
Now I know necessary bits:
lspci
gives reduced PCI address, i.e. without domain or i.o.w. BDF, while driver expects domain:BDF)Take altogether we can unbind the device:
% echo 0000:02:02.4 > /sys/bus/pci/drivers/pch_udc/unbind
[ 3042.531872] configfs-gadget 0000:02:02.4: unregistering UDC driver [g1]
[ 3042.540979] udc 0000:02:02.4: releasing '0000:02:02.4'
You may bind it again. Simple use bind node in the same folder.
The feature appeared more than 15 years ago and here is the article on LWN that explains it.
Upvotes: 4