LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to find platform_device entry from a kernel module (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-find-platform_device-entry-from-a-kernel-module-4175480891/)

EschewPanache 10-15-2013 12:14 PM

How to find platform_device entry from a kernel module
 
Folks, I have a 3.10.12 kernel and have written a character device driver as a loadable kernel module. From within this driver I want to find a particular device, an LED, that I want to blink as I operate. This LED was registered using "platform_device_reqister". What I would like to do is enumerate all of the devices registered in this manner and find the one I want, but, I have been unable to discover how to start. There is a lot of documentation on the kernel objects, but nothing I can find on how to find a particular one.
I thank any responders in advance!
Peace,
carl.

kbp 10-21-2013 05:05 AM

Quote:

enumerate all of the devices registered in this manner and find the one I want
Did you mean programatically? You can make your device driver output it's major number with printk then just grep through all the devices in /dev to filter them. How are you defining "the one I want"?

EschewPanache 10-21-2013 07:07 AM

Thank you, and yes, I did mean programmatically. The particular "device" is an LED, and appears in /sys/class/leds, which I was hoping to parse from my character driver without needing to search a filesystem. I know the LED's name, and the kernel module that contains the function that will set the LED intensity. That function requires a "struct classled" that I don't know how to find.

kbp 10-21-2013 06:45 PM

I didn't find any reference to 'struct classled' .. only struct led_classdev, could you point me at a reference ?

EschewPanache 10-22-2013 06:58 AM

oops. Spelling
 
KBP, thank you, you are correct, that is struct led_classdev. This is openwrt source, leds.h, in the "...drivers/leds" directory. The inline _led_set_brightness function is called by led_set_brightness() defined in led-core.c, and THAT function is also helpfully exported, making me think someone would like me to use it!


All times are GMT -5. The time now is 08:56 AM.