Re: [PATCH] exporting capability code/name pairs (try #6.1)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Kohei KaiGai
Date: Tuesday, February 19, 2008 - 11:16 pm

[Sorry, I sent a patch with TABs translated into spaces.]

[1/3] Add a private data field within kobj_attribute structure.

This patch add a private data field, declared as void *, within kobj_attribute
structure. Anyone wants to use sysfs can store their private data to refer at
_show() and _store() method.
It enables to share a single method function with several similar entries,
like ones to export the list of capabilities the running kernel supported.

Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
-- 
 include/linux/kobject.h |    1 +
 include/linux/sysfs.h   |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index caa3f41..57d5bf1 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -130,6 +130,7 @@ struct kobj_attribute {
 			char *buf);
 	ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
 			 const char *buf, size_t count);
+	void *data;	/* a private field */
 };

 extern struct sysfs_ops kobj_sysfs_ops;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 8027104..6f40ff9 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -50,6 +50,13 @@ struct attribute_group {
 	.store	= _store,					\
 }

+#define __ATTR_DATA(_name,_mode,_show,_store,_data) {		\
+	.attr = {.name = __stringify(_name), .mode = _mode },   \
+	.show	= _show,					\
+	.store	= _store,					\
+	.data	= (void *)(_data),				\
+}
+	
 #define __ATTR_RO(_name) { \
 	.attr	= { .name = __stringify(_name), .mode = 0444 },	\
 	.show	= _name##_show,					\

-- 
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/3] exporting capability code/name pairs (try 2nd), Andrew G. Morgan, (Fri Jan 25, 12:32 am)
[PATCH] exporting capability code/name pairs (try #4), Kohei KaiGai, (Fri Feb 8, 2:42 am)
Re: [PATCH] exporting capability code/name pairs (try #4), Andrew G. Morgan, (Fri Feb 8, 9:48 am)
Re: [PATCH] exporting capability code/name pairs (try #4), Alexey Dobriyan, (Fri Feb 8, 12:23 pm)
Re: [PATCH] exporting capability code/name pairs (try #4), Serge E. Hallyn, (Tue Feb 12, 11:08 am)
Re: [PATCH] exporting capability code/name pairs (try #4), Alexey Dobriyan, (Tue Feb 12, 2:58 pm)
[PATCH] exporting capability code/name pairs (try #5), Kohei KaiGai, (Thu Feb 14, 6:38 pm)
Re: [PATCH] exporting capability code/name pairs (try #5.1), Serge E. Hallyn, (Fri Feb 15, 11:38 am)
Re: [PATCH] exporting capability code/name pairs (try #5.1), Serge E. Hallyn, (Mon Feb 18, 8:15 am)
[PATCH] exporting capability code/name pairs (try #6), Kohei KaiGai, (Tue Feb 19, 9:38 pm)
[PATCH] exporting capability code/name pairs (try #6), Kohei KaiGai, (Tue Feb 19, 9:39 pm)
Re: [PATCH] exporting capability code/name pairs (try #6), Kohei KaiGai, (Tue Feb 19, 10:38 pm)
Re: [PATCH] exporting capability code/name pairs (try #6.1), Kohei KaiGai, (Tue Feb 19, 11:16 pm)