include/linux:(dynamic sysfs callbacks) new attribute macros
PATCH 1/1 include/linux:(dynamic sysfs callbacks) new attribute macros
Hi,
The following patch adds a new __ATTR_PRIVATE macro and a DEVICE_ATTR_PRIVATE macro to be used when creating static device attributes with a void * member.
Signed-off-by Yani Ioannou <[email protected]>
Thanks,
Yani
--- device.h | 3 +++ sysfs.h | 11 +++++++++++ 2 files changed, 14 insertions(+)
---
include/linux/device.h +3 -0
@@ -343,6 +343,9 @@ struct device_attribute {#define DEVICE_ATTR (_name,_mode,_show,_store) \ struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) +#define DEVICE_ATTR_PRIVATE (_name,_mode,_show,_store,_private) \ +struct device_attribute dev_attr_##_name = \ + __ATTR_PRIVATE(_name,_mode,_show,_store,_private)extern int device_create_file (struct device *device,struct device_attribute * entry);extern void device_remove_file (struct device * dev,struct device_attribute * attr);
include/linux/sysfs.h +11 -0
@@ -45,6 +45,17 @@ struct attribute_group { .store = _store, \ } +#define __ATTR_PRIVATE (_name,_mode,_show,_store,_private) { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + .private = _private, \ + .owner = THIS_MODULE, \ + }, \ + .show = _show, \ + .store = _store, \ +} +#define __ATTR_RO (_name) { \ .attr = { \ .name = __stringify(_name), \