How to find platform_device entry from a kernel module
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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"?
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, 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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.