3
votes

I compiled the linux kernel with serial device driver statically i.e obj-y.

Now I'm working on a simple serial driver and I want to test it, but since the module is loaded when the kernel boots up, the IO port regions (0x3f8 and onwards) are registered to the serial module. I need to remove(unregister) it so that I can allocate it to my driver.

So, is there any way to remove the statically linked device driver ? or should I recompile the whole kernel :/

1

1 Answers

4
votes

You should recompile the whole kernel and make this driver an obj-m.

Once it's loaded (either done automatically by modprobe or manually with insmod), you may remove it (using rmmod), modify the code, compile it again and load it again.

Of course, if there was some critical error that was not handled properly during the driver's operation, the whole kernel will be in an unstable state and you will have to reboot (until you fix what causes this).