Can't find kobject for use in sysfs_notify()
Asked Answered
H

0

6

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.

Hunan answered 27/10, 2016 at 23:50 Comment(1)
It's probably an old question, but I can answer this about platform_driver and miscdevice.Randirandie

© 2022 - 2024 — McMap. All rights reserved.