diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-11-02 08:47:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:22 -0500 |
commit | 000f2a4d8cfc1e1cbc0aa98136015e7ae7719b46 (patch) | |
tree | f501a2d118797a88184a77be089d335c4cc48e88 | |
parent | 4443d07fcfab39c4d2d9d7711cff983f15b374fc (diff) |
Driver Core: kill subsys_attribute and default sysfs ops
Remove the no longer needed subsys_attributes, they are all converted to
the more sensical kobj_attributes.
There is no longer a magic fallback in sysfs attribute operations, all
kobjects which create simple attributes need explicitely a ktype
assigned, which tells the core what was intended here.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | fs/sysfs/file.c | 63 | ||||
-rw-r--r-- | include/linux/kobject.h | 9 | ||||
-rw-r--r-- | lib/kobject.c | 21 |
3 files changed, 10 insertions, 83 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 387a63662793..8acf82bba44c 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -20,43 +20,6 @@ | |||
20 | 20 | ||
21 | #include "sysfs.h" | 21 | #include "sysfs.h" |
22 | 22 | ||
23 | #define to_sattr(a) container_of(a,struct subsys_attribute, attr) | ||
24 | |||
25 | /* | ||
26 | * Subsystem file operations. | ||
27 | * These operations allow subsystems to have files that can be | ||
28 | * read/written. | ||
29 | */ | ||
30 | static ssize_t | ||
31 | subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page) | ||
32 | { | ||
33 | struct kset *kset = to_kset(kobj); | ||
34 | struct subsys_attribute * sattr = to_sattr(attr); | ||
35 | ssize_t ret = -EIO; | ||
36 | |||
37 | if (sattr->show) | ||
38 | ret = sattr->show(kset, page); | ||
39 | return ret; | ||
40 | } | ||
41 | |||
42 | static ssize_t | ||
43 | subsys_attr_store(struct kobject * kobj, struct attribute * attr, | ||
44 | const char * page, size_t count) | ||
45 | { | ||
46 | struct kset *kset = to_kset(kobj); | ||
47 | struct subsys_attribute * sattr = to_sattr(attr); | ||
48 | ssize_t ret = -EIO; | ||
49 | |||
50 | if (sattr->store) | ||
51 | ret = sattr->store(kset, page, count); | ||
52 | return ret; | ||
53 | } | ||
54 | |||
55 | static struct sysfs_ops subsys_sysfs_ops = { | ||
56 | .show = subsys_attr_show, | ||
57 | .store = subsys_attr_store, | ||
58 | }; | ||
59 | |||
60 | /* | 23 | /* |
61 | * There's one sysfs_buffer for each open file and one | 24 | * There's one sysfs_buffer for each open file and one |
62 | * sysfs_open_dirent for each sysfs_dirent with one or more open | 25 | * sysfs_open_dirent for each sysfs_dirent with one or more open |
@@ -354,29 +317,23 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
354 | { | 317 | { |
355 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; | 318 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
356 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; | 319 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
357 | struct sysfs_buffer * buffer; | 320 | struct sysfs_buffer *buffer; |
358 | struct sysfs_ops * ops = NULL; | 321 | struct sysfs_ops *ops; |
359 | int error; | 322 | int error = -EACCES; |
360 | 323 | ||
361 | /* need attr_sd for attr and ops, its parent for kobj */ | 324 | /* need attr_sd for attr and ops, its parent for kobj */ |
362 | if (!sysfs_get_active_two(attr_sd)) | 325 | if (!sysfs_get_active_two(attr_sd)) |
363 | return -ENODEV; | 326 | return -ENODEV; |
364 | 327 | ||
365 | /* if the kobject has no ktype, then we assume that it is a subsystem | 328 | /* every kobject with an attribute needs a ktype assigned */ |
366 | * itself, and use ops for it. | 329 | if (kobj->ktype && kobj->ktype->sysfs_ops) |
367 | */ | ||
368 | if (kobj->ktype) | ||
369 | ops = kobj->ktype->sysfs_ops; | 330 | ops = kobj->ktype->sysfs_ops; |
370 | else | 331 | else { |
371 | ops = &subsys_sysfs_ops; | 332 | printk(KERN_ERR "missing sysfs attribute operations for " |
372 | 333 | "kobject: %s\n", kobject_name(kobj)); | |
373 | error = -EACCES; | 334 | WARN_ON(1); |
374 | |||
375 | /* No sysfs operations, either from having no subsystem, | ||
376 | * or the subsystem have no operations. | ||
377 | */ | ||
378 | if (!ops) | ||
379 | goto err_out; | 335 | goto err_out; |
336 | } | ||
380 | 337 | ||
381 | /* File needs write support. | 338 | /* File needs write support. |
382 | * The inode's perms must say it's ok, | 339 | * The inode's perms must say it's ok, |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 29dc444e3361..29841bb5badb 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -216,15 +216,6 @@ extern struct kset *firmware_kset; | |||
216 | extern int __must_check subsystem_register(struct kset *); | 216 | extern int __must_check subsystem_register(struct kset *); |
217 | extern void subsystem_unregister(struct kset *); | 217 | extern void subsystem_unregister(struct kset *); |
218 | 218 | ||
219 | struct subsys_attribute { | ||
220 | struct attribute attr; | ||
221 | ssize_t (*show)(struct kset *, char *); | ||
222 | ssize_t (*store)(struct kset *, const char *, size_t); | ||
223 | }; | ||
224 | |||
225 | extern int __must_check subsys_create_file(struct kset *, | ||
226 | struct subsys_attribute *); | ||
227 | |||
228 | #if defined(CONFIG_HOTPLUG) | 219 | #if defined(CONFIG_HOTPLUG) |
229 | int kobject_uevent(struct kobject *kobj, enum kobject_action action); | 220 | int kobject_uevent(struct kobject *kobj, enum kobject_action action); |
230 | int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | 221 | int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, |
diff --git a/lib/kobject.c b/lib/kobject.c index 99f6354a5751..c742ac25228a 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -810,26 +810,6 @@ void subsystem_unregister(struct kset *s) | |||
810 | kset_unregister(s); | 810 | kset_unregister(s); |
811 | } | 811 | } |
812 | 812 | ||
813 | /** | ||
814 | * subsystem_create_file - export sysfs attribute file. | ||
815 | * @s: subsystem. | ||
816 | * @a: subsystem attribute descriptor. | ||
817 | */ | ||
818 | |||
819 | int subsys_create_file(struct kset *s, struct subsys_attribute *a) | ||
820 | { | ||
821 | int error = 0; | ||
822 | |||
823 | if (!s || !a) | ||
824 | return -EINVAL; | ||
825 | |||
826 | if (kset_get(s)) { | ||
827 | error = sysfs_create_file(&s->kobj, &a->attr); | ||
828 | kset_put(s); | ||
829 | } | ||
830 | return error; | ||
831 | } | ||
832 | |||
833 | static void kset_release(struct kobject *kobj) | 813 | static void kset_release(struct kobject *kobj) |
834 | { | 814 | { |
835 | struct kset *kset = container_of(kobj, struct kset, kobj); | 815 | struct kset *kset = container_of(kobj, struct kset, kobj); |
@@ -927,4 +907,3 @@ EXPORT_SYMBOL(kset_unregister); | |||
927 | 907 | ||
928 | EXPORT_SYMBOL(subsystem_register); | 908 | EXPORT_SYMBOL(subsystem_register); |
929 | EXPORT_SYMBOL(subsystem_unregister); | 909 | EXPORT_SYMBOL(subsystem_unregister); |
930 | EXPORT_SYMBOL(subsys_create_file); | ||