driverfs: define struct driverfs_ops and remove struct device dependencies
In order to read/write attributes, you have to deal directly with the object that owns them. driverfs really wants to be generic and not deal directly with those objects. So, we create an intermediate layer that subsystems must implement that converts between the generic objects and the specific objects that own the attributes. This allows allows attributes to be exported for any object type. In doing so, it places the responsibility on the subsystems to do the following: - define their own object-specific attribute structures - define their own driverfs_ops - set the ops pointer in struct driver_dir_entry when creating an object's directory - do object reference counting on open() and close() - call the show() and store() callbacks of their attribute structure - convert between the generic objects and the specific objects from the struct driver_dir_entry and struct attribute pointers (using container_of) The implementation of this layer for struct device is intended to be used as an example of the interface. Because this layer of abstraction is now in place, we can move the device attribute structure into include/linux/device.h, and driverfs should be free of references to it completely.
Showing
Please register or sign in to comment