(dynamic sysfs callbacks) device_attribute
PATCH 1/3 (dynamic sysfs callbacks) device_attribute
Hi,
This patch adds support to the sysfs device_attribute to pass the new void * attribute member to it's callback functions. The device attribute will benefit the most from the dynamic sysfs callback patch compared to the other attributes simply because of it's greater usage.
The first patch simply adds the void * parameter to the device attribute function types and passes them when calling the callbacks.
Signed-off-by Yani Ioannou <[email protected]>
Thanks,
Yani
--- drivers/base/core.c | 4 ++-- include/linux/device.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/base/core.c +2 -2
@@ -41,7 +41,7 @@ dev_attr_show(struct kobject * kobj, strssize_t ret =0 ;if (dev_attr->show) - ret = dev_attr->show (dev, buf); + ret = dev_attr->show (dev, buf, attr->private);return ret; }
@@ -54,7 +54,7 @@ dev_attr_store(struct kobject * kobj, stssize_t ret =0 ;if (dev_attr->store) - ret = dev_attr->store (dev, buf, count); + ret = dev_attr->store (dev, buf, count, attr->private);return ret; }
include/linux/device.h +3 -2
@@ -335,8 +335,9 @@ extern void driver_attach(struct device_struct device_attribute {struct attribute attr; -ssize_t (*show)(struct device * dev,char * buf); -ssize_t (*store)(struct device * dev,const char * buf,size_t count); +ssize_t (*show)(struct device * dev,char * buf,void * private); +ssize_t (*store)(struct device * dev,const char * buf,size_t count, +void * private); };#define DEVICE_ATTR (_name,_mode,_show,_store) \