* [SYSFS QUESTION] How to add new sysfs attributes under /sys/modul e/<my module>
@ 2005-07-08 22:13 Bagalkote, Sreenivas
2005-07-09 15:59 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Bagalkote, Sreenivas @ 2005-07-08 22:13 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org'
Cc: 'Matt Domsch', 'Christoph Hellwig'
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>
2. When I used sysfs_create_file() on pci_driver.driver.kobj, the new
attribute
shows up under /sys/pci/drivers/<my driver>/ directory. But how do I
associate
my own show and store to this object?
I overwrote pci_driver.driver.kobj.ktype->sysfs_ops pointer with my own
sysfs_ops
structure pointer. When I cat the new attribute, I get a call to my show
attribute.
However, nothing seems to happen. The struct attribute.name that is passed
to my
show routine is NULL.
What am I doing wrong? Moreover, is it okay to overwrite the default
sysfs_ops
like this? I appreciate any help.
Sincerely,
Sreenivas
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [SYSFS QUESTION] How to add new sysfs attributes under /sys/modul e/<my module>
2005-07-08 22:13 [SYSFS QUESTION] How to add new sysfs attributes under /sys/modul e/<my module> Bagalkote, Sreenivas
@ 2005-07-09 15:59 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2005-07-09 15:59 UTC (permalink / raw)
To: Bagalkote, Sreenivas
Cc: 'linux-kernel@vger.kernel.org', 'Matt Domsch',
'Christoph Hellwig'
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-09 16:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-08 22:13 [SYSFS QUESTION] How to add new sysfs attributes under /sys/modul e/<my module> Bagalkote, Sreenivas
2005-07-09 15:59 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox