I am trying short.c in examples of Linux Device Driver 3
My PC has Parallel Port and after the Ubuntu boots up, I can see these:
cat /proc/ioports
0378-037a : parport0
037b-037f : parport0
outp 0x378 1
(outp is another example in LDD3 which write data to ports)
the LED on the port is ON.
Then I run these commands to remove modules
rmmod lp
rmmod parport_pc
cat /proc/ioports
(There is no module on 0378-037f any more.)
I run this again but the LED is not ON this time.
outp 0x378 1
Then I install short.ko and request_region() succeeds.
cat /proc/ioports
0378-037f : short
cat /proc/devices
249 short
outp 0x378 1
the LED is not ON this time either.
I tried these too, but same result (LED is not ON)
mknod /dev/short0 c 249 0
echo -n "a" > /dev/short0
"a" is 0x61 so that the last bit is 1.
Why can I not write data out though I have got the I/O region?
Thanks for your answer.
Finally, I found the solution.
Make sure the “parport” module is not loaded or compiled into your kernel. It is not enough to simply unload the parport module, as it leaves the ports in an inconsistent state. You must reboot the machine and keep the parport and all related modules/code from loading in the first place.
One way to do this is to edit the /etc/modprobe.d/blacklist.conf file and add the following lines:
It seems that partport has modify the mode of parallel port.
And if cups is installed, you should modify /etc/modules-load.d/cups-filters.conf: