Skip to contentSkip to conversation

include/linux:(dynamic sysfs callbacks) new attribute macros

PATCH New Yani Ioannou 1 participant 1 message May 14, 2005 Driver core

lore
Share & tools
lore
#0 lore raw

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.

Thanks,
Yani

---
 device.h |    3 +++
 sysfs.h  |   11 +++++++++++
 2 files changed, 14 insertions(+)

---

include/linux/device.h +3 -0
diff -uprN -X dontdiff linux-2.6.12-rc4-sysfsdyncallback-deviceattr/include/linux/device.h linux-2.6.12-rc4-sysfsdyncallback-deviceattr-macro/include/linux/device.h
@@ -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
diff -uprN -X dontdiff linux-2.6.12-rc4-sysfsdyncallback-deviceattr/include/linux/sysfs.h linux-2.6.12-rc4-sysfsdyncallback-deviceattr-macro/include/linux/sysfs.h
@@ -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),	\