Re: [SYSFS QUESTION] How to add new sysfs attributes under /sys/modul e/

Greg KH
2005-07-09T16:01:15Z

On Fri, Jul 08, 2005 at 06:13:38PM -0400, Bagalkote, Sreenivas wrote:
> Sysfs Gurus,
>
> I want to export few driver specific sysfs attributes when my driver loads.
> This driver is a pci hotplug driver. I want to export these sysfs attributes
> as soon as my pci_module_init succeeds.
>
> 1. I see that there is /sys/modules directory lists all the modules. Is this
> a right place to have such information? Is this only for the insmod'ed
> modules?
> After pci_module_init, I have struct pci_driver object that gives me
> kobject.
> (pci_driver.driver.kobj). But from this kobject, I couldn't find a way to
> reach /sys/modules/<my driver kobject>

No, use DRIVER_ATTR() and put it in your driver directory instead.

See the many other drivers that do this as examples.

For more details see the book, Linux Device Drivers, Third edition.
It's online for free if you don't wish to buy it.

Hope this helps,

greg k-h