03-09-2020, 05:29 PM
(This post was last modified: 03-09-2020, 05:49 PM by Der Geist der Maschine.
Edit Reason: clarifications
)
(03-09-2020, 05:16 PM)Foxchild Wrote: That is very good to know, thank you!
Well, yes I'd like to reimplement leds-gpio, I think. I guess a very simple LED driver would be a good learning experience for a beginner.
So, I have a question... When I write to "brightness" in /sys/devices/platform/leds/leds/pinephone:blue:user/ (Ubuntu Touch), then the brightness can be modified. Which, I assume, is a value that is used by the leds-gpio module and written in the corresponding memory mapped register. So, why is there no leds-gpio module present when I execute lsmod?
Maybe the kernel module is built-in? What does
Code:
zgrep -i led /proc/config.gz
say?
Before you ask:
A module has an init() function that registers the driver with the kernel proper. It is executed if the module is built in or when the module is insmod'ed. The driver informs the kernel in this frunction for what peripherals it is in charge of.
If the kernel is aware of a peripheral for this driver then the kernel is calling the driver's probe() function. In this function, the driver would set in your example the sysfs callback functions.
There are discoverable busses (PCI, USB) and the kernel knows the peripherals. For non-discoverable buses, the kernel learns the peripherals from the device tree. See my first link.