Reputation: 43
I have a simple loadable kernel module which controls an LED by providing blinkingPeriod, on/off features etc...
The device is present at /sys/led , and functions fine.
I have provided an input paramater for the command line which takes in which GPIO the LED is connnected to. Now I want to reuse the same kernel module, for an additional number of LED's, however I cannot load the module with insmod for additional LED's with a different command line parameter, since an error is thrown:
Error: could not insert module - File exists.
I know this is telling me that I cannot load the same module twice, but what is the best approach when trying to provide LKM's for multiple devices ?
The only solution I can think of is to re-write a LKM for each individual LED/device which hardly seems efficient, or pack all of the LED's in one LKM which isn't very scalable/portable.
Does anyone have any comments on the best approach. Thanks in advance.
Upvotes: 0
Views: 766
Reputation: 2304
What you should do is: - adding support for multiple LEDs in your module - stop using the module parameters to configure the GPIO - implement a sysfs interface to allow instantiating LEDs. I would use something like gpiolib.
An even better solution would be to use device tree if your platform supports it.
However, your driver is probably not needed and you can surely already do want you want with the leds-gpio and leds-pwm drivers.
Upvotes: 1