I am working on a driver that creates a sysfs attribute file. It is intended that an application be notified of changes to this attribute by using the poll()
method. I intend to use the sysfs_notify()
function for this. This is easy to do as long as you have the kobject
for the attribute (sysfs_notify()
requires that as the first parameter). Getting the kobject
is easy enough if using sysfs_create_file()
and related functions.
I read this post on correctly creating a sysfs file that solves a possible race condition between userspace notification that the device is present, and the creation of the sysfs files. This solution is also much cleaner.
However, I cannot figure out how to get the kobject
for each of the attributes (or parent) that I can use in sysfs_notify()
. At one point structures such as struct device_driver
had a member of struct kobject kobj;
. That was replaced (10ish years ago) with struct driver_private *p;
. This private structure now contains the actual kobject
and is not available for use.
Is there a new form of sysfs_notify()
that I can use, or is there another way of getting the correct kobject
? I may have to go back to "manually" creating the sysfs attribute otherwise.
platform_driver
andmiscdevice
. – Randirandie