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

Bagalkote, Sreenivas
2005-07-08T22:18:31Z

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