Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C: How to manually add a dependency when compiling a Kernel module

I'm working on an embedded Linux system that has a specific I2C platform driver and I'm writing a custom I2C driver. Everything works fine, but I have a problem with their dependencies.

As my custom driver uses the default I2C functions, once I compile it, the make command automatically updates the modules.dep file saying that my driver depends on i2c-core to run, but that is not enough. In order to i2c-core to be configured I need to load i2c-omap first (the platform's driver) and only then my driver works properly.

Unfortunately, I can't find any dummy function to call and thus trick the make into adding another dependency when it generates my driver. Also, I would prefer an automated solution instead of modifying modules.dep with something like sed -i 's/RE1/RE2/' modules.dep.

So, is there any way to explicitly add a dependency to a module when I compile it?

Thanks!

like image 760
Davi S Evangelista Avatar asked Feb 07 '26 14:02

Davi S Evangelista


1 Answers

I found an answer here: http://www.xml.com/ldd/chapter/book/ch11.html

I solved my problem calling

request_module("i2c-omap"); 

Anyway, this does not exactly update the dependencies file as I first intended. If anyone knows a way to do that, please add a comment here!

like image 123
Davi S Evangelista Avatar answered Feb 09 '26 04:02

Davi S Evangelista



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!