Creation of driver-specific sysfs attributes
Hi Greg, others,
Hope this is not a FAQ.
I want to export some read-only attributes (statistics) from cyclades.c char driver to userspace via sysfs.
I can't figure out the right place to do it - I could create a class under /sys/class/cyclades for example, but that doesnt sound right since this is not a "class" of device, but a device itself.
Hooking the statistics into /sys/class/tty/ttyC$/ sounds reasonable, but its not possible it seems because "tty" is a class_simple class, which only implements the "dev" attribute.
What is the appropriate place for such driver-specific attributes?
TIA
Quoted 10 lines · Marcelo Tosatti
Hi Greg, others,
Hope this is not a FAQ.
I want to export some read-only attributes (statistics) from
cyclades.cchar driver to userspace via sysfs.I can't figure out the right place to do it - I could create a class under
/sys/class/cycladesfor example, but that doesnt sound right since this is not a "class" of device, but a device itself.
For a driver only attribute, you want them to show up in the place for the driver (like under /sys/bus/pci/driver/MY_FOO_DRIVER/). To do that use the DRIVER_ATTR() and the driver_add_file() functions. For examples, see the other drivers that use these functions.
Hope this helps,
greg k-h