So, I go on vacation for a week or so and come back to an overflowing inbox. Instead of trying to wade through all of that, I decide to finish up the work Kay and I had started on cleaning up the kset core code. Here's a large patch series that is in my tree and should be for 2.6.25. It does quite a few things: - lots of struct kset work and cleanup. It's much simpler now and will be documented while I still remember what is going one... - almost all (only 5 left) struct kset are dynamically created with the new function call, kset_create_and_register(). This fixes up a lot of issues with static kobjects in structures and other messy things like that. - struct bus_type is now split into two, a static and a dynamic part. The dynamic part is under control of the driver core, and handles the ksets. The static part is under control of the bus that defined it. - decl_subsys() is now gone and buried, good riddance - subsys_attribute is now gone and replaced with: - kobj_attribute is now availble to make attributes for kobjects MUCH simpler than ever before. I've cleaned up some portions of the kernel, and all older users of subsys_attribute have been fixed. This takes away one of the biggest complaints about dealing with "raw" kobjects. - firmware subsystem has been all but removed as it was pointless. I'm posting the patches here so that people can take a look at them and not be surprised when they go in to 2.6.25 in a few months and show up in the next -mm releases. One note, the efivars sysfs file removal patch is incorrect, and I'll be fixing that up properly, so Matt, don't worry, I haven't forgotten :) And hey, with all this work, we ended up removing more code than we added, always a very good thing. Now, on to face that scary inbox... thanks, greg k-h --------------- Documentation/vm/slabinfo.c | 2 +- Documentation/vm/slub.txt | 2 +- arch/arm/mach-omap1/pm.c ...
It isn't that hard to add simple kset attributes, so don't go through
all the gyrations of creating your own object type and show and store
functions. Just use the functions that are already present. This makes
things much simpler.
Note, the version_str string violates the "one value per file" rule for
sysfs. I suggest changing this now (individual files per type supported
is one suggested way.)
Cc: Michael A. Halcrow <mahalcro@us.ibm.com>
Cc: Michael C. Thompson <mcthomps@us.ibm.com>
Cc: Tyler Hicks <tyhicks@ou.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/main.c | 85 +++++++++++-----------------------------------------
1 files changed, 18 insertions(+), 67 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index b83a512..82b34f2 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -730,58 +730,14 @@ static int ecryptfs_init_kmem_caches(void)
return 0;
}
-struct ecryptfs_obj {
- char *name;
- struct list_head slot_list;
- struct kobject kobj;
-};
-
-struct ecryptfs_attribute {
- struct attribute attr;
- ssize_t(*show) (struct ecryptfs_obj *, char *);
- ssize_t(*store) (struct ecryptfs_obj *, const char *, size_t);
-};
-
-static ssize_t
-ecryptfs_attr_store(struct kobject *kobj,
- struct attribute *attr, const char *buf, size_t len)
-{
- struct ecryptfs_obj *obj = container_of(kobj, struct ecryptfs_obj,
- kobj);
- struct ecryptfs_attribute *attribute =
- container_of(attr, struct ecryptfs_attribute, attr);
-
- return (attribute->store ? attribute->store(obj, buf, len) : 0);
-}
-
-static ssize_t
-ecryptfs_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
-{
- struct ecryptfs_obj *obj = container_of(kobj, struct ecryptfs_obj,
- kobj);
- struct ecryptfs_attribute *attribute =
- container_of(attr, struct ecryptfs_attribute, attr);
-
- return (attribute->show ? attribute->show(obj, buf) : 0);
-}
-
-static struct sysfs_ops ecryptfs_sysfs_ops = {
- .show = ...We don't need a "default" ktype for a kset. We should set this explicitly every time for each kset. This change is needed so that we can make ksets dynamic, and cleans up one of the odd, undocumented assumption that the kset/kobject/ktype model has. This patch is based on a lot of help from Kay Sievers. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- arch/powerpc/platforms/pseries/power.c | 2 +- arch/s390/hypfs/inode.c | 4 ++-- arch/s390/kernel/ipl.c | 8 ++++---- block/genhd.c | 5 +++-- drivers/acpi/bus.c | 2 +- drivers/base/bus.c | 5 +++-- drivers/base/class.c | 8 +++++--- drivers/base/core.c | 5 +++-- drivers/base/firmware.c | 5 +++-- drivers/base/hypervisor.c | 2 +- drivers/base/sys.c | 3 ++- drivers/edac/edac_mc_sysfs.c | 2 +- drivers/firmware/edd.c | 5 +++-- drivers/firmware/efivars.c | 9 +++++---- drivers/parisc/pdc_stable.c | 9 +++++---- drivers/pci/hotplug/pci_hotplug_core.c | 7 ++++--- drivers/uio/uio.c | 2 +- fs/configfs/mount.c | 4 ++-- fs/debugfs/inode.c | 4 ++-- fs/dlm/lockspace.c | 6 ++---- fs/ecryptfs/main.c | 4 ++-- fs/fuse/inode.c | 8 ++++---- fs/gfs2/locking/dlm/sysfs.c | 6 ++---- fs/gfs2/sys.c | 6 ++---- fs/namespace.c | 2 +- fs/ocfs2/cluster/masklog.c | 2 +- fs/ocfs2/cluster/sys.c | 2 +- fs/sysfs/file.c | 4 +--- include/linux/kobject.h | 15 ++++----------- kernel/ksysfs.c | 2 +- ...
What a confusing name for a macro... Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- include/linux/kobject.h | 18 ------------------ 1 files changed, 0 insertions(+), 18 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 4dcf478..4e8a542 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -195,24 +195,6 @@ extern struct kset kernel_subsys; /* The global /sys/hypervisor/ subsystem */ extern struct kset hypervisor_subsys; -/* - * Helpers for setting the kset of registered objects. - * Often, a registered object belongs to a kset embedded in a - * subsystem. These do no magic, just make the resulting code - * easier to follow. - */ - -/** - * kobj_set_kset_s(obj,subsys) - set kset for embedded kobject. - * @obj: ptr to some object type. - * @subsys: a subsystem object (not a ptr). - * - * Can be used for any object type with an embedded ->kobj. - */ - -#define kobj_set_kset_s(obj,subsys) \ - (obj)->kobj.kset = &(subsys) - extern int __must_check subsystem_register(struct kset *); extern void subsystem_unregister(struct kset *); -- 1.5.3.4 -
Now ksets can be dynamically created on the fly, no static definitions
are required. Thanks to Miklos for hints on how to make this work
better for the callers.
And thanks to Kay for finding some stupid bugs in my original version.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/kobject.h | 5 ++-
lib/kobject.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 1 deletions(-)
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 4e8a542..205d186 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -143,11 +143,14 @@ struct kset {
struct kset_uevent_ops *uevent_ops;
};
-
extern void kset_init(struct kset * k);
extern int __must_check kset_add(struct kset * k);
extern int __must_check kset_register(struct kset * k);
extern void kset_unregister(struct kset * k);
+extern struct kset * __must_check kset_create_and_register(const char *name,
+ struct kset_uevent_ops *u,
+ struct kobject *parent_kobj,
+ struct kset *parent_kset);
static inline struct kset * to_kset(struct kobject * kobj)
{
diff --git a/lib/kobject.c b/lib/kobject.c
index a7e3bf4..725fe2e 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -13,6 +13,7 @@
*/
#include <linux/kobject.h>
+#include <linux/err.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/stat.h>
@@ -662,6 +663,96 @@ int subsys_create_file(struct kset *s, struct subsys_attribute *a)
return error;
}
+static void kset_release(struct kobject *kobj)
+{
+ struct kset *kset = container_of(kobj, struct kset, kobj);
+ pr_debug("kset %s: now freed\n", kobject_name(kobj));
+ kfree(kset);
+}
+
+static struct kobj_type kset_type = {
+ .release = kset_release,
+};
+
+/**
+ * kset_create - create a struct kset dynamically
+ *
+ * @name: the name for the kset
+ * @uevent_ops: a ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/fuse/inode.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 2df24c6..ca80a7b 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -744,9 +744,6 @@ static inline void unregister_fuseblk(void)
}
#endif
-static decl_subsys(fuse, NULL);
-static decl_subsys(connections, NULL);
-
static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo)
{
struct inode * inode = foo;
@@ -791,32 +788,38 @@ static void fuse_fs_cleanup(void)
kmem_cache_destroy(fuse_inode_cachep);
}
+static struct kset *fuse_kset;
+static struct kset *connections_kset;
+
static int fuse_sysfs_init(void)
{
int err;
- fuse_subsys.kobj.kset = &fs_subsys;
- err = subsystem_register(&fuse_subsys);
- if (err)
+ fuse_kset = kset_create_and_register("fuse", NULL, NULL, &fs_subsys);
+ if (IS_ERR(fuse_kset)) {
+ err = PTR_ERR(fuse_kset);
goto out_err;
+ }
- connections_subsys.kobj.kset = &fuse_subsys;
- err = subsystem_register(&connections_subsys);
- if (err)
+ connections_kset = kset_create_and_register("connections", NULL,
+ NULL, fuse_kset);
+ if (IS_ERR(connections_kset)) {
+ err = PTR_ERR(connections_kset);
goto out_fuse_unregister;
+ }
return 0;
out_fuse_unregister:
- subsystem_unregister(&fuse_subsys);
+ kset_unregister(fuse_kset);
out_err:
return err;
}
static void fuse_sysfs_cleanup(void)
{
- subsystem_unregister(&connections_subsys);
- subsystem_unregister(&fuse_subsys);
+ kset_unregister(connections_kset);
+ kset_unregister(fuse_kset);
}
static int __init fuse_init(void)
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/debugfs/inode.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index f7f1351..9f8af79 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -426,20 +426,20 @@ exit:
}
EXPORT_SYMBOL_GPL(debugfs_rename);
-static decl_subsys(debug, NULL);
+static struct kset *debug_kset;
static int __init debugfs_init(void)
{
int retval;
- debug_subsys.kobj.kset = &kernel_subsys;
- retval = subsystem_register(&debug_subsys);
- if (retval)
- return retval;
+ debug_kset = kset_create_and_register("debug", NULL,
+ NULL, &kernel_subsys);
+ if (IS_ERR(debug_kset))
+ return PTR_ERR(debug_kset);
retval = register_filesystem(&debug_fs_type);
if (retval)
- subsystem_unregister(&debug_subsys);
+ kset_unregister(debug_kset);
return retval;
}
@@ -447,7 +447,7 @@ static void __exit debugfs_exit(void)
{
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
unregister_filesystem(&debug_fs_type);
- subsystem_unregister(&debug_subsys);
+ kset_unregister(debug_kset);
}
core_initcall(debugfs_init);
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/configfs/mount.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 374ddbd..8674e6d 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -128,7 +128,7 @@ void configfs_release_fs(void)
}
-static decl_subsys(config, NULL);
+static struct kset *config_kset;
static int __init configfs_init(void)
{
@@ -140,9 +140,9 @@ static int __init configfs_init(void)
if (!configfs_dir_cachep)
goto out;
- config_subsys.kobj.kset = &kernel_subsys;
- err = subsystem_register(&config_subsys);
- if (err) {
+ config_kset = kset_create_and_register("config", NULL,
+ NULL, &kernel_subsys);
+ if (IS_ERR(config_kset)) {
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
goto out;
@@ -151,7 +151,7 @@ static int __init configfs_init(void)
err = register_filesystem(&configfs_fs_type);
if (err) {
printk(KERN_ERR "configfs: Unable to register filesystem!\n");
- subsystem_unregister(&config_subsys);
+ kset_unregister(config_kset);
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
goto out;
@@ -160,7 +160,7 @@ static int __init configfs_init(void)
err = configfs_inode_init();
if (err) {
unregister_filesystem(&configfs_fs_type);
- subsystem_unregister(&config_subsys);
+ kset_unregister(config_kset);
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
}
@@ -171,7 +171,7 @@ out:
static void __exit configfs_exit(void)
{
unregister_filesystem(&configfs_fs_type);
- subsystem_unregister(&config_subsys);
+ kset_unregister(config_kset);
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
configfs_inode_exit();
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
security/inode.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/security/inode.c b/security/inode.c
index 9e42f5f..9071d81 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -315,20 +315,20 @@ void securityfs_remove(struct dentry *dentry)
}
EXPORT_SYMBOL_GPL(securityfs_remove);
-static decl_subsys(security, NULL);
+static struct kset *security_kset;
static int __init securityfs_init(void)
{
int retval;
- security_subsys.kobj.kset = &kernel_subsys;
- retval = subsystem_register(&security_subsys);
- if (retval)
- return retval;
+ security_kset = kset_create_and_register("security", NULL, NULL,
+ &kernel_subsys);
+ if (IS_ERR(security_kset))
+ return PTR_ERR(security_kset);
retval = register_filesystem(&fs_type);
if (retval)
- subsystem_unregister(&security_subsys);
+ kset_unregister(security_kset);
return retval;
}
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mike Halcrow <mhalcrow@us.ibm.com>
Cc: Phillip Hellewell <phillip@hellewell.homeip.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/main.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 18ab012..5bfdf96 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -730,7 +730,7 @@ static int ecryptfs_init_kmem_caches(void)
return 0;
}
-static decl_subsys(ecryptfs, NULL);
+static struct kset *ecryptfs_kset;
static ssize_t version_show(struct kset *kset, char *buff)
{
@@ -794,18 +794,18 @@ static int do_sysfs_registration(void)
{
int rc;
- ecryptfs_subsys.kobj.kset = &fs_subsys;
- rc = subsystem_register(&ecryptfs_subsys);
- if (rc) {
- printk(KERN_ERR
- "Unable to register ecryptfs sysfs subsystem\n");
+ ecryptfs_kset = kset_create_and_register("ecryptfs", NULL,
+ NULL, &fs_subsys);
+ if (IS_ERR(ecryptfs_kset)) {
+ printk(KERN_ERR "Unable to create ecryptfs kset\n");
+ rc = PTR_ERR(ecryptfs_kset);
goto out;
}
- rc = sysfs_create_group(&ecryptfs_subsys.kobj, &attr_group);
+ rc = sysfs_create_group(&ecryptfs_kset->kobj, &attr_group);
if (rc) {
printk(KERN_ERR
"Unable to create ecryptfs version attributes\n");
- subsystem_unregister(&ecryptfs_subsys);
+ subsystem_unregister(ecryptfs_kset);
}
out:
return rc;
@@ -813,8 +813,8 @@ out:
static void do_sysfs_unregistration(void)
{
- sysfs_remove_group(&ecryptfs_subsys.kobj, &attr_group);
- subsystem_unregister(&ecryptfs_subsys);
+ sysfs_remove_group(&ecryptfs_kset->kobj, &attr_group);
+ subsystem_unregister(ecryptfs_kset);
}
static int __init ecryptfs_init(void)
--
1.5.3.4
-
This also renames fs_subsys to fs_kset to catch all current users with a
build error instead of a build warning which can easily be missed.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/main.c | 2 +-
fs/fuse/inode.c | 2 +-
fs/gfs2/sys.c | 2 +-
fs/namespace.c | 14 ++++++++------
include/linux/fs.h | 2 +-
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 5bfdf96..b72a495 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -795,7 +795,7 @@ static int do_sysfs_registration(void)
int rc;
ecryptfs_kset = kset_create_and_register("ecryptfs", NULL,
- NULL, &fs_subsys);
+ NULL, fs_kset);
if (IS_ERR(ecryptfs_kset)) {
printk(KERN_ERR "Unable to create ecryptfs kset\n");
rc = PTR_ERR(ecryptfs_kset);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index ca80a7b..665c732 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -795,7 +795,7 @@ static int fuse_sysfs_init(void)
{
int err;
- fuse_kset = kset_create_and_register("fuse", NULL, NULL, &fs_subsys);
+ fuse_kset = kset_create_and_register("fuse", NULL, NULL, fs_kset);
if (IS_ERR(fuse_kset)) {
err = PTR_ERR(fuse_kset);
goto out_err;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index d7fa544..dab7d9d 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -549,7 +549,7 @@ int gfs2_sys_init(void)
gfs2_sys_margs = NULL;
spin_lock_init(&gfs2_sys_margs_lock);
kobject_set_name(&gfs2_kset.kobj, "gfs2");
- gfs2_kset.kobj.kset = &fs_subsys;
+ gfs2_kset.kobj.kset = fs_kset;
return kset_register(&gfs2_kset);
}
diff --git a/fs/namespace.c b/fs/namespace.c
index a4a3f70..fa352e8 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -41,8 +41,8 @@ static struct kmem_cache *mnt_cache __read_mostly;
static struct rw_semaphore namespace_sem;
/* /sys/fs */
-decl_subsys(fs, NULL);
-EXPORT_SYMBOL_GPL(fs_subsys);
+struct kset ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/gfs2/sys.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index dab7d9d..222dd8d 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -221,7 +221,7 @@ static struct kobj_type gfs2_ktype = {
.sysfs_ops = &gfs2_attr_ops,
};
-static struct kset gfs2_kset;
+static struct kset *gfs2_kset;
/*
* display struct lm_lockstruct fields
@@ -493,7 +493,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
{
int error;
- sdp->sd_kobj.kset = &gfs2_kset;
+ sdp->sd_kobj.kset = gfs2_kset;
sdp->sd_kobj.ktype = &gfs2_ktype;
error = kobject_set_name(&sdp->sd_kobj, "%s", sdp->sd_table_name);
@@ -548,14 +548,15 @@ int gfs2_sys_init(void)
{
gfs2_sys_margs = NULL;
spin_lock_init(&gfs2_sys_margs_lock);
- kobject_set_name(&gfs2_kset.kobj, "gfs2");
- gfs2_kset.kobj.kset = fs_kset;
- return kset_register(&gfs2_kset);
+ gfs2_kset = kset_create_and_register("gfs2", NULL, NULL, fs_kset);
+ if (IS_ERR(gfs2_kset))
+ return PTR_ERR(gfs2_kset);
+ return 0;
}
void gfs2_sys_uninit(void)
{
kfree(gfs2_sys_margs);
- kset_unregister(&gfs2_kset);
+ kset_unregister(gfs2_kset);
}
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/gfs2/locking/dlm/sysfs.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 93e66b2..9c351db 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -189,7 +189,7 @@ static struct kobj_type gdlm_ktype = {
.sysfs_ops = &gdlm_attr_ops,
};
-static struct kset gdlm_kset;
+static struct kset *gdlm_kset;
int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
{
@@ -201,7 +201,7 @@ int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
return error;
}
- ls->kobj.kset = &gdlm_kset;
+ ls->kobj.kset = gdlm_kset;
ls->kobj.ktype = &gdlm_ktype;
ls->kobj.parent = fskobj;
@@ -221,17 +221,19 @@ int gdlm_sysfs_init(void)
{
int error;
- kobject_set_name(&gdlm_kset.kobj, "lock_dlm");
- gdlm_kset.kobj.kset = &kernel_subsys;
- error = kset_register(&gdlm_kset);
- if (error)
- printk("lock_dlm: cannot register kset %d\n", error);
-
- return error;
+ gdlm_kset = kset_create_and_register("lock_dlm", NULL,
+ NULL, &kernel_subsys);
+ if (IS_ERR(gdlm_kset)) {
+ error = PTR_ERR(gdlm_kset);
+ printk(KERN_WARNING "%s: can not create kset %d\n",
+ __FUNCTION__, error);
+ return error;
+ }
+ return 0;
}
void gdlm_sysfs_exit(void)
{
- kset_unregister(&gdlm_kset);
+ kset_unregister(gdlm_kset);
}
--
1.5.3.4
-
This also renames pci_hotplug_slots_subsys to pcis_hotplug_slots_kset
catch all current users with a build error instead of a build warning
which can easily be missed.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/hotplug/acpiphp_ibm.c | 4 ++--
drivers/pci/hotplug/pci_hotplug_core.c | 21 ++++++++++-----------
drivers/pci/hotplug/rpadlpar_sysfs.c | 2 +-
include/linux/pci_hotplug.h | 2 +-
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 56829f8..121643f 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -428,7 +428,7 @@ static int __init ibm_acpiphp_init(void)
int retval = 0;
acpi_status status;
struct acpi_device *device;
- struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
+ struct kobject *sysdir = &pci_hotplug_slots_kset->kobj;
dbg("%s\n", __FUNCTION__);
@@ -475,7 +475,7 @@ init_return:
static void __exit ibm_acpiphp_exit(void)
{
acpi_status status;
- struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
+ struct kobject *sysdir = &pci_hotplug_slots_kset->kobj;
dbg("%s\n", __FUNCTION__);
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index ce1cff0..6130397 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -61,7 +61,7 @@ static int debug;
static LIST_HEAD(pci_hotplug_slot_list);
-struct kset pci_hotplug_slots_subsys;
+struct kset *pci_hotplug_slots_kset;
static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
@@ -96,8 +96,6 @@ static struct kobj_type hotplug_slot_ktype = {
.release = &hotplug_slot_release,
};
-decl_subsys_name(pci_hotplug_slots, slots, NULL);
-
/* these strings match up with the ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/dlm/lockspace.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 18e4a17..28c3cb4 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -166,7 +166,7 @@ static struct kobj_type dlm_ktype = {
.release = lockspace_kobj_release,
};
-static struct kset dlm_kset;
+static struct kset *dlm_kset;
static int kobject_setup(struct dlm_ls *ls)
{
@@ -180,7 +180,7 @@ static int kobject_setup(struct dlm_ls *ls)
if (error)
return error;
- ls->ls_kobj.kset = &dlm_kset;
+ ls->ls_kobj.kset = dlm_kset;
ls->ls_kobj.ktype = &dlm_ktype;
return 0;
}
@@ -225,17 +225,19 @@ int dlm_lockspace_init(void)
INIT_LIST_HEAD(&lslist);
spin_lock_init(&lslist_lock);
- kobject_set_name(&dlm_kset.kobj, "dlm");
- dlm_kset.kobj.kset = &kernel_subsys;
- error = kset_register(&dlm_kset);
- if (error)
- printk("dlm_lockspace_init: cannot register kset %d\n", error);
- return error;
+ dlm_kset = kset_create_and_register("dlm", NULL, NULL, &kernel_subsys);
+ if (IS_ERR(dlm_kset)) {
+ error = PTR_ERR(dlm_kset);
+ printk(KERN_WARNING "%s: can not create kset %d\n",
+ __FUNCTION__, error);
+ return error;
+ }
+ return 0;
}
void dlm_lockspace_exit(void)
{
- kset_unregister(&dlm_kset);
+ kset_unregister(dlm_kset);
}
static int dlm_scand(void *data)
--
1.5.3.4
-
The last user of this macro (pci hotplug core) is now switched over to
using a dynamic kset, so this macro is no longer needed at all.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/kobject.h | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 205d186..84525a6 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -187,11 +187,6 @@ struct kset _name##_subsys = { \
.kobj = { .k_name = __stringify(_name) }, \
.uevent_ops =_uevent_ops, \
}
-#define decl_subsys_name(_varname,_name,_uevent_ops) \
-struct kset _varname##_subsys = { \
- .kobj = { .k_name = __stringify(_name) }, \
- .uevent_ops =_uevent_ops, \
-}
/* The global /sys/kernel/ subsystem for people to chain off of */
extern struct kset kernel_subsys;
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
The class_obj subsystem is not yet converted as it is more complex and
should be going away soon with the removal of class_device from the
kernel tree.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/class.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 8ad9892..27256b3 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -71,7 +71,7 @@ static struct kobj_type class_ktype = {
};
/* Hotplug events for classes go to the class_obj subsys */
-static decl_subsys(class, NULL);
+static struct kset *class_kset;
int class_create_file(struct class * cls, const struct class_attribute * attr)
@@ -149,7 +149,7 @@ int class_register(struct class * cls)
if (error)
return error;
- cls->subsys.kobj.kset = &class_subsys;
+ cls->subsys.kobj.kset = class_kset;
cls->subsys.kobj.ktype = &class_ktype;
error = subsystem_register(&cls->subsys);
@@ -855,11 +855,9 @@ void class_interface_unregister(struct class_interface *class_intf)
int __init classes_init(void)
{
- int retval;
-
- retval = subsystem_register(&class_subsys);
- if (retval)
- return retval;
+ class_kset = kset_create_and_register("class", NULL, NULL, NULL);
+ if (IS_ERR(class_kset))
+ return PTR_ERR(class_kset);
/* ick, this is ugly, the things we go through to keep from showing up
* in sysfs... */
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/bus.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6309560..8b65694 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -13,6 +13,7 @@
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/string.h>
+#include <linux/err.h>
#include "base.h"
#include "power/power.h"
@@ -166,7 +167,7 @@ static struct kset_uevent_ops bus_uevent_ops = {
.filter = bus_uevent_filter,
};
-static decl_subsys(bus, &bus_uevent_ops);
+static struct kset *bus_kset;
#ifdef CONFIG_HOTPLUG
@@ -767,7 +768,7 @@ EXPORT_SYMBOL_GPL(device_reprobe);
#if 0
struct bus_type * find_bus(char * name)
{
- struct kobject * k = kset_find_obj(&bus_subsys.kset, name);
+ struct kobject * k = kset_find_obj(bus_kset, name);
return k ? to_bus(k) : NULL;
}
#endif /* 0 */
@@ -851,7 +852,7 @@ int bus_register(struct bus_type * bus)
if (retval)
goto out;
- bus->subsys.kobj.kset = &bus_subsys;
+ bus->subsys.kobj.kset = bus_kset;
bus->subsys.kobj.ktype = &bus_ktype;
retval = subsystem_register(&bus->subsys);
@@ -935,7 +936,11 @@ EXPORT_SYMBOL_GPL(bus_unregister_notifier);
int __init buses_init(void)
{
- return subsystem_register(&bus_subsys);
+ bus_kset = kset_create_and_register("bus", &bus_uevent_ops,
+ NULL, NULL);
+ if (IS_ERR(bus_kset))
+ return PTR_ERR(bus_kset);
+ return 0;
}
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/firmware.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index 336be04..d1c2ef4 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -11,15 +11,16 @@
#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/err.h>
#include <linux/device.h>
#include "base.h"
-static decl_subsys(firmware, NULL);
+static struct kset *firmware_kset;
int firmware_register(struct kset *s)
{
- s->kobj.kset = &firmware_subsys;
+ s->kobj.kset = firmware_kset;
s->kobj.ktype = NULL;
return subsystem_register(s);
}
@@ -31,7 +32,10 @@ void firmware_unregister(struct kset *s)
int __init firmware_init(void)
{
- return subsystem_register(&firmware_subsys);
+ firmware_kset = kset_create_and_register("firmware", NULL, NULL, NULL);
+ if (IS_ERR(firmware_kset))
+ return PTR_ERR(firmware_kset);
+ return 0;
}
EXPORT_SYMBOL_GPL(firmware_register);
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically. We also
rename hypervisor_subsys to hypervisor_kset to catch all users of the
variable.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/s390/hypfs/inode.c | 2 +-
drivers/base/hypervisor.c | 14 ++++++++++----
include/linux/kobject.h | 4 ++--
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index c022ccc..387d0e4 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -506,7 +506,7 @@ static int __init hypfs_init(void)
goto fail_diag;
}
}
- s390_subsys.kobj.kset = &hypervisor_subsys;
+ s390_subsys.kobj.kset = hypervisor_kset;
rc = subsystem_register(&s390_subsys);
if (rc)
goto fail_sysfs;
diff --git a/drivers/base/hypervisor.c b/drivers/base/hypervisor.c
index 14e75e9..cb2274f 100644
--- a/drivers/base/hypervisor.c
+++ b/drivers/base/hypervisor.c
@@ -2,19 +2,25 @@
* hypervisor.c - /sys/hypervisor subsystem.
*
* Copyright (C) IBM Corp. 2006
+ * Copyright (C) 2007 Greg Kroah-Hartman <gregkh@suse.de>
+ * Copyright (C) 2007 Novell Inc.
*
* This file is released under the GPLv2
*/
#include <linux/kobject.h>
#include <linux/device.h>
-
+#include <linux/err.h>
#include "base.h"
-decl_subsys(hypervisor, NULL);
-EXPORT_SYMBOL_GPL(hypervisor_subsys);
+struct kset *hypervisor_kset;
+EXPORT_SYMBOL_GPL(hypervisor_kset);
int __init hypervisor_init(void)
{
- return subsystem_register(&hypervisor_subsys);
+ hypervisor_kset = kset_create_and_register("hypervisor", NULL,
+ NULL, NULL);
+ if (IS_ERR(hypervisor_kset))
+ return PTR_ERR(hypervisor_kset);
+ return 0;
}
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 4196ad8..63a6bf9 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -190,8 +190,8 @@ struct kset _name##_subsys = { \
/* The global /sys/kernel/ kset for ...Dynamically create the kset instead of declaring it statically. We also
rename devices_subsys to devices_kset to catch all users of the
variable.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/base.h | 2 +-
drivers/base/core.c | 17 +++++++++--------
drivers/base/power/shutdown.c | 2 +-
drivers/base/sys.c | 4 +---
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 10b2fb6..7e309a4 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -44,4 +44,4 @@ extern char *make_class_name(const char *name, struct kobject *kobj);
extern int devres_release_all(struct device *dev);
-extern struct kset devices_subsys;
+extern struct kset *devices_kset;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 161ea6e..80188ec 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -401,11 +401,8 @@ static ssize_t show_dev(struct device *dev, struct device_attribute *attr,
static struct device_attribute devt_attr =
__ATTR(dev, S_IRUGO, show_dev, NULL);
-/*
- * devices_subsys - structure to be registered with kobject core.
- */
-
-decl_subsys(devices, &device_uevent_ops);
+/* kset to create /sys/devices/ */
+struct kset *devices_kset;
/**
@@ -525,7 +522,7 @@ static void klist_children_put(struct klist_node *n)
void device_initialize(struct device *dev)
{
- dev->kobj.kset = &devices_subsys;
+ dev->kobj.kset = devices_kset;
dev->kobj.ktype = &device_ktype;
kobject_init(&dev->kobj);
klist_init(&dev->klist_children, klist_children_get,
@@ -562,7 +559,7 @@ static struct kobject *virtual_device_parent(struct device *dev)
static struct kobject *virtual_dir = NULL;
if (!virtual_dir)
- virtual_dir = kobject_add_dir(&devices_subsys.kobj, "virtual");
+ virtual_dir = kobject_add_dir(&devices_kset->kobj, "virtual");
return virtual_dir;
}
@@ -1072,7 +1069,11 @@ ...Dynamically create the kset instead of declaring it statically. We also
rename kernel_subsys to kernel_kset to catch all users of this symbol
with a build error instead of an easy-to-ignore build warning.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/configfs/mount.c | 2 +-
fs/debugfs/inode.c | 2 +-
fs/dlm/lockspace.c | 2 +-
fs/gfs2/locking/dlm/sysfs.c | 2 +-
include/linux/kobject.h | 4 ++--
kernel/ksysfs.c | 43 +++++++++++++++++++++++++++++++------------
kernel/user.c | 4 ++--
security/inode.c | 2 +-
8 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 8674e6d..8e2f8e0 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -141,7 +141,7 @@ static int __init configfs_init(void)
goto out;
config_kset = kset_create_and_register("config", NULL,
- NULL, &kernel_subsys);
+ NULL, kernel_kset);
if (IS_ERR(config_kset)) {
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 9f8af79..d6fe796 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -433,7 +433,7 @@ static int __init debugfs_init(void)
int retval;
debug_kset = kset_create_and_register("debug", NULL,
- NULL, &kernel_subsys);
+ NULL, kernel_kset);
if (IS_ERR(debug_kset))
return PTR_ERR(debug_kset);
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 28c3cb4..b5f1823 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -225,7 +225,7 @@ int dlm_lockspace_init(void)
INIT_LIST_HEAD(&lslist);
spin_lock_init(&lslist_lock);
- dlm_kset = kset_create_and_register("dlm", NULL, NULL, &kernel_subsys);
+ dlm_kset = kset_create_and_register("dlm", NULL, NULL, kernel_kset);
if (IS_ERR(dlm_kset)) {
error = PTR_ERR(dlm_kset);
...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
mm/slub.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index b821fdb..9957683 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -21,6 +21,7 @@
#include <linux/ctype.h>
#include <linux/kallsyms.h>
#include <linux/memory.h>
+#include <linux/err.h>
/*
* Lock order:
@@ -3978,7 +3979,7 @@ static struct kset_uevent_ops slab_uevent_ops = {
.filter = uevent_filter,
};
-static decl_subsys(slab, &slab_uevent_ops);
+static struct kset *slab_kset;
#define ID_STR_LENGTH 64
@@ -4031,7 +4032,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
* This is typically the case for debug situations. In that
* case we can catch duplicate names easily.
*/
- sysfs_remove_link(&slab_subsys.kobj, s->name);
+ sysfs_remove_link(&slab_kset->kobj, s->name);
name = s->name;
} else {
/*
@@ -4042,7 +4043,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
}
kobject_set_name(&s->kobj, name);
- s->kobj.kset = &slab_subsys;
+ s->kobj.kset = slab_kset;
s->kobj.ktype = &slab_ktype;
kobject_init(&s->kobj);
err = kobject_add(&s->kobj);
@@ -4087,9 +4088,8 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
/*
* If we have a leftover link then remove it.
*/
- sysfs_remove_link(&slab_subsys.kobj, name);
- return sysfs_create_link(&slab_subsys.kobj,
- &s->kobj, name);
+ sysfs_remove_link(&slab_kset->kobj, name);
+ return sysfs_create_link(&slab_kset->kobj, &s->kobj, name);
}
al = kmalloc(sizeof(struct saved_alias), GFP_KERNEL);
@@ -4108,10 +4108,11 @@ static int __init slab_sysfs_init(void)
struct kmem_cache *s;
int err;
- err = subsystem_register(&slab_subsys);
- if (err) {
+ slab_kset = kset_create_and_register("slab", .../sys/kernel is where these things should go.
Also updated the documentation and tool that used this directory.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
Documentation/vm/slabinfo.c | 2 +-
Documentation/vm/slub.txt | 2 +-
mm/slub.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/vm/slabinfo.c b/Documentation/vm/slabinfo.c
index 7047696..488c1f3 100644
--- a/Documentation/vm/slabinfo.c
+++ b/Documentation/vm/slabinfo.c
@@ -1021,7 +1021,7 @@ void read_slab_dir(void)
char *t;
int count;
- if (chdir("/sys/slab"))
+ if (chdir("/sys/kernel/slab"))
fatal("SYSFS support for SLUB not active\n");
dir = opendir(".");
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt
index d17f324..dcf8bcf 100644
--- a/Documentation/vm/slub.txt
+++ b/Documentation/vm/slub.txt
@@ -63,7 +63,7 @@ In case you forgot to enable debugging on the kernel command line: It is
possible to enable debugging manually when the kernel is up. Look at the
contents of:
-/sys/slab/<slab name>/
+/sys/kernel/slab/<slab name>/
Look at the writable files. Writing 1 to them will enable the
corresponding debug option. All options can be set on a slab that does
diff --git a/mm/slub.c b/mm/slub.c
index 9957683..3700ec6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4109,7 +4109,7 @@ static int __init slab_sysfs_init(void)
int err;
slab_kset = kset_create_and_register("slab", &slab_uevent_ops,
- NULL, NULL);
+ NULL, kernel_kset);
if (IS_ERR(slab_kset)) {
printk(KERN_ERR "Cannot register slab subsystem.\n");
return PTR_ERR(slab_kset);
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/sys.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 7693c95..600db58 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -126,19 +126,16 @@ void sysdev_class_remove_file(struct sysdev_class *c,
}
EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
-/*
- * declare system_subsys
- */
-static decl_subsys(system, NULL);
+static struct kset *system_kset;
int sysdev_class_register(struct sysdev_class * cls)
{
pr_debug("Registering sysdev class '%s'\n",
kobject_name(&cls->kset.kobj));
INIT_LIST_HEAD(&cls->drivers);
- cls->kset.kobj.parent = &system_subsys.kobj;
+ cls->kset.kobj.parent = &system_kset->kobj;
cls->kset.kobj.ktype = &ktype_sysdev_class;
- cls->kset.kobj.kset = &system_subsys;
+ cls->kset.kobj.kset = system_kset;
return kset_register(&cls->kset);
}
@@ -297,8 +294,7 @@ void sysdev_shutdown(void)
pr_debug("Shutting Down System Devices\n");
mutex_lock(&sysdev_drivers_lock);
- list_for_each_entry_reverse(cls, &system_subsys.list,
- kset.kobj.entry) {
+ list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
struct sys_device * sysdev;
pr_debug("Shutting down type '%s':\n",
@@ -360,9 +356,7 @@ int sysdev_suspend(pm_message_t state)
pr_debug("Suspending System Devices\n");
- list_for_each_entry_reverse(cls, &system_subsys.list,
- kset.kobj.entry) {
-
+ list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
pr_debug("Suspending type '%s':\n",
kobject_name(&cls->kset.kobj));
@@ -413,8 +407,7 @@ aux_driver:
}
/* resume other classes */
- list_for_each_entry_continue(cls, &system_subsys.list,
- kset.kobj.entry) {
+ list_for_each_entry_continue(cls, &system_kset->list, ...I'll look into this, I wonder if we are walking off the end of an unterminated list... thanks, greg k-h -
On Mon, 5 Nov 2007 10:58:28 -0800, Could well be. If I'm using lcrash's walk function correctly (which always manages to confuse me...), the list of devices_kset seems to be broken. -
Alright, I can reproduce something like this at shutdown time myself here, I'll try to figure it out... thanks, greg k-h -
<wishes he'd read this thread an hour ago> The Vaio oopses during `reboot -f' and I bisected it down to this patch. http://userweb.kernel.org/~akpm/dsc00034.jpg http://userweb.kernel.org/~akpm/config-sony.txt http://userweb.kernel.org/~akpm/dmesg-sony.txt -
The G5 Mac oopses in the same place during `halt -pfn'. -
Crap, I can't duplicate this here anymore. I'll fire up the older boxes tonight and try to track this down... thanks, greg k-h -
Here's another machine hit the same thing http://userweb.kernel.org/~akpm/config-vmm.txt http://userweb.kernel.org/~akpm/dsc00035.jpg (interesting EIP). Thats'a crufty old pre-ACPI PIII running hacked-about FC1. -
Dynamically create the kset instead of declaring it statically. We also
rename module_subsys to module_kset to catch all users of the variable.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/module.h | 3 ++-
kernel/module.c | 6 ++----
kernel/params.c | 21 ++++++++-------------
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index 2cbc0b8..aa9f254 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -574,7 +574,8 @@ struct device_driver;
#ifdef CONFIG_SYSFS
struct module;
-extern struct kset module_subsys;
+extern struct kset *module_kset;
+extern int module_sysfs_initialized;
int mod_sysfs_init(struct module *mod);
int mod_sysfs_setup(struct module *mod,
diff --git a/kernel/module.c b/kernel/module.c
index 8240939..0aa8f6b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -47,8 +47,6 @@
#include <asm/cacheflush.h>
#include <linux/license.h>
-extern int module_sysfs_initialized;
-
#if 0
#define DEBUGP printk
#else
@@ -1221,7 +1219,7 @@ int mod_sysfs_init(struct module *mod)
err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
if (err)
goto out;
- mod->mkobj.kobj.kset = &module_subsys;
+ mod->mkobj.kobj.kset = module_kset;
mod->mkobj.mod = mod;
kobject_init(&mod->mkobj.kobj);
@@ -2530,7 +2528,7 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
struct kobject *mkobj;
/* Lookup built-in module entry in /sys/modules */
- mkobj = kset_find_obj(&module_subsys, drv->mod_name);
+ mkobj = kset_find_obj(module_kset, drv->mod_name);
if (mkobj) {
mk = container_of(mkobj, struct module_kobject, kobj);
/* remember our module structure */
diff --git a/kernel/params.c b/kernel/params.c
index d4304b3..1a3a8d7 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -562,7 +562,7 @@ static void __init ...Dynamically create the kset instead of declaring it statically. We also
rename power_subsys to power_kset to catch all users of the variable and
we properly export it so that people don't have to guess that it really
is present in the system.
The pseries code is wierd, why is it createing /sys/power if CONFIG_PM
is disabled? Oh well, stupid big boxes ignoring config options...
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/arm/mach-omap1/pm.c | 3 +--
arch/powerpc/platforms/pseries/power.c | 15 +++++++--------
include/linux/kobject.h | 2 ++
kernel/power/disk.c | 2 +-
kernel/power/main.c | 12 ++++++------
kernel/power/power.h | 2 --
6 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 3bf01e2..402113c 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -97,7 +97,6 @@ static struct subsys_attribute sleep_while_idle_attr = {
.store = omap_pm_sleep_while_idle_store,
};
-extern struct kset power_subsys;
static void (*omap_sram_idle)(void) = NULL;
static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
@@ -726,7 +725,7 @@ static int __init omap_pm_init(void)
omap_pm_init_proc();
#endif
- error = subsys_create_file(&power_subsys, &sleep_while_idle_attr);
+ error = subsys_create_file(power_kset, &sleep_while_idle_attr);
if (error)
printk(KERN_ERR "subsys_create_file failed: %d\n", error);
diff --git a/arch/powerpc/platforms/pseries/power.c b/arch/powerpc/platforms/pseries/power.c
index 08d7a50..bf35de4 100644
--- a/arch/powerpc/platforms/pseries/power.c
+++ b/arch/powerpc/platforms/pseries/power.c
@@ -25,6 +25,7 @@
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/init.h>
+#include <linux/err.h>
unsigned long rtas_poweron_auto; /* default and normal state ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Michael Holzheu <holzheu@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/s390/hypfs/inode.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 387d0e4..b8f124a 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -490,7 +490,7 @@ static struct super_operations hypfs_s_ops = {
.show_options = hypfs_show_options,
};
-static decl_subsys(s390, NULL);
+static struct kset *s390_kset;
static int __init hypfs_init(void)
{
@@ -506,17 +506,20 @@ static int __init hypfs_init(void)
goto fail_diag;
}
}
- s390_subsys.kobj.kset = hypervisor_kset;
- rc = subsystem_register(&s390_subsys);
- if (rc)
+
+ s390_kset = kset_create_and_register("s390", NULL, NULL,
+ hypervisor_kset);
+ if (IS_PTR(s390_kset)) {
+ rc = PTR_ERR(s390_kset);
goto fail_sysfs;
+ }
rc = register_filesystem(&hypfs_type);
if (rc)
goto fail_filesystem;
return 0;
fail_filesystem:
- subsystem_unregister(&s390_subsys);
+ kset_unregister(s390_kset);
fail_sysfs:
if (!MACHINE_IS_VM)
hypfs_diag_exit();
@@ -530,7 +533,7 @@ static void __exit hypfs_exit(void)
if (!MACHINE_IS_VM)
hypfs_diag_exit();
unregister_filesystem(&hypfs_type);
- subsystem_unregister(&s390_subsys);
+ kset_unregister(s390_kset);
}
module_init(hypfs_init)
--
1.5.3.4
-
On Fri, 2 Nov 2007 16:59:05 -0700,
arch/s390/hypfs/inode.c: In function 'hypfs_init':
arch/s390/hypfs/inode.c:512: error: implicit declaration of function 'IS_PTR'
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
arch/s390/hypfs/inode.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6/arch/s390/hypfs/inode.c
===================================================================
--- linux-2.6.orig/arch/s390/hypfs/inode.c 2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/arch/s390/hypfs/inode.c 2007-11-05 14:14:46.000000000 +0100
@@ -509,7 +509,7 @@ static int __init hypfs_init(void)
s390_kset = kset_create_and_register("s390", NULL, NULL,
hypervisor_kset);
- if (IS_PTR(s390_kset)) {
+ if (IS_ERR(s390_kset)) {
rc = PTR_ERR(s390_kset);
goto fail_sysfs;
}
-
Argh, that's what I get when I can't build my code, stupid typos... thanks for the patch, I've merged it in. greg k-h -
Dynamically create the kset instead of declaring it statically.
Having 3 static kobjects in one structure is not only foolish, but ripe
for nasty race conditions if handled improperly. We also rename the
field to catch any potential users of it (not that there should be
outside of the driver core...)
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/bus.c | 15 ++++++++-------
drivers/base/driver.c | 2 +-
include/linux/device.h | 2 +-
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 67b8ca2..5ddc2e8 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -639,7 +639,7 @@ int bus_add_driver(struct device_driver *drv)
error = kobject_set_name(&drv->kobj, "%s", drv->name);
if (error)
goto out_put_bus;
- drv->kobj.kset = &bus->drivers;
+ drv->kobj.kset = bus->drivers_kset;
drv->kobj.ktype = &driver_ktype;
error = kobject_register(&drv->kobj);
if (error)
@@ -870,11 +870,12 @@ int bus_register(struct bus_type * bus)
goto bus_devices_fail;
}
- kobject_set_name(&bus->drivers.kobj, "drivers");
- bus->drivers.kobj.parent = &bus->subsys.kobj;
- retval = kset_register(&bus->drivers);
- if (retval)
+ bus->drivers_kset = kset_create_and_register("drivers", NULL,
+ &bus->subsys.kobj, NULL);
+ if (IS_ERR(bus->drivers_kset)) {
+ retval = PTR_ERR(bus->drivers_kset);
goto bus_drivers_fail;
+ }
klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
klist_init(&bus->klist_drivers, NULL, NULL);
@@ -894,7 +895,7 @@ int bus_register(struct bus_type * bus)
bus_attrs_fail:
remove_probe_files(bus);
bus_probe_files_fail:
- kset_unregister(&bus->drivers);
+ kset_unregister(bus->drivers_kset);
bus_drivers_fail:
kset_unregister(bus->devices_kset);
bus_devices_fail:
@@ -917,7 +918,7 @@ void bus_unregister(struct bus_type * bus)
pr_debug("bus %s: unregistering\n", bus->name);
...Dynamically create the kset instead of declaring it statically.
Having 3 static kobjects in one structure is not only foolish, but ripe
for nasty race conditions if handled improperly. We also rename the
field to catch any potential users of it (not that there should be
outside of the driver core...)
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/bus.c | 19 ++++++++++---------
include/linux/device.h | 2 +-
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8b65694..67b8ca2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -450,7 +450,7 @@ int bus_add_device(struct device * dev)
error = device_add_attrs(bus, dev);
if (error)
goto out_put;
- error = sysfs_create_link(&bus->devices.kobj,
+ error = sysfs_create_link(&bus->devices_kset->kobj,
&dev->kobj, dev->bus_id);
if (error)
goto out_id;
@@ -467,7 +467,7 @@ int bus_add_device(struct device * dev)
out_deprecated:
sysfs_remove_link(&dev->kobj, "subsystem");
out_subsys:
- sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
+ sysfs_remove_link(&bus->devices_kset->kobj, dev->bus_id);
out_id:
device_remove_attrs(bus, dev);
out_put:
@@ -513,7 +513,7 @@ void bus_remove_device(struct device * dev)
if (dev->bus) {
sysfs_remove_link(&dev->kobj, "subsystem");
remove_deprecated_bus_links(dev);
- sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
+ sysfs_remove_link(&dev->bus->devices_kset->kobj, dev->bus_id);
device_remove_attrs(dev->bus, dev);
if (dev->is_registered) {
dev->is_registered = 0;
@@ -863,11 +863,12 @@ int bus_register(struct bus_type * bus)
if (retval)
goto bus_uevent_fail;
- kobject_set_name(&bus->devices.kobj, "devices");
- bus->devices.kobj.parent = &bus->subsys.kobj;
- retval = kset_register(&bus->devices);
- if (retval)
+ bus->devices_kset = kset_create_and_register("devices", NULL,
+ ...This isn't used by anything in the driver core, and by no one in the 204
different usages of it in the kernel tree. Remove this field so no one
gets any idea that it is needed to be used.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/device.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index f6eaa33..a8ffb3a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -51,7 +51,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
struct bus_type {
const char * name;
- struct module * owner;
struct kset subsys;
struct kset *drivers_kset;
--
1.5.3.4
-
This allows an easier way to get to the device klist associated with a
struct bus_type (you have three to choose from...) This will make it
easier to move these fields to be dynamic in a future patch.
The only user of this is the PCI core which horribly abuses this
interface to rearrange the order of the pci devices. This should be
done using the existing bus device walking functions, but that's left
for future patches.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/bus.c | 6 ++++++
drivers/pci/probe.c | 11 +++++++----
include/linux/device.h | 1 +
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 3cd991f..e502ca6 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -942,6 +942,12 @@ struct kset *bus_get_kset(struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(bus_get_kset);
+struct klist *bus_get_device_klist(struct bus_type *bus)
+{
+ return &bus->klist_devices;
+}
+EXPORT_SYMBOL_GPL(bus_get_device_klist);
+
int __init buses_init(void)
{
bus_kset = kset_create_and_register("bus", &bus_uevent_ops,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 463a5a9..994e185 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1251,16 +1251,19 @@ static void __init pci_sort_breadthfirst_klist(void)
struct klist_node *n;
struct device *dev;
struct pci_dev *pdev;
+ struct klist *device_klist;
- spin_lock(&pci_bus_type.klist_devices.k_lock);
- list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) {
+ device_klist = bus_get_device_klist(&pci_bus_type);
+
+ spin_lock(&device_klist->k_lock);
+ list_for_each_safe(pos, tmp, &device_klist->k_list) {
n = container_of(pos, struct klist_node, n_node);
dev = container_of(n, struct device, knode_bus);
pdev = to_pci_dev(dev);
pci_insertion_sort_klist(pdev, &sorted_devices);
}
- list_splice(&sorted_devices, ...This allows an easier way to get to the kset associated with a struct
bus_type (you have three to choose from...) This will make it easier to
move these fields to be dynamic in a future patch.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/bus.c | 6 ++++++
drivers/pci/hotplug/pci_hotplug_core.c | 2 +-
include/linux/device.h | 2 ++
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5ddc2e8..3cd991f 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -936,6 +936,12 @@ int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(bus_unregister_notifier);
+struct kset *bus_get_kset(struct bus_type *bus)
+{
+ return &bus->subsys;
+}
+EXPORT_SYMBOL_GPL(bus_get_kset);
+
int __init buses_init(void)
{
bus_kset = kset_create_and_register("bus", &bus_uevent_ops,
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 6130397..cf69024 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -701,7 +701,7 @@ static int __init pci_hotplug_init (void)
int result;
pci_hotplug_slots_kset = kset_create_and_register("slots", NULL, NULL,
- &pci_bus_type.subsys);
+ bus_get_kset(&pci_bus_type));
if (IS_ERR(pci_hotplug_slots_kset)) {
result = PTR_ERR(pci_hotplug_slots_kset);
err("Register subsys with error %d\n", result);
diff --git a/include/linux/device.h b/include/linux/device.h
index a8ffb3a..86eff9d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -117,6 +117,8 @@ extern int bus_unregister_notifier(struct bus_type *bus,
#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
unbound */
+extern struct kset *bus_get_kset(struct bus_type *bus);
+
struct device_driver {
const char * name;
struct ...From: Kay Sievers <kay.sievers@vrfy.org>
Add kobj_sysfs_ops to replace subsys_sysfs_ops. There is no
need for special kset operations, we want to be able to use
simple attribute operations at any kobject, not only ksets.
The whole concept of any default sysfs attribute operations
will go away with the upcoming removal of subsys_sysfs_ops.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/kobject.h | 10 ++++++++++
lib/kobject.c | 29 +++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 8f4a38c..cf9768a 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -119,6 +119,16 @@ struct kset_uevent_ops {
struct kobj_uevent_env *env);
};
+struct kobj_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t count);
+};
+
+extern struct sysfs_ops kobj_sysfs_ops;
+
/**
* struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
*
diff --git a/lib/kobject.c b/lib/kobject.c
index 725fe2e..bc2ba8c 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -488,6 +488,35 @@ void kobject_put(struct kobject * kobj)
kref_put(&kobj->kref, kobject_release);
}
+/* default kobject attribute operations */
+static ssize_t kobj_attr_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct kobj_attribute *kattr;
+ ssize_t ret = -EIO;
+
+ kattr = container_of(attr, struct kobj_attribute, attr);
+ if (kattr->show)
+ ret = kattr->show(kobj, kattr, buf);
+ return ret;
+}
+
+static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ struct kobj_attribute *kattr;
+ ssize_t ret = ...On Fri, 2 Nov 2007 16:59:12 -0700,
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 ...That should usually be done by default attributes assigned to the ktype. Do you have a good use case, where people need to create such attributes individually instead? Kay -
The s390 code that was converted to use kobj_attributes :) These look very useful, I'll go add them to the series unless Kay really objects. thanks, greg k-h -
I just want to hear a good reason to create attributes individually. :) Especially in conjunction with kobject_register(), these attributes are not available at uevent time, which is really really bad. Default attributes just work fine, and have the proper error handling built-in. Offering special functions for it, may just encourage people to continue this "broken" way of creating attributes. So I really object, unless we get a good example why it's needed. :) Kay -
On Mon, 05 Nov 2007 18:25:40 +0100, But where should I specify those default attributes? kset_create_and_register() sets the ktype to kset_ktype... -
Do you need to create attributes at a kset itself, not the kobjects that belong to the kset? Kay -
On Mon, 05 Nov 2007 19:07:50 +0100, Yes, see arch/s390/kernel/ipl.c (and I guess anything that uses subsys_create_file() before). -
Where are the objects that join this kset? A kset is a "collection of objects of a similar type", If there are no objects, you don't need a kset at all, I guess, but just a plain directory. :) Anyway, seems we need an easy way to pass default attributes to ksets and plain directories. If userspace should set some values here when a subsystems creates the its sysfs representation, we must make sure, that the attributes exist at the time the event is sent, otherwise we will Well, some users embedded ksets(subsystem) into objects, because it they confused kobjects and ksets. So there may be a only very few valid users left. :) Kay -
Kay is right, it should be simple to add the kobject attributes to the Hm, I don't think that anyone still does this anymore, as I think I fixed up all of these horrible use cases :) thanks, greg k-h -
On Mon, 05 Nov 2007 19:39:31 +0100, Yes, ipl.c looks a lot like "we need a subdirectory under /sys/firmware/ Maybe they need something like device->uevent_suppress, but at the kobject level? -
In looking at all of the users of the firmware subdirectory, that is what they are all needing that subdirectory for. Ugh, I'll go change that up and delete that kset, and a few of the other Ugh, I hope not :) thanks, greg k-h -
From: Kay Sievers <kay.sievers@vrfy.org>
Clean up the use of ksets and kobjects. Kobjects are instances of
objects (like struct user_info), ksets are collections of objects of a
similar type (like the uids directory containing the user_info directories).
So, use kobjects for the user_info directories, and a kset for the "uids"
directory.
On object cleanup, the final kobject_put() was missing.
Cc: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
include/linux/sched.h | 9 +---
kernel/ksysfs.c | 7 +--
kernel/user.c | 104 ++++++++++++++++++++++++-------------------------
3 files changed, 55 insertions(+), 65 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 155d743..e8033c1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -547,18 +547,13 @@ struct user_struct {
#ifdef CONFIG_FAIR_USER_SCHED
struct task_group *tg;
#ifdef CONFIG_SYSFS
- struct kset kset;
- struct subsys_attribute user_attr;
+ struct kobject kobj;
struct work_struct work;
#endif
#endif
};
-#ifdef CONFIG_FAIR_USER_SCHED
-extern int uids_kobject_init(void);
-#else
-static inline int uids_kobject_init(void) { return 0; }
-#endif
+extern int uids_sysfs_init(void);
extern struct user_struct *find_user(uid_t);
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index ea07bcf..e3293e7 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -142,11 +142,8 @@ static int __init ksysfs_init(void)
goto group_exit;
}
- /*
- * Create "/sys/kernel/uids" directory and corresponding root user's
- * directory under it.
- */
- error = uids_kobject_init();
+ /* create the /sys/kernel/uids/ directory */
+ error = uids_sysfs_init();
if (error)
goto notes_exit;
diff --git a/kernel/user.c b/kernel/user.c
index 75d9f9b..c9fffa1 100644
--- a/kernel/user.c
+++ ...From: Kay Sievers <kay.sievers@vrfy.org>
Switch all dynamically created ksets, that export simple attributes,
to kobj_attribute from subsys_attribute. Struct subsys_attribute will
be removed.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mike Halcrow <mhalcrow@us.ibm.com>
Cc: Phillip Hellewell <phillip@hellewell.homeip.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/main.c | 10 ++++++----
kernel/ksysfs.c | 35 +++++++++++++++++++++--------------
kernel/power/disk.c | 18 ++++++++++++------
kernel/power/main.c | 12 ++++++++----
kernel/power/power.h | 2 +-
lib/kobject.c | 8 ++++----
6 files changed, 52 insertions(+), 33 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index b72a495..828fb99 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -732,12 +732,13 @@ static int ecryptfs_init_kmem_caches(void)
static struct kset *ecryptfs_kset;
-static ssize_t version_show(struct kset *kset, char *buff)
+static ssize_t version_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buff)
{
return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
}
-static struct subsys_attribute version_attr = __ATTR_RO(version);
+static struct kobj_attribute version_attr = __ATTR_RO(version);
static struct ecryptfs_version_str_map_elem {
u32 flag;
@@ -751,7 +752,8 @@ static struct ecryptfs_version_str_map_elem {
{ECRYPTFS_VERSIONING_MULTKEY, "multiple keys per file"}
};
-static ssize_t version_str_show(struct kset *kset, char *buff)
+static ssize_t version_str_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buff)
{
int i;
int remaining = PAGE_SIZE;
@@ -778,7 +780,7 @@ out:
return total_written;
}
-static struct subsys_attribute version_attr_str = __ATTR_RO(version_str);
+static struct kobj_attribute version_attr_str = __ATTR_RO(version_str);
static struct attribute *attributes[] = {
...struct bus_type is static everywhere in the kernel. This moves the
kobject in the structure out of it, and a bunch of other private only to
the driver core fields are now moved to a private structure. This lets
us dynamically create the backing kobject properly and gives us the
chance to be able to document to users exactly how to use the struct
bus_type as there are no fields they can improperly access.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/base.h | 30 +++++++++++-
drivers/base/bus.c | 120 ++++++++++++++++++++++++++--------------------
drivers/base/core.c | 6 +-
drivers/base/dd.c | 4 +-
drivers/base/driver.c | 2 +-
drivers/base/platform.c | 4 +-
include/linux/device.h | 12 +----
7 files changed, 107 insertions(+), 71 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 7e309a4..ca6d273 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -1,6 +1,34 @@
-/* initialisation functions */
+/**
+ * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure.
+ *
+ * @subsys - the struct kset that defines this bus. This is the main kobject
+ * @drivers_kset - the list of drivers associated with this bus
+ * @devices_kset - the list of devices associated with this bus
+ * @klist_devices - the klist to iterate over the @devices_kset
+ * @klist_drivers - the klist to iterate over the @drivers_kset
+ * @bus_notifier - the bus notifier list for anything that cares about things
+ * on this bus.
+ * @bus - pointer back to the struct bus_type that this structure is associated
+ * with.
+ *
+ * This structure is the one that is the actual kobject allowing struct
+ * bus_type to be statically allocated safely. Nothing outside of the driver
+ * core should ever touch these fields.
+ */
+struct bus_type_private {
+ struct kset subsys;
+ struct kset *drivers_kset;
+ struct kset ...On Fri, 2 Nov 2007 16:59:11 -0700,
drivers/base/bus.c: In function 'make_deprecated_bus_links':
drivers/base/bus.c:428: error: 'struct bus_type' has no member named 'subsys'
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/base/bus.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6/drivers/base/bus.c
===================================================================
--- linux-2.6.orig/drivers/base/bus.c 2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/drivers/base/bus.c 2007-11-05 11:30:28.000000000 +0100
@@ -425,7 +425,7 @@ static void device_remove_attrs(struct b
static int make_deprecated_bus_links(struct device *dev)
{
return sysfs_create_link(&dev->kobj,
- &dev->bus->subsys.kobj, "bus");
+ &dev->bus->p->subsys.kobj, "bus");
}
static void remove_deprecated_bus_links(struct device *dev)
-
Thanks, Kay beat you to this by sending me a patch for it yesterday :) greg -
This file violates the one-value-per-file sysfs rule.
If you all want it added back, please do something like a per-feature
file to show what is present and what isn't.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mike Halcrow <mhalcrow@us.ibm.com>
Cc: Phillip Hellewell <phillip@hellewell.homeip.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/main.c | 43 -------------------------------------------
1 files changed, 0 insertions(+), 43 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 828fb99..286ade1 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -740,51 +740,8 @@ static ssize_t version_show(struct kobject *kobj,
static struct kobj_attribute version_attr = __ATTR_RO(version);
-static struct ecryptfs_version_str_map_elem {
- u32 flag;
- char *str;
-} ecryptfs_version_str_map[] = {
- {ECRYPTFS_VERSIONING_PASSPHRASE, "passphrase"},
- {ECRYPTFS_VERSIONING_PUBKEY, "pubkey"},
- {ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH, "plaintext passthrough"},
- {ECRYPTFS_VERSIONING_POLICY, "policy"},
- {ECRYPTFS_VERSIONING_XATTR, "metadata in extended attribute"},
- {ECRYPTFS_VERSIONING_MULTKEY, "multiple keys per file"}
-};
-
-static ssize_t version_str_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buff)
-{
- int i;
- int remaining = PAGE_SIZE;
- int total_written = 0;
-
- buff[0] = '\0';
- for (i = 0; i < ARRAY_SIZE(ecryptfs_version_str_map); i++) {
- int entry_size;
-
- if (!(ECRYPTFS_VERSIONING_MASK
- & ecryptfs_version_str_map[i].flag))
- continue;
- entry_size = strlen(ecryptfs_version_str_map[i].str);
- if ((entry_size + 2) > remaining)
- goto out;
- memcpy(buff, ecryptfs_version_str_map[i].str, entry_size);
- buff[entry_size++] = '\n';
- buff[entry_size] = '\0';
- buff += entry_size;
- total_written += entry_size;
- remaining -= entry_size;
- }
-out:
- return total_written;
-}
-
-static struct kobj_attribute version_attr_str = ...This cleans up a lot of code and gets rid of a unneeded macro, and gets
us one step closer to deleting the deprecated subsys_attr code.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/efivars.c | 35 ++++++++++++++---------------------
1 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 65cddb7..8d7c8c5 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -129,13 +129,6 @@ struct efivar_attribute {
};
-#define EFI_ATTR(_name, _mode, _show, _store) \
-struct subsys_attribute efi_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode}, \
- .show = _show, \
- .store = _store, \
-};
-
#define EFIVAR_ATTR(_name, _mode, _show, _store) \
struct efivar_attribute efivar_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode}, \
@@ -411,12 +404,12 @@ efivar_unregister(struct efivar_entry *var)
* Let's not leave out systab information that snuck into
* the efivars driver
*/
-static ssize_t
-systab_read(struct kset *kset, char *buf)
+static ssize_t systab_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *str = buf;
- if (!kset || !buf)
+ if (!kobj || !buf)
return -EINVAL;
if (efi.mps != EFI_INVALID_TABLE_ADDR)
@@ -437,13 +430,19 @@ systab_read(struct kset *kset, char *buf)
return str - buf;
}
-static EFI_ATTR(systab, 0400, systab_read, NULL);
+static struct kobj_attribute efi_attr_systab =
+ __ATTR(systab, 0400, systab_show, NULL);
-static struct subsys_attribute *efi_subsys_attrs[] = {
- &efi_attr_systab,
+static struct attribute *efi_subsys_attrs[] = {
+ &efi_attr_systab.attr,
NULL, /* maybe more in the future? */
};
+static struct attribute_group efi_subsys_attr_group = {
+ .attrs = ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/efivars.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 8d7c8c5..c2383ac 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -444,7 +444,7 @@ static struct attribute_group efi_subsys_attr_group = {
static decl_subsys(vars, NULL);
-static decl_subsys(efi, NULL);
+static struct kset *efi_kset;
/*
* efivar_create_sysfs_entry()
@@ -539,15 +539,14 @@ efivars_init(void)
/*
* For now we'll register the efi subsys within this driver
*/
-
- error = firmware_register(&efi_subsys);
-
- if (error) {
+ efi_kset = kset_create_and_register("efi", NULL, NULL, firmware_kset);
+ if (IS_ERR(efi_kset)) {
+ error = PTR_ERR(efi_kset);
printk(KERN_ERR "efivars: Firmware registration failed with error %d.\n", error);
goto out_free;
}
- vars_subsys.kobj.kset = &efi_subsys;
+ vars_subsys.kobj.kset = efi_kset;
error = subsystem_register(&vars_subsys);
@@ -584,7 +583,7 @@ efivars_init(void)
} while (status != EFI_NOT_FOUND);
/* Don't forget the systab entry */
- error = sysfs_create_group(&efi_subsys.kobj, &efi_subsys_attr_group);
+ error = sysfs_create_group(&efi_kset->kobj, &efi_subsys_attr_group);
if (error)
printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error);
else
@@ -593,7 +592,7 @@ efivars_init(void)
subsystem_unregister(&vars_subsys);
out_firmware_unregister:
- firmware_unregister(&efi_subsys);
+ kset_unregister(efi_kset);
out_free:
kfree(variable_name);
@@ -614,7 +613,7 @@ efivars_exit(void)
}
...Needed for future firmware subsystem cleanups.
In the end, the firmware_register/unregister functions will be deleted
entirely, but we need this symbol so that subsystems can migrate over.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/firmware.c | 3 ++-
include/linux/kobject.h | 2 ++
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index d1c2ef4..d225059 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -16,7 +16,8 @@
#include "base.h"
-static struct kset *firmware_kset;
+struct kset *firmware_kset;
+EXPORT_SYMBOL_GPL(firmware_kset);
int firmware_register(struct kset *s)
{
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index cf9768a..3aa8108 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -204,6 +204,8 @@ extern struct kset *kernel_kset;
extern struct kset *hypervisor_kset;
/* The global /sys/power/ kset for people to chain off of */
extern struct kset *power_kset;
+/* The global /sys/firmware/ kset for people to chain off of */
+extern struct kset *firmware_kset;
extern int __must_check subsystem_register(struct kset *);
extern void subsystem_unregister(struct kset *);
--
1.5.3.4
-
This makes the code a bit simpler and and gets us one step closer to
deleting the deprecated subsys_attr code.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Cliff Brake <cbrake@accelent.com>
Cc: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/arm/mach-omap1/pm.c | 22 ++++++++--------------
1 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 402113c..63edafb 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -69,14 +69,14 @@ static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
static unsigned short enable_dyn_sleep = 1;
-static ssize_t omap_pm_sleep_while_idle_show(struct kset *kset, char *buf)
+static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
{
return sprintf(buf, "%hu\n", enable_dyn_sleep);
}
-static ssize_t omap_pm_sleep_while_idle_store(struct kset *kset,
- const char * buf,
- size_t n)
+static ssize_t idle_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char * buf, size_t n)
{
unsigned short value;
if (sscanf(buf, "%hu", &value) != 1 ||
@@ -88,14 +88,8 @@ static ssize_t omap_pm_sleep_while_idle_store(struct kset *kset,
return n;
}
-static struct subsys_attribute sleep_while_idle_attr = {
- .attr = {
- .name = __stringify(sleep_while_idle),
- .mode = 0644,
- },
- .show = omap_pm_sleep_while_idle_show,
- .store = omap_pm_sleep_while_idle_store,
-};
+static struct kobj_attribute sleep_while_idle_attr =
+ __ATTR(sleep_while_idle, 0644, idle_show, idle_store);
static void (*omap_sram_idle)(void) = NULL;
static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
@@ -725,9 +719,9 @@ static int __init omap_pm_init(void)
omap_pm_init_proc();
#endif
- error = subsys_create_file(power_kset, &sleep_while_idle_attr);
+ error = sysfs_create_file(&power_kset->kobj, ...WTF? Passing binary structures into a sysfs file, expecting it to be in
the correct format/endianness? That's just wrong on so many levels.
So, these files are deleted. If you want to add them back, please do so
in configfs, or in debugfs. Or use text strings, which is what sysfs is
only for.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/efivars.c | 149 --------------------------------------------
1 files changed, 0 insertions(+), 149 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 06ecdb9..65cddb7 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_name = { \
.store = _store, \
};
-#define VAR_SUBSYS_ATTR(_name, _mode, _show, _store) \
-struct subsys_attribute var_subsys_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode}, \
- .show = _show, \
- .store = _store, \
-};
-
#define to_efivar_attr(_attr) container_of(_attr, struct efivar_attribute, attr)
#define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj)
@@ -408,144 +401,12 @@ static struct kobj_type efivar_ktype = {
.default_attrs = def_attrs,
};
-static ssize_t
-dummy(struct kset *kset, char *buf)
-{
- return -ENODEV;
-}
-
static inline void
efivar_unregister(struct efivar_entry *var)
{
kobject_unregister(&var->kobj);
}
-
-static ssize_t
-efivar_create(struct kset *kset, const char *buf, size_t count)
-{
- struct efi_variable *new_var = (struct efi_variable *)buf;
- struct efivar_entry *search_efivar, *n;
- unsigned long strsize1, strsize2;
- efi_status_t status = EFI_NOT_FOUND;
- int found = 0;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
-
- spin_lock(&efivars_lock);
-
- /*
- * Does this variable already exist?
- ...I have tested gregkh's patches tree, which includes this patch, the patch to put these back as binary blob interfaces, as well as other cleanups, on an Itanium2 system. The efibootmgr userspace application continues to work as it did before this patch series, which I claim is success. For the patches that touch drivers/firmware/efivars.c I can say: Tested-by: Matt Domsch <Matt_Domsch@dell.com> Thanks, Matt -- Matt Domsch Linux Technology Strategist, Dell Office of the CTO linux.dell.com & www.dell.com/linux -
Great, thanks for doing this, I appreciate it. greg k-h -
This makes the code a bit simpler and and gets us one step closer to
deleting the deprecated subsys_attr code.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Manish Ahuja <mahuja@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/powerpc/platforms/pseries/power.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/power.c b/arch/powerpc/platforms/pseries/power.c
index bf35de4..012224b 100644
--- a/arch/powerpc/platforms/pseries/power.c
+++ b/arch/powerpc/platforms/pseries/power.c
@@ -29,13 +29,15 @@
unsigned long rtas_poweron_auto; /* default and normal state is 0 */
-static ssize_t auto_poweron_show(struct kset *kset, char *buf)
+static ssize_t auto_poweron_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", rtas_poweron_auto);
}
-static ssize_t
-auto_poweron_store(struct kset *kset, const char *buf, size_t n)
+static ssize_t auto_poweron_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t n)
{
int ret;
unsigned long ups_restart;
@@ -48,14 +50,8 @@ auto_poweron_store(struct kset *kset, const char *buf, size_t n)
return -EINVAL;
}
-static struct subsys_attribute auto_poweron_attr = {
- .attr = {
- .name = __stringify(auto_poweron),
- .mode = 0644,
- },
- .show = auto_poweron_show,
- .store = auto_poweron_store,
-};
+static struct kobj_attribute auto_poweron_attr =
+ __ATTR(auto_poweron, 0644, auto_poweron_show, auto_poweron_store);
#ifndef CONFIG_PM
struct kset *power_kset;
@@ -80,7 +76,7 @@ core_initcall(pm_init);
#else
static int __init apo_pm_init(void)
{
- return (subsys_create_file(power_kset, &auto_poweron_attr));
+ return (sysfs_create_file(&power_kset->kobj, &auto_poweron_attr));
}
__initcall(apo_pm_init);
#endif
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/efivars.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index c2383ac..362c5a5 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -443,7 +443,7 @@ static struct attribute_group efi_subsys_attr_group = {
};
-static decl_subsys(vars, NULL);
+static struct kset *vars_kset;
static struct kset *efi_kset;
/*
@@ -489,7 +489,7 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
kobject_set_name(&new_efivar->kobj, "%s", short_name);
- new_efivar->kobj.kset = &vars_subsys;
+ new_efivar->kobj.kset = vars_kset;
new_efivar->kobj.ktype = &efivar_ktype;
i = kobject_register(&new_efivar->kobj);
if (i) {
@@ -546,11 +546,9 @@ efivars_init(void)
goto out_free;
}
- vars_subsys.kobj.kset = efi_kset;
-
- error = subsystem_register(&vars_subsys);
-
- if (error) {
+ vars_kset = kset_create_and_register("vars", NULL, NULL, efi_kset);
+ if (IS_ERR(vars_kset)) {
+ error = PTR_ERR(vars_kset);
printk(KERN_ERR "efivars: Subsystem registration failed with error %d.\n", error);
goto out_firmware_unregister;
}
@@ -589,7 +587,7 @@ efivars_init(void)
else
goto out_free;
- subsystem_unregister(&vars_subsys);
+ kset_unregister(vars_kset);
out_firmware_unregister:
kset_unregister(efi_kset);
@@ -612,7 +610,7 @@ efivars_exit(void)
efivar_unregister(entry);
}
- subsystem_unregister(&vars_subsys);
+ kset_unregister(vars_kset);
kset_unregister(efi_kset);
}
--
1.5.3.4
-
This makes the code a bit simpler and and gets us one step closer to
deleting the deprecated subsys_attr code.
NOTE, this needs the next patch in the series in order to work properly.
This will build, but the sysfs files will not properly operate.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Michael Holzheu <holzheu@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Volker Sameske <sameske@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/s390/kernel/ipl.c | 80 ++++++++++++++++++++++++++++-------------------
1 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index cae793a..f2cfbf9 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -162,22 +162,25 @@ EXPORT_SYMBOL_GPL(diag308);
/* SYSFS */
#define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
-static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
+static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
+ struct kobj_attribute *attr, \
char *page) \
{ \
return sprintf(page, _format, _value); \
} \
-static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
+static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
__ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
#define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
-static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
+static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
+ struct kobj_attribute *attr, \
char *page) \
{ \
return sprintf(page, _fmt_out, \
(unsigned long long) _value); \
} \
-static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
+static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
+ struct kobj_attribute *attr, \
const char *buf, size_t len) \
...Dynamically create the kset instead of declaring it statically.
This makes the kobject attributes now work properly that I broke in the
previous patch.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Michael Holzheu <holzheu@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Volker Sameske <sameske@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/s390/kernel/ipl.c | 75 +++++++++++++++++++++++++-----------------------
1 files changed, 39 insertions(+), 36 deletions(-)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index f2cfbf9..327e990 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -14,6 +14,7 @@
#include <linux/delay.h>
#include <linux/reboot.h>
#include <linux/ctype.h>
+#include <linux/err.h>
#include <asm/ipl.h>
#include <asm/smp.h>
#include <asm/setup.h>
@@ -426,7 +427,7 @@ static struct attribute_group ipl_unknown_attr_group = {
.attrs = ipl_unknown_attrs,
};
-static decl_subsys(ipl, NULL);
+static struct kset *ipl_kset;
/*
* reipl section
@@ -602,7 +603,7 @@ static ssize_t reipl_type_store(struct kobject *kobj,
static struct kobj_attribute reipl_type_attr =
__ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
-static decl_subsys(reipl, NULL);
+static struct kset *reipl_kset;
/*
* dump section
@@ -699,13 +700,13 @@ static ssize_t dump_type_store(struct kobject *kobj,
static struct kobj_attribute dump_type_attr =
__ATTR(dump_type, 0644, dump_type_show, dump_type_store);
-static decl_subsys(dump, NULL);
+static struct kset *dump_kset;
/*
* Shutdown actions section
*/
-static decl_subsys(shutdown_actions, NULL);
+static struct kset *shutdown_actions_kset;
/* on panic */
@@ -830,23 +831,23 @@ static int __init ipl_register_fcp_files(void)
{
int rc;
- rc = sysfs_create_group(&ipl_subsys.kobj,
+ rc = sysfs_create_group(&ipl_kset->kobj,
&ipl_fcp_attr_group);
if ...On Fri, 2 Nov 2007 16:59:24 -0700,
It seems you also need this (not yet booted):
Fix the following warnings:
arch/s390/kernel/ipl.c: In function 'reipl_init':
arch/s390/kernel/ipl.c:981: warning: passing argument 2 of 'sysfs_create_file' from incompatible pointer type
arch/s390/kernel/ipl.c: In function 'dump_init':
arch/s390/kernel/ipl.c:1070: warning: passing argument 2 of 'sysfs_create_file' from incompatible pointer type
arch/s390/kernel/ipl.c: In function 'shutdown_actions_init':
arch/s390/kernel/ipl.c:1094: warning: passing argument 2 of 'sysfs_create_file' from incompatible pointer type
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
arch/s390/kernel/ipl.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
Index: linux-2.6/arch/s390/kernel/ipl.c
===================================================================
--- linux-2.6.orig/arch/s390/kernel/ipl.c 2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/arch/s390/kernel/ipl.c 2007-11-05 11:22:04.000000000 +0100
@@ -978,7 +978,7 @@ static int __init reipl_init(void)
reipl_kset = kset_create_and_register("reipl", NULL, NULL, firmware_kset);
if (IS_ERR(reipl_kset))
return PTR_ERR(reipl_kset);
- rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr);
+ rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr);
if (rc) {
kset_unregister(reipl_kset);
return rc;
@@ -1067,7 +1067,7 @@ static int __init dump_init(void)
dump_kset = kset_create_and_register("dump", NULL, NULL, firmware_kset);
if (IS_ERR(dump_kset))
return PTR_ERR(dump_kset);
- rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr);
+ rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr);
if (rc) {
kset_unregister(dump_kset);
return rc;
@@ -1091,7 +1091,8 @@ static int __init shutdown_actions_init(
firmware_kset);
if (IS_ERR(shutdown_actions_kset))
return PTR_ERR(shutdown_actions_kset);
- rc = sysfs_create_file(&shutdown_actions_kset->kobj, ...Thanks, but this should go with the previous kobject_attribute cleanup patch, not the kset patch. I've merged it in now. thanks for the review and patch. greg k-h -
From: Kay Sievers <kay.sievers@vrfy.org>
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>
---
fs/sysfs/file.c | 63 +++++++---------------------------------------
include/linux/kobject.h | 9 ------
lib/kobject.c | 21 ---------------
3 files changed, 10 insertions(+), 83 deletions(-)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 4d6fba0..fb5a1c2 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -20,43 +20,6 @@
#include "sysfs.h"
-#define to_sattr(a) container_of(a,struct subsys_attribute, attr)
-
-/*
- * Subsystem file operations.
- * These operations allow subsystems to have files that can be
- * read/written.
- */
-static ssize_t
-subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page)
-{
- struct kset *kset = to_kset(kobj);
- struct subsys_attribute * sattr = to_sattr(attr);
- ssize_t ret = -EIO;
-
- if (sattr->show)
- ret = sattr->show(kset, page);
- return ret;
-}
-
-static ssize_t
-subsys_attr_store(struct kobject * kobj, struct attribute * attr,
- const char * page, size_t count)
-{
- struct kset *kset = to_kset(kobj);
- struct subsys_attribute * sattr = to_sattr(attr);
- ssize_t ret = -EIO;
-
- if (sattr->store)
- ret = sattr->store(kset, page, count);
- return ret;
-}
-
-static struct sysfs_ops subsys_sysfs_ops = {
- .show = subsys_attr_show,
- .store = subsys_attr_store,
-};
-
/*
* There's one sysfs_buffer for each open file and one
* sysfs_open_dirent for each sysfs_dirent with one or more open
@@ -350,29 +313,23 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
{
struct sysfs_dirent ...Dynamically create the kset instead of declaring it statically.
This makes the kobject attributes now work properly that I broke in the
previous patch.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Thibaut VARENE <varenet@parisc-linux.org>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Kyle McMartin <kyle@parisc-linux.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/parisc/pdc_stable.c | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index e1b9cba..3d71fea 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -960,8 +960,8 @@ static struct attribute_group pdcs_attr_group = {
.attrs = pdcs_subsys_attrs,
};
-static decl_subsys(paths, NULL);
-static decl_subsys(stable, NULL);
+static struct kset *stable_kset;
+static struct kset *paths_kset;
/**
* pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
@@ -993,7 +993,7 @@ pdcs_register_pathentries(void)
if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
return err;
- entry->kobj.kset = &paths_subsys;
+ entry->kobj.kset = paths_kset;
entry->kobj.ktype = &ktype_pdcspath;
if ((err = kobject_register(&entry->kobj)))
return err;
@@ -1058,19 +1058,26 @@ pdc_stable_init(void)
/* the actual result is 16 bits away */
pdcs_osid = (u16)(result >> 16);
- /* For now we'll register the stable subsys within this driver */
- if ((rc = firmware_register(&stable_subsys)))
+ /* For now we'll register the stable kset within this driver */
+ stable_kset = kset_create_and_register("stable", NULL, NULL,
+ firmware_kset);
+ if (IS_ERR(stable_kset)) {
+ rc = PTR_ERR(stable_kset);
goto fail_firmreg;
+ }
/* Don't forget the root entries */
- error = sysfs_create_group(&stable_subsys.kobj, pdcs_attr_group);
-
- /* register the paths subsys as a ...Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/edd.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index fc567fa..098132a 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = {
.default_attrs = def_attrs,
};
-static decl_subsys(edd, NULL);
+static struct kset *edd_kset;
/**
@@ -723,7 +723,7 @@ edd_device_register(struct edd_device *edev, int i)
edd_dev_set_info(edev, i);
kobject_set_name(&edev->kobj, "int13_dev%02x",
0x80 + i);
- edev->kobj.kset = &edd_subsys;
+ edev->kobj.kset = edd_kset;
edev->kobj.ktype = &edd_ktype;
error = kobject_register(&edev->kobj);
if (!error)
@@ -756,9 +756,9 @@ edd_init(void)
return 1;
}
- rc = firmware_register(&edd_subsys);
- if (rc)
- return rc;
+ edd_kset = kset_create_and_register("edd", NULL, NULL, firmware_kset);
+ if (IS_ERR(edd_kset))
+ return PTR_ERR(edd_kset);
for (i = 0; i < edd_num_devices() && !rc; i++) {
edev = kzalloc(sizeof (*edev), GFP_KERNEL);
@@ -774,7 +774,7 @@ edd_init(void)
}
if (rc)
- firmware_unregister(&edd_subsys);
+ kset_unregister(edd_kset);
return rc;
}
@@ -788,7 +788,7 @@ edd_exit(void)
if ((edev = edd_devices[i]))
edd_device_unregister(edev);
}
- firmware_unregister(&edd_subsys);
+ kset_unregister(edd_kset);
}
late_initcall(edd_init);
--
1.5.3.4
-
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/acpi/bus.c | 12 ++++++++----
drivers/acpi/system.c | 2 +-
include/acpi/acpi_bus.h | 2 +-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index fe90513..8be7567 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -744,7 +744,7 @@ static int __init acpi_bus_init(void)
return -ENODEV;
}
-decl_subsys(acpi, NULL);
+struct kset *acpi_kset;
static int __init acpi_init(void)
{
@@ -756,10 +756,14 @@ static int __init acpi_init(void)
return -ENODEV;
}
- result = firmware_register(&acpi_subsys);
- if (result < 0)
- printk(KERN_WARNING "%s: firmware_register error: %d\n",
+ acpi_kset = kset_create_and_register("acpi", NULL, NULL,
+ firmware_kset);
+ if (IS_ERR(acpi_kset)) {
+ result = PTR_ERR(acpi_kset);
+ printk(KERN_WARNING "%s: kset create error: %d\n",
__FUNCTION__, result);
+ acpi_kset = NULL;
+ }
result = acpi_bus_init();
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index edee280..a9eb14c 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -135,7 +135,7 @@ static int acpi_system_sysfs_init(void)
int table_index = 0;
int result;
- tables_kobj.parent = &acpi_subsys.kobj;
+ tables_kobj.parent = &acpi_kset->kobj;
kobject_set_name(&tables_kobj, "tables");
result = kobject_register(&tables_kobj);
if (result)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 19c3ead..17514cb 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -318,7 +318,7 @@ struct acpi_bus_event {
u32 data;
};
-extern struct kset acpi_subsys;
+extern struct kset *acpi_kset;
extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
/*
* External Functions
-- ...These functions are no longer called or needed, so we can remove them.
As I rewrote the whole firmware.c file, add my copyright.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/firmware.c | 19 ++-----------------
include/linux/device.h | 5 -----
2 files changed, 2 insertions(+), 22 deletions(-)
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index d225059..75e3049 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -3,11 +3,11 @@
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
+ * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
+ * Copyright (c) 2007 Novell Inc.
*
* This file is released under the GPLv2
- *
*/
-
#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -19,18 +19,6 @@
struct kset *firmware_kset;
EXPORT_SYMBOL_GPL(firmware_kset);
-int firmware_register(struct kset *s)
-{
- s->kobj.kset = firmware_kset;
- s->kobj.ktype = NULL;
- return subsystem_register(s);
-}
-
-void firmware_unregister(struct kset *s)
-{
- subsystem_unregister(s);
-}
-
int __init firmware_init(void)
{
firmware_kset = kset_create_and_register("firmware", NULL, NULL, NULL);
@@ -38,6 +26,3 @@ int __init firmware_init(void)
return PTR_ERR(firmware_kset);
return 0;
}
-
-EXPORT_SYMBOL_GPL(firmware_register);
-EXPORT_SYMBOL_GPL(firmware_unregister);
diff --git a/include/linux/device.h b/include/linux/device.h
index 3701269..cb71907 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -541,11 +541,6 @@ extern void device_shutdown(void);
/* drivers/base/sys.c */
extern void sysdev_shutdown(void);
-
-/* drivers/base/firmware.c */
-extern int __must_check firmware_register(struct kset *);
-extern void firmware_unregister(struct kset *);
-
/* debugging and troubleshooting/diagnostic helpers. */
extern const char *dev_driver_string(struct device ...This makes the code a bit simpler and and gets us one step closer to
deleting the deprecated subsys_attr code.
NOTE, this needs the next patch in the series in order to work properly.
This will build, but the sysfs files will not properly operate.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Thibaut VARENE <varenet@parisc-linux.org>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Kyle McMartin <kyle@parisc-linux.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/parisc/pdc_stable.c | 147 ++++++++++++++++++++----------------------
1 files changed, 70 insertions(+), 77 deletions(-)
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 1382be6..e1b9cba 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -120,7 +120,7 @@ struct pdcspath_entry pdcspath_entry_##_name = { \
};
#define PDCS_ATTR(_name, _mode, _show, _store) \
-struct subsys_attribute pdcs_attr_##_name = { \
+struct kobj_attribute pdcs_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode}, \
.show = _show, \
.store = _store, \
@@ -523,15 +523,15 @@ static struct pdcspath_entry *pdcspath_entries[] = {
/**
* pdcs_size_read - Stable Storage size output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*/
-static ssize_t
-pdcs_size_read(struct kset *kset, char *buf)
+static ssize_t pdcs_size_read(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
{
char *out = buf;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
/* show the size of the stable storage */
@@ -542,17 +542,17 @@ pdcs_size_read(struct kset *kset, char *buf)
/**
* pdcs_auto_read - Stable Storage autoboot/search flag output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
* @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
...Dynamically create the kset instead of declaring it statically.
Also use the new kobj_attribute which cleans up this file a _lot_.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Kurt Hackel <kurt.hackel@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ocfs2/cluster/masklog.c | 4 +-
fs/ocfs2/cluster/sys.c | 83 +++++++++++--------------------------------
2 files changed, 23 insertions(+), 64 deletions(-)
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index dead319..23c732f 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -146,7 +146,7 @@ static struct kset mlog_kset = {
.kobj = {.ktype = &mlog_ktype},
};
-int mlog_sys_init(struct kset *o2cb_subsys)
+int mlog_sys_init(struct kset *o2cb_kset)
{
int i = 0;
@@ -157,7 +157,7 @@ int mlog_sys_init(struct kset *o2cb_subsys)
mlog_attr_ptrs[i] = NULL;
kobject_set_name(&mlog_kset.kobj, "logmask");
- mlog_kset.kobj.kset = o2cb_subsys;
+ mlog_kset.kobj.kset = o2cb_kset;
return kset_register(&mlog_kset);
}
diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c
index 880d013..eb2c4d7 100644
--- a/fs/ocfs2/cluster/sys.c
+++ b/fs/ocfs2/cluster/sys.c
@@ -28,96 +28,55 @@
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>
+#include <linux/fs.h>
#include "ocfs2_nodemanager.h"
#include "masklog.h"
#include "sys.h"
-struct o2cb_attribute {
- struct attribute attr;
- ssize_t (*show)(char *buf);
- ssize_t (*store)(const char *buf, size_t count);
-};
-
-#define O2CB_ATTR(_name, _mode, _show, _store) \
-struct o2cb_attribute o2cb_attr_##_name = __ATTR(_name, _mode, _show, _store)
-
-#define to_o2cb_attr(_attr) container_of(_attr, struct o2cb_attribute, attr)
-static ssize_t o2cb_interface_revision_show(char *buf)
+static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
{
return snprintf(buf, ...This macro is no longer used. ksets should be created dynamically with
a call to kset_create_and_register() not declared statically.
Yes, there are 5 remaining static struct kset usages in the kernel tree,
but they will be fixed up soon.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/class.c | 11 +++++++++--
include/linux/kobject.h | 6 ------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 27256b3..c854158 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -453,8 +453,15 @@ static struct kset_uevent_ops class_uevent_ops = {
.uevent = class_uevent,
};
-static decl_subsys(class_obj, &class_uevent_ops);
-
+/*
+ * DO NOT copy how this is created, kset_create_and_register() should be
+ * called, but this is a hold-over from the old-way and will be deleted
+ * entirely soon.
+ */
+static struct kset class_obj_subsys = {
+ .kobj = { .k_name = "class_obj", },
+ .uevent_ops = &class_uevent_ops,
+};
static int class_device_add_attrs(struct class_device * cd)
{
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 05c8ef8..0e8f21e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -192,12 +192,6 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
#define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
-#define decl_subsys(_name,_uevent_ops) \
-struct kset _name##_subsys = { \
- .kobj = { .k_name = __stringify(_name) }, \
- .uevent_ops =_uevent_ops, \
-}
-
/* The global /sys/kernel/ kset for people to chain off of */
extern struct kset *kernel_kset;
/* The global /sys/hypervisor/ kset for people to chain off of */
--
1.5.3.4
-
Now I'm rather screwed. I still need to revert gregkh-driver-block-device.patch so that the G5 will boot, but doing that restores the decl_subsys(block, &block_uevent_ops) in genhd.c, and that no longer compiles. -
you killed perfmon. perfmon/perfmon_sysfs.c: In function 'pfm_init_sysfs': perfmon/perfmon_sysfs.c:411: error: 'kernel_subsys' undeclared (first use in this function) perfmon/perfmon_sysfs.c:411: error: (Each undeclared identifier is reported only once perfmon/perfmon_sysfs.c:411: error: for each function it appears in.) I'll drop the perfmon tree and shall soldier on. -
Andrew, Greg, I am sure we can fix this. I just need to get the kset patch from Greg. -- -Stephane -
What's the status on when perfmon will be sent to Linus? I'll be glad to send you a patch, I'm updating my tree right now, give me a few hours... thanks, greg k-h -
Greg, Trying to get into -mm first. Obvisouly there is a first problem with kobject/sysfs. But I am hoping it won't be that difficult to fix especially with your help ;-> -- -Stephane -
fs/ocfs2/stackglue.c:940: error: expected ')' before '(' token
fs/ocfs2/stackglue.c: In function 'ocfs2_show':
fs/ocfs2/stackglue.c:948: error: 'ocfs2_subsys' undeclared (first use in this function)
fs/ocfs2/stackglue.c:948: error: (Each undeclared identifier is reported only once
fs/ocfs2/stackglue.c:948: error: for each function it appears in.)
fs/ocfs2/stackglue.c: In function 'ocfs2_store':
fs/ocfs2/stackglue.c:962: error: 'ocfs2_subsys' undeclared (first use in this function)
fs/ocfs2/stackglue.c: In function 'ocfs2_sys_shutdown':
fs/ocfs2/stackglue.c:972: error: 'ocfs2_subsys' undeclared (first use in this function)
fs/ocfs2/stackglue.c: In function 'ocfs2_sys_init':
fs/ocfs2/stackglue.c:979: error: 'ocfs2_subsys' undeclared (first use in this function)
fs/ocfs2/stackglue.c:980: error: implicit declaration of function 'kobj_set_kset_s'
fs/ocfs2/stackglue.c:980: error: 'fs_subsys' undeclared (first use in this function)
wrecks the ocfs2 devel tree. I'll drop that too.
I wonder how much other out-of-tree code will be broken.
-
