On Fri, 2 Nov 2007 16:59:12 -0700, Greg Kroah-Hartman <gregkh@suse.de> wrote:How about adding some simple wrappers around the new kobj_attribute structure? This makes the layering clearer. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> --- include/linux/kobject.h | 7 ++++++- lib/kobject.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) Index: linux-2.6/include/linux/kobject.h =================================================================== --- linux-2.6.orig/include/linux/kobject.h 2007-11-05 11:12:49.000000000 +0100 +++ linux-2.6/include/linux/kobject.h 2007-11-05 13:24:55.000000000 +0100 @@ -126,7 +126,12 @@ struct kobj_attribute { ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count); }; - +#define KOBJ_ATTR(_name,_mode,_show,_store) \ + struct kobj_attribute kobj_attr_##_name = \ + __ATTR(_name,_mode,_show,_store) +extern int __must_check kobject_create_file(struct kobject *, + struct kobj_attribute *); +extern void kobject_remove_file(struct kobject *,struct kobj_attribute *); extern struct sysfs_ops kobj_sysfs_ops; /** Index: linux-2.6/lib/kobject.c =================================================================== --- linux-2.6.orig/lib/kobject.c 2007-11-05 11:12:49.000000000 +0100 +++ linux-2.6/lib/kobject.c 2007-11-05 13:36:45.000000000 +0100 @@ -577,6 +577,28 @@ struct sysfs_ops kobj_sysfs_ops = { .store = kobj_attr_store, }; +/** + * kobject_create_file() - create an attribute file for a kobject + * @kobj: kobject the attribute is created for + * @attr: attribute to be created + */ +int kobject_create_file(struct kobject *kobj, struct kobj_attribute *attr) +{ + return sysfs_create_file(kobj, &attr->attr); +} +EXPORT_SYMBOL_GPL(kobject_create_file); + +/** + * kobject_remove_file() - remove an attribute file from a kobject + * @kobj: kobject the attribute is removed from + * @attr: attribute to be removed + */ +void kobject_remove_file(struct kobject *kobj, struct kobj_attribute *attr) +{ + sysfs_remove_file(kobj, &attr->attr); +} +EXPORT_SYMBOL_GPL(kobject_remove_file); + static void dir_release(struct kobject *kobj) { kfree(kobj); -
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Eric Sandeen | Re: [RFC] Heads up on sys_fallocate() |
git: | |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Antonio Almeida | HTB accuracy for high speed |
