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 | 23 ++---
arch/powerpc/platforms/pseries/power.c | 33 ++---
arch/s390/hypfs/inode.c | 15 ++-
arch/s390/kernel/ipl.c | 149 +++++++++++++----------
block/genhd.c | 5 +-
drivers/acpi/bus.c | 12 ++-
drivers/acpi/system.c | 2 +-
drivers/base/base.h | 32 +++++-
drivers/base/bus.c | 142 +++++++++++++--------
drivers/base/class.c | 27 +++--
drivers/base/core.c | 24 ++--
drivers/base/dd.c | 4 +-
drivers/base/driver.c | 2 +-
drivers/base/firmware.c | 27 ++---
drivers/base/hypervisor.c | 14 ++-
drivers/base/platform.c | 4 +-
drivers/base/power/shutdown.c | 2 +-
drivers/base/sys.c | 31 ++---
drivers/edac/edac_mc_sysfs.c | 2 +-
drivers/firmware/edd.c | 15 ++-
drivers/firmware/efivars.c | 214 ++++---------------------------
drivers/parisc/pdc_stable.c | 186 ++++++++++++++--------------
drivers/pci/hotplug/acpiphp_ibm.c | 4 +-
drivers/pci/hotplug/pci_hotplug_core.c | 22 ++--
drivers/pci/hotplug/rpadlpar_sysfs.c | 2 +-
drivers/pci/probe.c | 11 +-
drivers/uio/uio.c | 2 +-
fs/configfs/mount.c | 14 +-
fs/debugfs/inode.c | 14 +-
fs/dlm/lockspace.c | 22 ++--
fs/ecryptfs/main.c | 130 +++----------------
fs/fuse/inode.c | 27 +++--
fs/gfs2/locking/dlm/sysfs.c | 24 ++--
fs/gfs2/sys.c | 15 +--
fs/namespace.c | 14 ++-
fs/ocfs2/cluster/masklog.c | 4 +-
fs/ocfs2/cluster/sys.c | 83 +++---------
fs/sysfs/file.c | 65 ++--------
include/acpi/acpi_bus.h | 2 +-
include/linux/device.h | 21 +---
include/linux/fs.h | 2 +-
include/linux/kobject.h | 76 ++++--------
include/linux/module.h | 3 +-
include/linux/pci_hotplug.h | 2 +-
include/linux/sched.h | 9 +-
kernel/ksysfs.c | 83 ++++++++-----
kernel/module.c | 6 +-
kernel/params.c | 26 ++---
kernel/power/disk.c | 20 ++-
kernel/power/main.c | 24 ++--
kernel/power/power.h | 4 +-
kernel/user.c | 104 ++++++++--------
lib/kobject.c | 129 +++++++++++++++++---
mm/slub.c | 20 ++--
security/inode.c | 12 +-
57 files changed, 900 insertions(+), 1065 deletions(-)
---------------
Greg Kroah-Hartman (50):
ecryptfs: clean up attribute mess
KOBJECT: remove struct kobj_type from struct kset
KOBJECT: remove kobj_set_kset_s as no one is using it anymore
kset: add kset_create_and_register function
kset: convert fuse to use kset_create
kset: convert securityfs to use kset_create
kset: convert debugfs to use kset_create
kset: convert configfs to use kset_create
kset: convert ecryptfs to use kset_create
kset: convert main fs kset to use kset_create
kset: convert gfs2 to use kset_create
kset: convert gfs2 dlm to use kset_create
kset: convert dlm to use kset_create
kset: convert pci hotplug to use kset_create_and_register
kset: remove decl_subsys_name
kset: convert kernel_subsys to use kset_create
kset: convert drivers/base/bus.c kset_create_and_register
kset: convert drivers/base/class.c kset_create_and_register
kset: convert drivers/base/firmware.c kset_create_and_register
kset: convert /sys/devices to use kset_create
kset: convert /sys/hypervisor to use kset_create
kset: convert /sys/devices/system to use kset_create
kset: convert slub to use kset_create
kset: move /sys/slab to /sys/kernel/slab
kset: convert /sys/module to use kset_create
kset: convert /sys/power to use kset_create
kset: convert s390 hypervisor kset to use kset_create
kset: convert struct bus_device->devices to use kset_create
kset: convert struct bus_device->drivers to use kset_create
driver core: remove owner field from struct bus_type
driver core: add way to get to bus kset
driver core: add way to get to bus device klist
driver core: remove fields from struct bus_type
ecryptfs: remove version_str file from sysfs
efivars: remove new_var and del_var files from sysfs
kobject: convert efivars to kobj_attr interface
firmware: export firmware_kset so that people can use that instead of the braindead firmware_register interface
kset: convert efivars to use kset_create for the efi subsystem.
kset: convert efivars to use kset_create for the vars sub-subsystem.
kobject: convert arm/mach-omap1/pm.c to kobj_attr interface
kobject: convert pseries/power.c to kobj_attr interface
kobject: convert s390 ipl.c to kobj_attr interface
kset: convert s390 ipl.c to use kset_create
kobject: convert parisc/pdc_stable to kobj_attr interface
kset: convert parisc/pdc_stable.c to use kset_create
kset: convert edd to use kset_create
kset: convert acpi to use kset_create
firmware: remove firmware_(un)register()
kset: convert ocfs2 to use kset_create
kset: remove decl_subsys macro
Kay Sievers (4):
Driver Core: add kobj_attribute handling
Driver Core: switch all dynamic ksets to kobj_sysfs_ops
fix struct user_info export's sysfs interaction
Driver Core: kill subsys_attribute and default sysfs ops
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 <[email protected]>
Cc: Michael C. Thompson <[email protected]>
Cc: Tyler Hicks <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 = ecryptfs_attr_show,
- .store = ecryptfs_attr_store
-};
+static decl_subsys(ecryptfs, NULL, NULL);
-static struct kobj_type ecryptfs_ktype = {
- .sysfs_ops = &ecryptfs_sysfs_ops
-};
-
-static decl_subsys(ecryptfs, &ecryptfs_ktype, NULL);
-
-static ssize_t version_show(struct ecryptfs_obj *obj, char *buff)
+static ssize_t version_show(struct kset *kset, char *buff)
{
return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
}
-static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version);
+static struct subsys_attribute version_attr = __ATTR_RO(version);
static struct ecryptfs_version_str_map_elem {
u32 flag;
@@ -795,7 +751,7 @@ static struct ecryptfs_version_str_map_elem {
{ECRYPTFS_VERSIONING_MULTKEY, "multiple keys per file"}
};
-static ssize_t version_str_show(struct ecryptfs_obj *obj, char *buff)
+static ssize_t version_str_show(struct kset *kset, char *buff)
{
int i;
int remaining = PAGE_SIZE;
@@ -822,7 +778,17 @@ out:
return total_written;
}
-static struct ecryptfs_attribute sysfs_attr_version_str = __ATTR_RO(version_str);
+static struct subsys_attribute version_attr_str = __ATTR_RO(version_str);
+
+static struct attribute *attributes[] = {
+ &version_attr.attr,
+ &version_attr_str.attr,
+ NULL,
+};
+
+static struct attribute_group attr_group = {
+ .attrs = attributes,
+};
static int do_sysfs_registration(void)
{
@@ -834,23 +800,11 @@ static int do_sysfs_registration(void)
"Unable to register ecryptfs sysfs subsystem\n");
goto out;
}
- rc = sysfs_create_file(&ecryptfs_subsys.kobj,
- &sysfs_attr_version.attr);
+ rc = sysfs_create_group(&ecryptfs_subsys.kobj, &attr_group);
if (rc) {
printk(KERN_ERR
- "Unable to create ecryptfs version attribute\n");
+ "Unable to create ecryptfs version attributes\n");
subsystem_unregister(&ecryptfs_subsys);
- goto out;
- }
- rc = sysfs_create_file(&ecryptfs_subsys.kobj,
- &sysfs_attr_version_str.attr);
- if (rc) {
- printk(KERN_ERR
- "Unable to create ecryptfs version_str attribute\n");
- sysfs_remove_file(&ecryptfs_subsys.kobj,
- &sysfs_attr_version.attr);
- subsystem_unregister(&ecryptfs_subsys);
- goto out;
}
out:
return rc;
@@ -858,10 +812,7 @@ out:
static void do_sysfs_unregistration(void)
{
- sysfs_remove_file(&ecryptfs_subsys.kobj,
- &sysfs_attr_version.attr);
- sysfs_remove_file(&ecryptfs_subsys.kobj,
- &sysfs_attr_version_str.attr);
+ sysfs_remove_group(&ecryptfs_subsys.kobj, &attr_group);
subsystem_unregister(&ecryptfs_subsys);
}
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 +-
kernel/module.c | 2 +-
kernel/params.c | 9 +++++----
kernel/power/main.c | 2 +-
mm/slub.c | 5 +++--
security/inode.c | 4 ++--
35 files changed, 84 insertions(+), 86 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/power.c b/arch/powerpc/platforms/pseries/power.c
index 73e6902..08d7a50 100644
--- a/arch/powerpc/platforms/pseries/power.c
+++ b/arch/powerpc/platforms/pseries/power.c
@@ -57,7 +57,7 @@ static struct subsys_attribute auto_poweron_attr = {
};
#ifndef CONFIG_PM
-decl_subsys(power,NULL,NULL);
+decl_subsys(power, NULL);
static struct attribute *g[] = {
&auto_poweron_attr.attr,
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 5245717..c022ccc 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, NULL);
+static decl_subsys(s390, NULL);
static int __init hypfs_init(void)
{
@@ -506,7 +506,7 @@ static int __init hypfs_init(void)
goto fail_diag;
}
}
- kobj_set_kset_s(&s390_subsys, hypervisor_subsys);
+ s390_subsys.kobj.kset = &hypervisor_subsys;
rc = subsystem_register(&s390_subsys);
if (rc)
goto fail_sysfs;
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index ce0856d..cae793a 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -418,7 +418,7 @@ static struct attribute_group ipl_unknown_attr_group = {
.attrs = ipl_unknown_attrs,
};
-static decl_subsys(ipl, NULL, NULL);
+static decl_subsys(ipl, NULL);
/*
* reipl section
@@ -590,7 +590,7 @@ static ssize_t reipl_type_store(struct kset *kset, const char *buf,
static struct subsys_attribute reipl_type_attr =
__ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
-static decl_subsys(reipl, NULL, NULL);
+static decl_subsys(reipl, NULL);
/*
* dump section
@@ -685,13 +685,13 @@ static ssize_t dump_type_store(struct kset *kset, const char *buf,
static struct subsys_attribute dump_type_attr =
__ATTR(dump_type, 0644, dump_type_show, dump_type_store);
-static decl_subsys(dump, NULL, NULL);
+static decl_subsys(dump, NULL);
/*
* Shutdown actions section
*/
-static decl_subsys(shutdown_actions, NULL, NULL);
+static decl_subsys(shutdown_actions, NULL);
/* on panic */
diff --git a/block/genhd.c b/block/genhd.c
index e609996..164db96 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -584,7 +584,7 @@ static struct kset_uevent_ops block_uevent_ops = {
.uevent = block_uevent,
};
-decl_subsys(block, &ktype_block, &block_uevent_ops);
+decl_subsys(block, &block_uevent_ops);
/*
* aggregate disk stat collector. Uses the same stats that the sysfs
@@ -720,8 +720,9 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
}
}
disk->minors = minors;
- kobj_set_kset_s(disk,block_subsys);
kobject_init(&disk->kobj);
+ disk->kobj.kset = &block_subsys;
+ disk->kobj.ktype = &ktype_block;
rand_initialize_disk(disk);
INIT_WORK(&disk->async_notify,
media_change_notify_thread);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 49d432d..fe90513 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, NULL);
+decl_subsys(acpi, NULL);
static int __init acpi_init(void)
{
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 9a19b07..6309560 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -166,7 +166,7 @@ static struct kset_uevent_ops bus_uevent_ops = {
.filter = bus_uevent_filter,
};
-static decl_subsys(bus, &bus_ktype, &bus_uevent_ops);
+static decl_subsys(bus, &bus_uevent_ops);
#ifdef CONFIG_HOTPLUG
@@ -639,6 +639,7 @@ int bus_add_driver(struct device_driver *drv)
if (error)
goto out_put_bus;
drv->kobj.kset = &bus->drivers;
+ drv->kobj.ktype = &driver_ktype;
error = kobject_register(&drv->kobj);
if (error)
goto out_put_bus;
@@ -851,6 +852,7 @@ int bus_register(struct bus_type * bus)
goto out;
bus->subsys.kobj.kset = &bus_subsys;
+ bus->subsys.kobj.ktype = &bus_ktype;
retval = subsystem_register(&bus->subsys);
if (retval)
@@ -868,7 +870,6 @@ int bus_register(struct bus_type * bus)
kobject_set_name(&bus->drivers.kobj, "drivers");
bus->drivers.kobj.parent = &bus->subsys.kobj;
- bus->drivers.ktype = &driver_ktype;
retval = kset_register(&bus->drivers);
if (retval)
goto bus_drivers_fail;
diff --git a/drivers/base/class.c b/drivers/base/class.c
index a863bb0..8ad9892 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, &class_ktype, NULL);
+static decl_subsys(class, NULL);
int class_create_file(struct class * cls, const struct class_attribute * attr)
@@ -150,6 +150,7 @@ int class_register(struct class * cls)
return error;
cls->subsys.kobj.kset = &class_subsys;
+ cls->subsys.kobj.ktype = &class_ktype;
error = subsystem_register(&cls->subsys);
if (!error) {
@@ -452,7 +453,7 @@ static struct kset_uevent_ops class_uevent_ops = {
.uevent = class_uevent,
};
-static decl_subsys(class_obj, &class_device_ktype, &class_uevent_ops);
+static decl_subsys(class_obj, &class_uevent_ops);
static int class_device_add_attrs(struct class_device * cd)
@@ -537,7 +538,8 @@ static struct class_device_attribute class_uevent_attr =
void class_device_initialize(struct class_device *class_dev)
{
- kobj_set_kset_s(class_dev, class_obj_subsys);
+ class_dev->kobj.kset = &class_obj_subsys;
+ class_dev->kobj.ktype = &class_device_ktype;
kobject_init(&class_dev->kobj);
INIT_LIST_HEAD(&class_dev->node);
}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3f4d6aa..161ea6e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -405,7 +405,7 @@ static struct device_attribute devt_attr =
* devices_subsys - structure to be registered with kobject core.
*/
-decl_subsys(devices, &device_ktype, &device_uevent_ops);
+decl_subsys(devices, &device_uevent_ops);
/**
@@ -525,7 +525,8 @@ static void klist_children_put(struct klist_node *n)
void device_initialize(struct device *dev)
{
- kobj_set_kset_s(dev, devices_subsys);
+ dev->kobj.kset = &devices_subsys;
+ dev->kobj.ktype = &device_ktype;
kobject_init(&dev->kobj);
klist_init(&dev->klist_children, klist_children_get,
klist_children_put);
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index 90c8629..336be04 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -15,11 +15,12 @@
#include "base.h"
-static decl_subsys(firmware, NULL, NULL);
+static decl_subsys(firmware, NULL);
int firmware_register(struct kset *s)
{
- kobj_set_kset_s(s, firmware_subsys);
+ s->kobj.kset = &firmware_subsys;
+ s->kobj.ktype = NULL;
return subsystem_register(s);
}
diff --git a/drivers/base/hypervisor.c b/drivers/base/hypervisor.c
index 7080b41..14e75e9 100644
--- a/drivers/base/hypervisor.c
+++ b/drivers/base/hypervisor.c
@@ -11,7 +11,7 @@
#include "base.h"
-decl_subsys(hypervisor, NULL, NULL);
+decl_subsys(hypervisor, NULL);
EXPORT_SYMBOL_GPL(hypervisor_subsys);
int __init hypervisor_init(void)
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index ac7ff6d..7cf19fc 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
/*
* declare system_subsys
*/
-static decl_subsys(system, &ktype_sysdev_class, NULL);
+static decl_subsys(system, NULL);
int sysdev_class_register(struct sysdev_class * cls)
{
@@ -139,6 +139,7 @@ int sysdev_class_register(struct sysdev_class * cls)
kobject_name(&cls->kset.kobj));
INIT_LIST_HEAD(&cls->drivers);
cls->kset.kobj.parent = &system_subsys.kobj;
+ cls->kset.kobj.ktype = &ktype_sysdev_class;
cls->kset.kobj.kset = &system_subsys;
return kset_register(&cls->kset);
}
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 3706b2b..905fcd7 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -744,7 +744,6 @@ static struct kobj_type ktype_mc_set_attribs = {
*/
static struct kset mc_kset = {
.kobj = {.ktype = &ktype_mc_set_attribs },
- .ktype = &ktype_mci,
};
@@ -767,6 +766,7 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
/* this instance become part of the mc_kset */
kobj_mci->kset = &mc_kset;
+ kobj_mci->ktype = &ktype_mci;
/* set the name of the mc<id> object */
err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx);
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 6942e06..fc567fa 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, &edd_ktype, NULL);
+static decl_subsys(edd, NULL);
/**
@@ -723,7 +723,8 @@ 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);
- kobj_set_kset_s(edev,edd_subsys);
+ edev->kobj.kset = &edd_subsys;
+ edev->kobj.ktype = &edd_ktype;
error = kobject_register(&edev->kobj);
if (!error)
edd_populate_dir(edev);
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 858a7b9..06ecdb9 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -583,8 +583,8 @@ static struct subsys_attribute *efi_subsys_attrs[] = {
NULL, /* maybe more in the future? */
};
-static decl_subsys(vars, &efivar_ktype, NULL);
-static decl_subsys(efi, NULL, NULL);
+static decl_subsys(vars, NULL);
+static decl_subsys(efi, NULL);
/*
* efivar_create_sysfs_entry()
@@ -629,7 +629,8 @@ 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);
- kobj_set_kset_s(new_efivar, vars_subsys);
+ new_efivar->kobj.kset = &vars_subsys;
+ new_efivar->kobj.ktype = &efivar_ktype;
i = kobject_register(&new_efivar->kobj);
if (i) {
kfree(short_name);
@@ -687,7 +688,7 @@ efivars_init(void)
goto out_free;
}
- kobj_set_kset_s(&vars_subsys, efi_subsys);
+ vars_subsys.kobj.kset = &efi_subsys;
error = subsystem_register(&vars_subsys);
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index ebb09e9..1382be6 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -964,8 +964,8 @@ static struct subsys_attribute *pdcs_subsys_attrs[] = {
NULL,
};
-static decl_subsys(paths, &ktype_pdcspath, NULL);
-static decl_subsys(stable, NULL, NULL);
+static decl_subsys(paths, NULL);
+static decl_subsys(stable, NULL);
/**
* pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
@@ -997,7 +997,8 @@ pdcs_register_pathentries(void)
if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
return err;
- kobj_set_kset_s(entry, paths_subsys);
+ entry->kobj.kset = &paths_subsys;
+ entry->kobj.ktype = &ktype_pdcspath;
if ((err = kobject_register(&entry->kobj)))
return err;
@@ -1072,7 +1073,7 @@ pdc_stable_init(void)
error = subsys_create_file(&stable_subsys, attr);
/* register the paths subsys as a subsystem of stable subsys */
- kobj_set_kset_s(&paths_subsys, stable_subsys);
+ paths_subsys.kobj.kset = &stable_subsys;
if ((rc = subsystem_register(&paths_subsys)))
goto fail_subsysreg;
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 01c351c..ce1cff0 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -96,7 +96,7 @@ static struct kobj_type hotplug_slot_ktype = {
.release = &hotplug_slot_release,
};
-decl_subsys_name(pci_hotplug_slots, slots, &hotplug_slot_ktype, NULL);
+decl_subsys_name(pci_hotplug_slots, slots, NULL);
/* these strings match up with the values in pci_bus_speed */
static char *pci_bus_speed_strings[] = {
@@ -633,7 +633,8 @@ int pci_hp_register (struct hotplug_slot *slot)
}
kobject_set_name(&slot->kobj, "%s", slot->name);
- kobj_set_kset_s(slot, pci_hotplug_slots_subsys);
+ slot->kobj.kset = &pci_hotplug_slots_subsys;
+ slot->kobj.ktype = &hotplug_slot_ktype;
/* this can fail if we have already registered a slot with the same name */
if (kobject_register(&slot->kobj)) {
@@ -701,7 +702,7 @@ static int __init pci_hotplug_init (void)
{
int result;
- kobj_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys);
+ pci_hotplug_slots_subsys.kobj.kset = &pci_bus_type.subsys;
result = subsystem_register(&pci_hotplug_slots_subsys);
if (result) {
err("Register subsys with error %d\n", result);
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 865f32b..606aae7 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -160,7 +160,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
if (!map_found) {
map_found = 1;
kobject_set_name(&idev->map_attr_kset.kobj,"maps");
- idev->map_attr_kset.ktype = &map_attr_type;
+ idev->map_attr_kset.kobj.ktype = &map_attr_type;
idev->map_attr_kset.kobj.parent = &idev->dev->kobj;
ret = kset_register(&idev->map_attr_kset);
if (ret)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 3bf0278..374ddbd 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, NULL);
+static decl_subsys(config, NULL);
static int __init configfs_init(void)
{
@@ -140,7 +140,7 @@ static int __init configfs_init(void)
if (!configfs_dir_cachep)
goto out;
- kobj_set_kset_s(&config_subsys, kernel_subsys);
+ config_subsys.kobj.kset = &kernel_subsys;
err = subsystem_register(&config_subsys);
if (err) {
kmem_cache_destroy(configfs_dir_cachep);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 6a713b3..f7f1351 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -426,13 +426,13 @@ exit:
}
EXPORT_SYMBOL_GPL(debugfs_rename);
-static decl_subsys(debug, NULL, NULL);
+static decl_subsys(debug, NULL);
static int __init debugfs_init(void)
{
int retval;
- kobj_set_kset_s(&debug_subsys, kernel_subsys);
+ debug_subsys.kobj.kset = &kernel_subsys;
retval = subsystem_register(&debug_subsys);
if (retval)
return retval;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 6353a83..18e4a17 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -166,9 +166,7 @@ static struct kobj_type dlm_ktype = {
.release = lockspace_kobj_release,
};
-static struct kset dlm_kset = {
- .ktype = &dlm_ktype,
-};
+static struct kset dlm_kset;
static int kobject_setup(struct dlm_ls *ls)
{
@@ -228,7 +226,7 @@ int dlm_lockspace_init(void)
spin_lock_init(&lslist_lock);
kobject_set_name(&dlm_kset.kobj, "dlm");
- kobj_set_kset_s(&dlm_kset, kernel_subsys);
+ dlm_kset.kobj.kset = &kernel_subsys;
error = kset_register(&dlm_kset);
if (error)
printk("dlm_lockspace_init: cannot register kset %d\n", error);
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 82b34f2..18ab012 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, NULL);
+static decl_subsys(ecryptfs, NULL);
static ssize_t version_show(struct kset *kset, char *buff)
{
@@ -794,6 +794,7 @@ static int do_sysfs_registration(void)
{
int rc;
+ ecryptfs_subsys.kobj.kset = &fs_subsys;
rc = subsystem_register(&ecryptfs_subsys);
if (rc) {
printk(KERN_ERR
@@ -841,7 +842,6 @@ static int __init ecryptfs_init(void)
printk(KERN_ERR "Failed to register filesystem\n");
goto out_free_kmem_caches;
}
- kobj_set_kset_s(&ecryptfs_subsys, fs_subsys);
rc = do_sysfs_registration();
if (rc) {
printk(KERN_ERR "sysfs registration failed\n");
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 9a68d69..2df24c6 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -744,8 +744,8 @@ static inline void unregister_fuseblk(void)
}
#endif
-static decl_subsys(fuse, NULL, NULL);
-static decl_subsys(connections, NULL, NULL);
+static decl_subsys(fuse, NULL);
+static decl_subsys(connections, NULL);
static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo)
{
@@ -795,12 +795,12 @@ static int fuse_sysfs_init(void)
{
int err;
- kobj_set_kset_s(&fuse_subsys, fs_subsys);
+ fuse_subsys.kobj.kset = &fs_subsys;
err = subsystem_register(&fuse_subsys);
if (err)
goto out_err;
- kobj_set_kset_s(&connections_subsys, fuse_subsys);
+ connections_subsys.kobj.kset = &fuse_subsys;
err = subsystem_register(&connections_subsys);
if (err)
goto out_fuse_unregister;
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index ae9e6a2..93e66b2 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -189,9 +189,7 @@ static struct kobj_type gdlm_ktype = {
.sysfs_ops = &gdlm_attr_ops,
};
-static struct kset gdlm_kset = {
- .ktype = &gdlm_ktype,
-};
+static struct kset gdlm_kset;
int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
{
@@ -224,7 +222,7 @@ int gdlm_sysfs_init(void)
int error;
kobject_set_name(&gdlm_kset.kobj, "lock_dlm");
- kobj_set_kset_s(&gdlm_kset, kernel_subsys);
+ gdlm_kset.kobj.kset = &kernel_subsys;
error = kset_register(&gdlm_kset);
if (error)
printk("lock_dlm: cannot register kset %d\n", error);
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 06e0b77..d7fa544 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -221,9 +221,7 @@ static struct kobj_type gfs2_ktype = {
.sysfs_ops = &gfs2_attr_ops,
};
-static struct kset gfs2_kset = {
- .ktype = &gfs2_ktype,
-};
+static struct kset gfs2_kset;
/*
* display struct lm_lockstruct fields
@@ -551,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");
- kobj_set_kset_s(&gfs2_kset, fs_subsys);
+ gfs2_kset.kobj.kset = &fs_subsys;
return kset_register(&gfs2_kset);
}
diff --git a/fs/namespace.c b/fs/namespace.c
index 0608388..a4a3f70 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -41,7 +41,7 @@ static struct kmem_cache *mnt_cache __read_mostly;
static struct rw_semaphore namespace_sem;
/* /sys/fs */
-decl_subsys(fs, NULL, NULL);
+decl_subsys(fs, NULL);
EXPORT_SYMBOL_GPL(fs_subsys);
static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index a4882c8..dead319 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -157,7 +157,7 @@ int mlog_sys_init(struct kset *o2cb_subsys)
mlog_attr_ptrs[i] = NULL;
kobject_set_name(&mlog_kset.kobj, "logmask");
- kobj_set_kset_s(&mlog_kset, *o2cb_subsys);
+ mlog_kset.kobj.kset = o2cb_subsys;
return kset_register(&mlog_kset);
}
diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c
index 64f6f37..880d013 100644
--- a/fs/ocfs2/cluster/sys.c
+++ b/fs/ocfs2/cluster/sys.c
@@ -72,7 +72,7 @@ static struct kobj_type o2cb_subsys_type = {
};
/* gives us o2cb_subsys */
-static decl_subsys(o2cb, NULL, NULL);
+static decl_subsys(o2cb, NULL);
static ssize_t
o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 27d1785..4d6fba0 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -361,9 +361,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
/* if the kobject has no ktype, then we assume that it is a subsystem
* itself, and use ops for it.
*/
- if (kobj->kset && kobj->kset->ktype)
- ops = kobj->kset->ktype->sysfs_ops;
- else if (kobj->ktype)
+ if (kobj->ktype)
ops = kobj->ktype->sysfs_ops;
else
ops = &subsys_sysfs_ops;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 4a0d27f..4dcf478 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -128,7 +128,6 @@ struct kset_uevent_ops {
* define the attribute callbacks and other common events that happen to
* a kobject.
*
- * @ktype: the struct kobj_type for this specific kset
* @list: the list of all kobjects for this kset
* @list_lock: a lock for iterating over the kobjects
* @kobj: the embedded kobject for this kset (recursion, isn't it fun...)
@@ -138,7 +137,6 @@ struct kset_uevent_ops {
* desired.
*/
struct kset {
- struct kobj_type *ktype;
struct list_head list;
spinlock_t list_lock;
struct kobject kobj;
@@ -166,12 +164,9 @@ static inline void kset_put(struct kset * k)
kobject_put(&k->kobj);
}
-static inline struct kobj_type * get_ktype(struct kobject * k)
+static inline struct kobj_type *get_ktype(struct kobject *kobj)
{
- if (k->kset && k->kset->ktype)
- return k->kset->ktype;
- else
- return k->ktype;
+ return kobj->ktype;
}
extern struct kobject * kset_find_obj(struct kset *, const char *);
@@ -184,16 +179,14 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
#define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
-#define decl_subsys(_name,_type,_uevent_ops) \
+#define decl_subsys(_name,_uevent_ops) \
struct kset _name##_subsys = { \
.kobj = { .k_name = __stringify(_name) }, \
- .ktype = _type, \
.uevent_ops =_uevent_ops, \
}
-#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
+#define decl_subsys_name(_varname,_name,_uevent_ops) \
struct kset _varname##_subsys = { \
.kobj = { .k_name = __stringify(_name) }, \
- .ktype = _type, \
.uevent_ops =_uevent_ops, \
}
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 65daa53..094e2bc 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -94,7 +94,7 @@ static struct bin_attribute notes_attr = {
.read = ¬es_read,
};
-decl_subsys(kernel, NULL, NULL);
+decl_subsys(kernel, NULL);
EXPORT_SYMBOL_GPL(kernel_subsys);
static struct attribute * kernel_attrs[] = {
diff --git a/kernel/module.c b/kernel/module.c
index 3202c99..8240939 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1221,7 +1221,7 @@ int mod_sysfs_init(struct module *mod)
err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
if (err)
goto out;
- kobj_set_kset_s(&mod->mkobj, module_subsys);
+ mod->mkobj.kobj.kset = &module_subsys;
mod->mkobj.mod = mod;
kobject_init(&mod->mkobj.kobj);
diff --git a/kernel/params.c b/kernel/params.c
index 16f269e..d4304b3 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -30,6 +30,8 @@
#define DEBUGP(fmt, a...)
#endif
+static struct kobj_type module_ktype;
+
static inline char dash2underscore(char c)
{
if (c == '-')
@@ -560,7 +562,8 @@ static void __init kernel_param_sysfs_setup(const char *name,
BUG_ON(!mk);
mk->mod = THIS_MODULE;
- kobj_set_kset_s(mk, module_subsys);
+ mk->kobj.kset = &module_subsys;
+ mk->kobj.ktype = &module_ktype;
kobject_set_name(&mk->kobj, name);
kobject_init(&mk->kobj);
ret = kobject_add(&mk->kobj);
@@ -682,8 +685,6 @@ static struct sysfs_ops module_sysfs_ops = {
.store = module_attr_store,
};
-static struct kobj_type module_ktype;
-
static int uevent_filter(struct kset *kset, struct kobject *kobj)
{
struct kobj_type *ktype = get_ktype(kobj);
@@ -697,7 +698,7 @@ static struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter,
};
-decl_subsys(module, &module_ktype, &module_uevent_ops);
+decl_subsys(module, &module_uevent_ops);
int module_sysfs_initialized;
static struct kobj_type module_ktype = {
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 3cdf95b..ce9bf12 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -273,7 +273,7 @@ EXPORT_SYMBOL(pm_suspend);
#endif /* CONFIG_SUSPEND */
-decl_subsys(power,NULL,NULL);
+decl_subsys(power, NULL);
/**
diff --git a/mm/slub.c b/mm/slub.c
index bcdb2c8..b821fdb 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3978,7 +3978,7 @@ static struct kset_uevent_ops slab_uevent_ops = {
.filter = uevent_filter,
};
-static decl_subsys(slab, &slab_ktype, &slab_uevent_ops);
+static decl_subsys(slab, &slab_uevent_ops);
#define ID_STR_LENGTH 64
@@ -4041,8 +4041,9 @@ static int sysfs_slab_add(struct kmem_cache *s)
name = create_unique_id(s);
}
- kobj_set_kset_s(s, slab_subsys);
kobject_set_name(&s->kobj, name);
+ s->kobj.kset = &slab_subsys;
+ s->kobj.ktype = &slab_ktype;
kobject_init(&s->kobj);
err = kobject_add(&s->kobj);
if (err)
diff --git a/security/inode.c b/security/inode.c
index b28a8ac..9e42f5f 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -315,13 +315,13 @@ void securityfs_remove(struct dentry *dentry)
}
EXPORT_SYMBOL_GPL(securityfs_remove);
-static decl_subsys(security, NULL, NULL);
+static decl_subsys(security, NULL);
static int __init securityfs_init(void)
{
int retval;
- kobj_set_kset_s(&security_subsys, kernel_subsys);
+ security_subsys.kobj.kset = &kernel_subsys;
retval = subsystem_register(&security_subsys);
if (retval)
return retval;
--
1.5.3.4
What a confusing name for a macro...
Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 struct kset_uevent_ops for the kset
+ * @parent_kobj: the parent kobject of this kset, if any.
+ * @parent_kset: the parent kset of this kset, if any.
+ *
+ * This function creates a kset structure dynamically. This structure can
+ * then be registered with the system and show up in sysfs with a call to
+ * kset_register(). When you are finished with this structure, if
+ * kset_register() has been called, call kset_unregister() and the
+ * structure will be dynamically freed when it is no longer being used.
+ *
+ * NOTE, you can not have both a @parent_kobj and a @parent_kset, pick one
+ * or the other.
+ */
+static struct kset *kset_create(const char *name,
+ struct kset_uevent_ops *uevent_ops,
+ struct kobject *parent_kobj,
+ struct kset *parent_kset)
+{
+ struct kset *kset;
+
+ if ((parent_kobj) && (parent_kset)) {
+ printk(KERN_WARNING "Can not specify both a parent kset and a "
+ "parent kobject for %s\n", __FUNCTION__);
+ WARN_ON(1);
+ return ERR_PTR(-EINVAL);
+ }
+
+ kset = kzalloc(sizeof(*kset), GFP_KERNEL);
+ if (!kset)
+ return ERR_PTR(-ENOMEM);
+ kobject_set_name(&kset->kobj, name);
+ kset->uevent_ops = uevent_ops;
+ kset->kobj.parent = parent_kobj;
+ kset->kobj.kset = parent_kset;
+ kset->kobj.ktype = &kset_type;
+
+ return kset;
+}
+
+/**
+ * kset_create_and_register - create a struct kset dynamically and register it with sysfs
+ *
+ * @name: the name for the kset
+ * @uevent_ops: a struct kset_uevent_ops for the kset
+ * @parent_kobj: the parent kobject of this kset, if any.
+ * @parent_kset: the parent kset of this kset, if any.
+ *
+ * This function creates a kset structure dynamically and registers it
+ * with sysfs. When you are finished with this structure, call
+ * kset_unregister() and the structure will be dynamically freed when it
+ * is no longer being used.
+ *
+ * NOTE, you can not have both a @parent_kobj and a @parent_kset, pick one
+ * or the other.
+ */
+struct kset *kset_create_and_register(const char *name,
+ struct kset_uevent_ops *uevent_ops,
+ struct kobject *parent_kobj,
+ struct kset *parent_kset)
+{
+ struct kset *kset;
+ int error;
+
+ kset = kset_create(name, uevent_ops, parent_kobj, parent_kset);
+ if (IS_ERR(kset))
+ return kset;
+ error = kset_register(kset);
+ if (error) {
+ kfree(kset);
+ return ERR_PTR(error);
+ }
+ return kset;
+}
+EXPORT_SYMBOL_GPL(kset_create_and_register);
+
EXPORT_SYMBOL(kobject_init);
EXPORT_SYMBOL(kobject_register);
EXPORT_SYMBOL(kobject_unregister);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Acked-by: Chris Wright <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Signed-off-by: Joel Becker <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Cc: Mike Halcrow <[email protected]>
Cc: Phillip Hellewell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 *fs_kset;
+EXPORT_SYMBOL_GPL(fs_kset);
static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
{
@@ -1861,10 +1861,12 @@ void __init mnt_init(void)
if (err)
printk(KERN_WARNING "%s: sysfs_init error: %d\n",
__FUNCTION__, err);
- err = subsystem_register(&fs_subsys);
- if (err)
- printk(KERN_WARNING "%s: subsystem_register error: %d\n",
- __FUNCTION__, err);
+ fs_kset = kset_create_and_register("fs", NULL, NULL, NULL);
+ if (IS_ERR(fs_kset)) {
+ printk(KERN_WARNING "%s: kset create error: %d\n",
+ __FUNCTION__, (int)PTR_ERR(fs_kset));
+ fs_kset = NULL;
+ }
init_rootfs();
init_mount_tree();
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b3ec4a4..e0e52c6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1476,7 +1476,7 @@ extern void drop_collected_mounts(struct vfsmount *);
extern int vfs_statfs(struct dentry *, struct kstatfs *);
/* /sys/fs */
-extern struct kset fs_subsys;
+extern struct kset *fs_kset;
#define FLOCK_VERIFY_READ 1
#define FLOCK_VERIFY_WRITE 2
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Steven Whitehouse <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Cc: Steven Whitehouse <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Steven Whitehouse <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
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 <[email protected]>
Cc: Kristen Carlson Accardi <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 values in pci_bus_speed */
static char *pci_bus_speed_strings[] = {
"33 MHz PCI", /* 0x00 */
@@ -633,7 +631,7 @@ int pci_hp_register (struct hotplug_slot *slot)
}
kobject_set_name(&slot->kobj, "%s", slot->name);
- slot->kobj.kset = &pci_hotplug_slots_subsys;
+ slot->kobj.kset = pci_hotplug_slots_kset;
slot->kobj.ktype = &hotplug_slot_ktype;
/* this can fail if we have already registered a slot with the same name */
@@ -702,9 +700,10 @@ static int __init pci_hotplug_init (void)
{
int result;
- pci_hotplug_slots_subsys.kobj.kset = &pci_bus_type.subsys;
- result = subsystem_register(&pci_hotplug_slots_subsys);
- if (result) {
+ pci_hotplug_slots_kset = kset_create_and_register("slots", NULL, NULL,
+ &pci_bus_type.subsys);
+ if (IS_ERR(pci_hotplug_slots_kset)) {
+ result = PTR_ERR(pci_hotplug_slots_kset);
err("Register subsys with error %d\n", result);
goto exit;
}
@@ -716,9 +715,9 @@ static int __init pci_hotplug_init (void)
info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
goto exit;
-
+
err_subsys:
- subsystem_unregister(&pci_hotplug_slots_subsys);
+ kset_unregister(pci_hotplug_slots_kset);
exit:
return result;
}
@@ -726,7 +725,7 @@ exit:
static void __exit pci_hotplug_exit (void)
{
cpci_hotplug_exit();
- subsystem_unregister(&pci_hotplug_slots_subsys);
+ kset_unregister(pci_hotplug_slots_kset);
}
module_init(pci_hotplug_init);
@@ -738,7 +737,7 @@ MODULE_LICENSE("GPL");
module_param(debug, bool, 0644);
MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
-EXPORT_SYMBOL_GPL(pci_hotplug_slots_subsys);
+EXPORT_SYMBOL_GPL(pci_hotplug_slots_kset);
EXPORT_SYMBOL_GPL(pci_hp_register);
EXPORT_SYMBOL_GPL(pci_hp_deregister);
EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index a080fed..71c23db 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -130,7 +130,7 @@ struct kobj_type ktype_dlpar_io = {
struct kset dlpar_io_kset = {
.kobj = {.ktype = &ktype_dlpar_io,
- .parent = &pci_hotplug_slots_subsys.kobj},
+ .parent = &pci_hotplug_slots_kset->kobj},
.ktype = &ktype_dlpar_io,
};
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index ab4cb6e..8f67e8f 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -174,7 +174,7 @@ extern int pci_hp_register (struct hotplug_slot *slot);
extern int pci_hp_deregister (struct hotplug_slot *slot);
extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
struct hotplug_slot_info *info);
-extern struct kset pci_hotplug_slots_subsys;
+extern struct kset *pci_hotplug_slots_kset;
/* PCI Setting Record (Type 0) */
struct hpp_type0 {
--
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 <[email protected]>
Cc: Kristen Carlson Accardi <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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. 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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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);
printk(KERN_WARNING "%s: can not create kset %d\n",
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 9c351db..494e00c 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -222,7 +222,7 @@ int gdlm_sysfs_init(void)
int error;
gdlm_kset = kset_create_and_register("lock_dlm", NULL,
- NULL, &kernel_subsys);
+ NULL, kernel_kset);
if (IS_ERR(gdlm_kset)) {
error = PTR_ERR(gdlm_kset);
printk(KERN_WARNING "%s: can not create kset %d\n",
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 84525a6..4196ad8 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -188,8 +188,8 @@ struct kset _name##_subsys = { \
.uevent_ops =_uevent_ops, \
}
-/* The global /sys/kernel/ subsystem for people to chain off of */
-extern struct kset kernel_subsys;
+/* The global /sys/kernel/ kset for people to chain off of */
+extern struct kset *kernel_kset;
/* The global /sys/hypervisor/ subsystem */
extern struct kset hypervisor_subsys;
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 094e2bc..b4f5116 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/kexec.h>
#include <linux/sched.h>
+#include <linux/err.h>
#define KERNEL_ATTR_RO(_name) \
static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
@@ -94,8 +95,8 @@ static struct bin_attribute notes_attr = {
.read = ¬es_read,
};
-decl_subsys(kernel, NULL);
-EXPORT_SYMBOL_GPL(kernel_subsys);
+struct kset *kernel_kset;
+EXPORT_SYMBOL_GPL(kernel_kset);
static struct attribute * kernel_attrs[] = {
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
@@ -116,24 +117,42 @@ static struct attribute_group kernel_attr_group = {
static int __init ksysfs_init(void)
{
- int error = subsystem_register(&kernel_subsys);
- if (!error)
- error = sysfs_create_group(&kernel_subsys.kobj,
- &kernel_attr_group);
+ int error;
- if (!error && notes_size > 0) {
+ kernel_kset = kset_create_and_register("kernel", NULL, NULL, NULL);
+ if (IS_ERR(kernel_kset)) {
+ error = PTR_ERR(kernel_kset);
+ goto exit;
+ }
+ error = sysfs_create_group(&kernel_kset->kobj, &kernel_attr_group);
+ if (error)
+ goto kset_exit;
+
+ if (notes_size > 0) {
notes_attr.size = notes_size;
- error = sysfs_create_bin_file(&kernel_subsys.kobj,
- ¬es_attr);
+ error = sysfs_create_bin_file(&kernel_kset->kobj, ¬es_attr);
+ if (error)
+ goto group_exit;
}
/*
* Create "/sys/kernel/uids" directory and corresponding root user's
* directory under it.
*/
- if (!error)
- error = uids_kobject_init();
-
+ error = uids_kobject_init();
+ if (error)
+ goto notes_exit;
+
+ return 0;
+
+notes_exit:
+ if (notes_size > 0)
+ sysfs_remove_bin_file(&kernel_kset->kobj, ¬es_attr);
+group_exit:
+ sysfs_remove_group(&kernel_kset->kobj, &kernel_attr_group);
+kset_exit:
+ kset_unregister(kernel_kset);
+exit:
return error;
}
diff --git a/kernel/user.c b/kernel/user.c
index 0f3aa02..75d9f9b 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -198,8 +198,8 @@ int __init uids_kobject_init(void)
int error;
/* create under /sys/kernel dir */
- uids_kobject.parent = &kernel_subsys.kobj;
- uids_kobject.kset = &kernel_subsys;
+ uids_kobject.parent = &kernel_kset->kobj;
+ uids_kobject.kset = kernel_kset;
kobject_set_name(&uids_kobject, "uids");
kobject_init(&uids_kobject);
diff --git a/security/inode.c b/security/inode.c
index 9071d81..787b719 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -322,7 +322,7 @@ static int __init securityfs_init(void)
int retval;
security_kset = kset_create_and_register("security", NULL, NULL,
- &kernel_subsys);
+ kernel_kset);
if (IS_ERR(security_kset))
return PTR_ERR(security_kset);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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.
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 devices_subsys to devices_kset to catch all users of the
variable.
Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 @@ struct device * device_find_child(struct device *parent, void *data,
int __init devices_init(void)
{
- return subsystem_register(&devices_subsys);
+ devices_kset = kset_create_and_register("devices", &device_uevent_ops,
+ NULL, NULL);
+ if (IS_ERR(devices_kset))
+ return PTR_ERR(devices_kset);
+ return 0;
}
EXPORT_SYMBOL_GPL(device_for_each_child);
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index 56e8eaa..f51cbc1 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -34,7 +34,7 @@ void device_shutdown(void)
{
struct device * dev, *devn;
- list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.list,
+ list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
kobj.entry) {
if (dev->bus && dev->bus->shutdown) {
dev_dbg(dev, "shutdown\n");
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 7cf19fc..7693c95 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -25,8 +25,6 @@
#include "base.h"
-extern struct kset devices_subsys;
-
#define to_sysdev(k) container_of(k, struct sys_device, kobj)
#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
@@ -459,7 +457,7 @@ int sysdev_resume(void)
int __init system_bus_init(void)
{
- system_subsys.kobj.parent = &devices_subsys.kobj;
+ system_subsys.kobj.parent = &devices_kset->kobj;
return subsystem_register(&system_subsys);
}
--
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
+ * 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 people to chain off of */
extern struct kset *kernel_kset;
-/* The global /sys/hypervisor/ subsystem */
-extern struct kset hypervisor_subsys;
+/* The global /sys/hypervisor/ kset for people to chain off of */
+extern struct kset *hypervisor_kset;
extern int __must_check subsystem_register(struct kset *);
extern void subsystem_unregister(struct kset *);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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, kset.kobj.entry) {
list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
pr_debug(" %s\n", kobject_name(&err_dev->kobj));
__sysdev_resume(err_dev);
@@ -439,7 +432,7 @@ int sysdev_resume(void)
pr_debug("Resuming System Devices\n");
- list_for_each_entry(cls, &system_subsys.list, kset.kobj.entry) {
+ list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
struct sys_device * sysdev;
pr_debug("Resuming type '%s':\n",
@@ -457,8 +450,11 @@ int sysdev_resume(void)
int __init system_bus_init(void)
{
- system_subsys.kobj.parent = &devices_kset->kobj;
- return subsystem_register(&system_subsys);
+ system_kset = kset_create_and_register("system", NULL,
+ NULL, devices_kset);
+ if (IS_ERR(system_kset))
+ return PTR_ERR(system_kset);
+ return 0;
}
EXPORT_SYMBOL_GPL(sysdev_register);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Christoph Lameter <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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", &slab_uevent_ops,
+ NULL, NULL);
+ if (IS_ERR(slab_kset)) {
printk(KERN_ERR "Cannot register slab subsystem.\n");
- return -ENOSYS;
+ return PTR_ERR(slab_kset);
}
slab_state = SYSFS;
--
1.5.3.4
/sys/kernel is where these things should go.
Also updated the documentation and tool that used this directory.
Cc: Kay Sievers <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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. We also
rename module_subsys to module_kset to catch all users of the variable.
Cc: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 kernel_param_sysfs_setup(const char *name,
BUG_ON(!mk);
mk->mod = THIS_MODULE;
- mk->kobj.kset = &module_subsys;
+ mk->kobj.kset = module_kset;
mk->kobj.ktype = &module_ktype;
kobject_set_name(&mk->kobj, name);
kobject_init(&mk->kobj);
@@ -698,7 +698,7 @@ static struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter,
};
-decl_subsys(module, &module_uevent_ops);
+struct kset *module_kset;
int module_sysfs_initialized;
static struct kobj_type module_ktype = {
@@ -712,9 +712,11 @@ static int __init param_sysfs_init(void)
{
int ret;
- ret = subsystem_register(&module_subsys);
- if (ret < 0) {
- printk(KERN_WARNING "%s (%d): subsystem_register error: %d\n",
+ module_kset = kset_create_and_register("module", &module_uevent_ops,
+ NULL, NULL);
+ if (IS_ERR(module_kset)) {
+ ret = PTR_ERR(module_kset);
+ printk(KERN_WARNING "%s (%d): error creating kset: %d\n",
__FILE__, __LINE__, ret);
return ret;
}
@@ -726,14 +728,7 @@ static int __init param_sysfs_init(void)
}
subsys_initcall(param_sysfs_init);
-#else
-#if 0
-static struct sysfs_ops module_sysfs_ops = {
- .show = NULL,
- .store = NULL,
-};
-#endif
-#endif
+#endif /* CONFIG_SYSFS */
EXPORT_SYMBOL(param_set_byte);
EXPORT_SYMBOL(param_get_byte);
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 is 0 */
@@ -57,7 +58,7 @@ static struct subsys_attribute auto_poweron_attr = {
};
#ifndef CONFIG_PM
-decl_subsys(power, NULL);
+struct kset *power_kset;
static struct attribute *g[] = {
&auto_poweron_attr.attr,
@@ -70,18 +71,16 @@ static struct attribute_group attr_group = {
static int __init pm_init(void)
{
- int error = subsystem_register(&power_subsys);
- if (!error)
- error = sysfs_create_group(&power_subsys.kobj, &attr_group);
- return error;
+ power_kset = kset_create_and_register("power", NULL, NULL, NULL);
+ if (IS_ERR(power_kset))
+ return PTR_ERR(power_kset);
+ return sysfs_create_group(&power_kset->kobj, &attr_group);
}
core_initcall(pm_init);
#else
-extern struct kset power_subsys;
-
static int __init apo_pm_init(void)
{
- return (subsys_create_file(&power_subsys, &auto_poweron_attr));
+ return (subsys_create_file(power_kset, &auto_poweron_attr));
}
__initcall(apo_pm_init);
#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 63a6bf9..8f4a38c 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -192,6 +192,8 @@ struct kset _name##_subsys = { \
extern struct kset *kernel_kset;
/* The global /sys/hypervisor/ kset for people to chain off of */
extern struct kset *hypervisor_kset;
+/* The global /sys/power/ kset for people to chain off of */
+extern struct kset *power_kset;
extern int __must_check subsystem_register(struct kset *);
extern void subsystem_unregister(struct kset *);
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 8b15f77..05fbe67 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -698,7 +698,7 @@ static struct attribute_group attr_group = {
static int __init pm_disk_init(void)
{
- return sysfs_create_group(&power_subsys.kobj, &attr_group);
+ return sysfs_create_group(&power_kset->kobj, &attr_group);
}
core_initcall(pm_disk_init);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index ce9bf12..6651a3c 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -21,6 +21,7 @@
#include <linux/freezer.h>
#include <linux/vmstat.h>
#include <linux/syscalls.h>
+#include <linux/err.h>
#include "power.h"
@@ -273,8 +274,7 @@ EXPORT_SYMBOL(pm_suspend);
#endif /* CONFIG_SUSPEND */
-decl_subsys(power, NULL);
-
+struct kset *power_kset;
/**
* state - control system power state.
@@ -383,10 +383,10 @@ static struct attribute_group attr_group = {
static int __init pm_init(void)
{
- int error = subsystem_register(&power_subsys);
- if (!error)
- error = sysfs_create_group(&power_subsys.kobj,&attr_group);
- return error;
+ power_kset = kset_create_and_register("power", NULL, NULL, NULL);
+ if (IS_ERR(power_kset))
+ return PTR_ERR(power_kset);
+ return sysfs_create_group(&power_kset->kobj, &attr_group);
}
core_initcall(pm_init);
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 195dc46..1083e6b 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -63,8 +63,6 @@ static struct subsys_attribute _name##_attr = { \
.store = _name##_store, \
}
-extern struct kset power_subsys;
-
/* Preferred image size in bytes (default 500 MB) */
extern unsigned long image_size;
extern int in_suspend;
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Michael Holzheu <[email protected]>
Cc: Cornelia Huck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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,
+ &bus->subsys.kobj, NULL);
+ if (IS_ERR(bus->devices_kset)) {
+ retval = PTR_ERR(bus->devices_kset);
goto bus_devices_fail;
+ }
kobject_set_name(&bus->drivers.kobj, "drivers");
bus->drivers.kobj.parent = &bus->subsys.kobj;
@@ -895,7 +896,7 @@ bus_attrs_fail:
bus_probe_files_fail:
kset_unregister(&bus->drivers);
bus_drivers_fail:
- kset_unregister(&bus->devices);
+ kset_unregister(bus->devices_kset);
bus_devices_fail:
bus_remove_file(bus, &bus_attr_uevent);
bus_uevent_fail:
@@ -917,7 +918,7 @@ void bus_unregister(struct bus_type * bus)
bus_remove_attrs(bus);
remove_probe_files(bus);
kset_unregister(&bus->drivers);
- kset_unregister(&bus->devices);
+ kset_unregister(bus->devices_kset);
bus_remove_file(bus, &bus_attr_uevent);
subsystem_unregister(&bus->subsys);
}
diff --git a/include/linux/device.h b/include/linux/device.h
index 2e15822..094d71d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -55,7 +55,7 @@ struct bus_type {
struct kset subsys;
struct kset drivers;
- struct kset devices;
+ struct kset *devices_kset;
struct klist klist_devices;
struct klist klist_drivers;
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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);
bus_remove_attrs(bus);
remove_probe_files(bus);
- kset_unregister(&bus->drivers);
+ kset_unregister(bus->drivers_kset);
kset_unregister(bus->devices_kset);
bus_remove_file(bus, &bus_attr_uevent);
subsystem_unregister(&bus->subsys);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index eb11475..1c9770d 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,7 +185,7 @@ void driver_unregister(struct device_driver * drv)
*/
struct device_driver *driver_find(const char *name, struct bus_type *bus)
{
- struct kobject *k = kset_find_obj(&bus->drivers, name);
+ struct kobject *k = kset_find_obj(bus->drivers_kset, name);
if (k)
return to_drv(k);
return NULL;
diff --git a/include/linux/device.h b/include/linux/device.h
index 094d71d..f6eaa33 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -54,7 +54,7 @@ struct bus_type {
struct module * owner;
struct kset subsys;
- struct kset drivers;
+ struct kset *drivers_kset;
struct kset *devices_kset;
struct klist klist_devices;
struct klist klist_drivers;
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 bus_type * bus;
--
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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, &pci_bus_type.klist_devices.k_list);
- spin_unlock(&pci_bus_type.klist_devices.k_lock);
+ list_splice(&sorted_devices, &device_klist->k_list);
+ spin_unlock(&device_klist->k_lock);
}
static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
diff --git a/include/linux/device.h b/include/linux/device.h
index 86eff9d..6d56a34 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -118,6 +118,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
unbound */
extern struct kset *bus_get_kset(struct bus_type *bus);
+extern struct klist *bus_get_device_klist(struct bus_type *bus);
struct device_driver {
const char * name;
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 *devices_kset;
+ struct klist klist_devices;
+ struct klist klist_drivers;
+ struct blocking_notifier_head bus_notifier;
+ unsigned int drivers_autoprobe:1;
+ struct bus_type *bus;
+};
+
+/* initialisation functions */
extern int devices_init(void);
extern int buses_init(void);
extern int classes_init(void);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index e502ca6..80a4919 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -18,7 +18,7 @@
#include "power/power.h"
#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
-#define to_bus(obj) container_of(obj, struct bus_type, subsys.kobj)
+#define to_bus(obj) container_of(obj, struct bus_type_private, subsys.kobj)
/*
* sysfs bindings for drivers
@@ -33,13 +33,17 @@ static int __must_check bus_rescan_devices_helper(struct device *dev,
static struct bus_type *bus_get(struct bus_type *bus)
{
- return bus ? container_of(kset_get(&bus->subsys),
- struct bus_type, subsys) : NULL;
+ if (bus) {
+ kset_get(&bus->p->subsys);
+ return bus;
+ }
+ return NULL;
}
static void bus_put(struct bus_type *bus)
{
- kset_put(&bus->subsys);
+ if (bus)
+ kset_put(&bus->p->subsys);
}
static ssize_t
@@ -105,11 +109,11 @@ static ssize_t
bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
{
struct bus_attribute * bus_attr = to_bus_attr(attr);
- struct bus_type * bus = to_bus(kobj);
+ struct bus_type_private *bus_priv = to_bus(kobj);
ssize_t ret = 0;
if (bus_attr->show)
- ret = bus_attr->show(bus, buf);
+ ret = bus_attr->show(bus_priv->bus, buf);
return ret;
}
@@ -118,11 +122,11 @@ bus_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count)
{
struct bus_attribute * bus_attr = to_bus_attr(attr);
- struct bus_type * bus = to_bus(kobj);
+ struct bus_type_private *bus_priv = to_bus(kobj);
ssize_t ret = 0;
if (bus_attr->store)
- ret = bus_attr->store(bus, buf, count);
+ ret = bus_attr->store(bus_priv->bus, buf, count);
return ret;
}
@@ -135,7 +139,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
{
int error;
if (bus_get(bus)) {
- error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
+ error = sysfs_create_file(&bus->p->subsys.kobj, &attr->attr);
bus_put(bus);
} else
error = -EINVAL;
@@ -145,7 +149,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
{
if (bus_get(bus)) {
- sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
+ sysfs_remove_file(&bus->p->subsys.kobj, &attr->attr);
bus_put(bus);
}
}
@@ -238,16 +242,16 @@ static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf)
{
- return sprintf(buf, "%d\n", bus->drivers_autoprobe);
+ return sprintf(buf, "%d\n", bus->p->drivers_autoprobe);
}
static ssize_t store_drivers_autoprobe(struct bus_type *bus,
const char *buf, size_t count)
{
if (buf[0] == '0')
- bus->drivers_autoprobe = 0;
+ bus->p->drivers_autoprobe = 0;
else
- bus->drivers_autoprobe = 1;
+ bus->p->drivers_autoprobe = 1;
return count;
}
@@ -301,7 +305,7 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
if (!bus)
return -EINVAL;
- klist_iter_init_node(&bus->klist_devices, &i,
+ klist_iter_init_node(&bus->p->klist_devices, &i,
(start ? &start->knode_bus : NULL));
while ((dev = next_device(&i)) && !error)
error = fn(dev, data);
@@ -334,7 +338,7 @@ struct device * bus_find_device(struct bus_type *bus,
if (!bus)
return NULL;
- klist_iter_init_node(&bus->klist_devices, &i,
+ klist_iter_init_node(&bus->p->klist_devices, &i,
(start ? &start->knode_bus : NULL));
while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev))
@@ -380,7 +384,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
if (!bus)
return -EINVAL;
- klist_iter_init_node(&bus->klist_drivers, &i,
+ klist_iter_init_node(&bus->p->klist_drivers, &i,
start ? &start->knode_bus : NULL);
while ((drv = next_driver(&i)) && !error)
error = fn(drv, data);
@@ -450,12 +454,12 @@ int bus_add_device(struct device * dev)
error = device_add_attrs(bus, dev);
if (error)
goto out_put;
- error = sysfs_create_link(&bus->devices_kset->kobj,
+ error = sysfs_create_link(&bus->p->devices_kset->kobj,
&dev->kobj, dev->bus_id);
if (error)
goto out_id;
error = sysfs_create_link(&dev->kobj,
- &dev->bus->subsys.kobj, "subsystem");
+ &dev->bus->p->subsys.kobj, "subsystem");
if (error)
goto out_subsys;
error = make_deprecated_bus_links(dev);
@@ -467,7 +471,7 @@ int bus_add_device(struct device * dev)
out_deprecated:
sysfs_remove_link(&dev->kobj, "subsystem");
out_subsys:
- sysfs_remove_link(&bus->devices_kset->kobj, dev->bus_id);
+ sysfs_remove_link(&bus->p->devices_kset->kobj, dev->bus_id);
out_id:
device_remove_attrs(bus, dev);
out_put:
@@ -489,11 +493,11 @@ void bus_attach_device(struct device * dev)
if (bus) {
dev->is_registered = 1;
- if (bus->drivers_autoprobe)
+ if (bus->p->drivers_autoprobe)
ret = device_attach(dev);
WARN_ON(ret < 0);
if (ret >= 0)
- klist_add_tail(&dev->knode_bus, &bus->klist_devices);
+ klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
else
dev->is_registered = 0;
}
@@ -513,7 +517,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_kset->kobj, dev->bus_id);
+ sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev->bus_id);
device_remove_attrs(dev->bus, dev);
if (dev->is_registered) {
dev->is_registered = 0;
@@ -639,18 +643,18 @@ 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_kset;
+ drv->kobj.kset = bus->p->drivers_kset;
drv->kobj.ktype = &driver_ktype;
error = kobject_register(&drv->kobj);
if (error)
goto out_put_bus;
- if (drv->bus->drivers_autoprobe) {
+ if (drv->bus->p->drivers_autoprobe) {
error = driver_attach(drv);
if (error)
goto out_unregister;
}
- klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
+ klist_add_tail(&drv->knode_bus, &bus->p->klist_drivers);
module_add_driver(drv->owner, drv);
error = driver_create_file(drv, &driver_attr_uevent);
@@ -829,7 +833,7 @@ static ssize_t bus_uevent_store(struct bus_type *bus,
enum kobject_action action;
if (kobject_action_type(buf, count, &action) == 0)
- kobject_uevent(&bus->subsys.kobj, action);
+ kobject_uevent(&bus->p->subsys.kobj, action);
return count;
}
static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
@@ -845,17 +849,26 @@ static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
int bus_register(struct bus_type * bus)
{
int retval;
+ struct bus_type_private *priv;
+
+ priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->bus = bus;
+ bus->p = priv;
- BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
+ BLOCKING_INIT_NOTIFIER_HEAD(&priv->bus_notifier);
- retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
+ retval = kobject_set_name(&priv->subsys.kobj, "%s", bus->name);
if (retval)
goto out;
- bus->subsys.kobj.kset = bus_kset;
- bus->subsys.kobj.ktype = &bus_ktype;
+ priv->subsys.kobj.kset = bus_kset;
+ priv->subsys.kobj.ktype = &bus_ktype;
+ priv->drivers_autoprobe = 1;
- retval = subsystem_register(&bus->subsys);
+ retval = kset_register(&priv->subsys);
if (retval)
goto out;
@@ -863,24 +876,25 @@ int bus_register(struct bus_type * bus)
if (retval)
goto bus_uevent_fail;
- bus->devices_kset = kset_create_and_register("devices", NULL,
- &bus->subsys.kobj, NULL);
- if (IS_ERR(bus->devices_kset)) {
- retval = PTR_ERR(bus->devices_kset);
+ priv->devices_kset = kset_create_and_register("devices", NULL,
+ &priv->subsys.kobj,
+ NULL);
+ if (IS_ERR(priv->devices_kset)) {
+ retval = PTR_ERR(priv->devices_kset);
goto bus_devices_fail;
}
- 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);
+ priv->drivers_kset = kset_create_and_register("drivers", NULL,
+ &priv->subsys.kobj,
+ NULL);
+ if (IS_ERR(priv->drivers_kset)) {
+ retval = PTR_ERR(priv->drivers_kset);
goto bus_drivers_fail;
}
- klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
- klist_init(&bus->klist_drivers, NULL, NULL);
+ klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
+ klist_init(&priv->klist_drivers, NULL, NULL);
- bus->drivers_autoprobe = 1;
retval = add_probe_files(bus);
if (retval)
goto bus_probe_files_fail;
@@ -895,13 +909,14 @@ int bus_register(struct bus_type * bus)
bus_attrs_fail:
remove_probe_files(bus);
bus_probe_files_fail:
- kset_unregister(bus->drivers_kset);
+ kset_unregister(bus->p->drivers_kset);
bus_drivers_fail:
- kset_unregister(bus->devices_kset);
+ kset_unregister(bus->p->devices_kset);
bus_devices_fail:
bus_remove_file(bus, &bus_attr_uevent);
bus_uevent_fail:
- subsystem_unregister(&bus->subsys);
+ kset_unregister(&bus->p->subsys);
+ kfree(bus->p);
out:
return retval;
}
@@ -918,33 +933,34 @@ void bus_unregister(struct bus_type * bus)
pr_debug("bus %s: unregistering\n", bus->name);
bus_remove_attrs(bus);
remove_probe_files(bus);
- kset_unregister(bus->drivers_kset);
- kset_unregister(bus->devices_kset);
+ kset_unregister(bus->p->drivers_kset);
+ kset_unregister(bus->p->devices_kset);
bus_remove_file(bus, &bus_attr_uevent);
- subsystem_unregister(&bus->subsys);
+ kset_unregister(&bus->p->subsys);
+ kfree(bus->p);
}
int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
{
- return blocking_notifier_chain_register(&bus->bus_notifier, nb);
+ return blocking_notifier_chain_register(&bus->p->bus_notifier, nb);
}
EXPORT_SYMBOL_GPL(bus_register_notifier);
int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
{
- return blocking_notifier_chain_unregister(&bus->bus_notifier, nb);
+ return blocking_notifier_chain_unregister(&bus->p->bus_notifier, nb);
}
EXPORT_SYMBOL_GPL(bus_unregister_notifier);
struct kset *bus_get_kset(struct bus_type *bus)
{
- return &bus->subsys;
+ return &bus->p->subsys;
}
EXPORT_SYMBOL_GPL(bus_get_kset);
struct klist *bus_get_device_klist(struct bus_type *bus)
{
- return &bus->klist_devices;
+ return &bus->p->klist_devices;
}
EXPORT_SYMBOL_GPL(bus_get_device_klist);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 80188ec..d4753d4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -749,7 +749,7 @@ int device_add(struct device *dev)
/* notify clients of device entry (new way) */
if (dev->bus)
- blocking_notifier_call_chain(&dev->bus->bus_notifier,
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_ADD_DEVICE, dev);
error = device_create_file(dev, &uevent_attr);
@@ -797,7 +797,7 @@ int device_add(struct device *dev)
device_pm_remove(dev);
PMError:
if (dev->bus)
- blocking_notifier_call_chain(&dev->bus->bus_notifier,
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
device_remove_attrs(dev);
AttrsError:
@@ -975,7 +975,7 @@ void device_del(struct device * dev)
if (platform_notify_remove)
platform_notify_remove(dev);
if (dev->bus)
- blocking_notifier_call_chain(&dev->bus->bus_notifier,
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
device_pm_remove(dev);
kobject_uevent(&dev->kobj, KOBJ_REMOVE);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 7ac474d..7bf0e67 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -38,7 +38,7 @@ static void driver_bound(struct device *dev)
dev->bus_id, dev->driver->name);
if (dev->bus)
- blocking_notifier_call_chain(&dev->bus->bus_notifier,
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_BOUND_DRIVER, dev);
klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
@@ -296,7 +296,7 @@ static void __device_release_driver(struct device * dev)
klist_remove(&dev->knode_driver);
if (dev->bus)
- blocking_notifier_call_chain(&dev->bus->bus_notifier,
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_UNBIND_DRIVER,
dev);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1c9770d..f94be40 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,7 +185,7 @@ void driver_unregister(struct device_driver * drv)
*/
struct device_driver *driver_find(const char *name, struct bus_type *bus)
{
- struct kobject *k = kset_find_obj(bus->drivers_kset, name);
+ struct kobject *k = kset_find_obj(bus->p->drivers_kset, name);
if (k)
return to_drv(k);
return NULL;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index fb56092..d56a05f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -497,12 +497,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
* if the probe was successful, and make sure any forced probes of
* new devices fail.
*/
- spin_lock(&platform_bus_type.klist_drivers.k_lock);
+ spin_lock(&platform_bus_type.p->klist_drivers.k_lock);
drv->probe = NULL;
if (code == 0 && list_empty(&drv->driver.klist_devices.k_list))
retval = -ENODEV;
drv->driver.probe = platform_drv_probe_fail;
- spin_unlock(&platform_bus_type.klist_drivers.k_lock);
+ spin_unlock(&platform_bus_type.p->klist_drivers.k_lock);
if (code != retval)
platform_driver_unregister(drv);
diff --git a/include/linux/device.h b/include/linux/device.h
index 6d56a34..3701269 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -35,6 +35,7 @@ struct device_driver;
struct class;
struct class_device;
struct bus_type;
+struct bus_type_private;
struct bus_attribute {
struct attribute attr;
@@ -51,15 +52,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
struct bus_type {
const char * name;
-
- struct kset subsys;
- struct kset *drivers_kset;
- struct kset *devices_kset;
- struct klist klist_devices;
- struct klist klist_drivers;
-
- struct blocking_notifier_head bus_notifier;
-
struct bus_attribute * bus_attrs;
struct device_attribute * dev_attrs;
struct driver_attribute * drv_attrs;
@@ -75,7 +67,7 @@ struct bus_type {
int (*resume_early)(struct device * dev);
int (*resume)(struct device * dev);
- unsigned int drivers_autoprobe:1;
+ struct bus_type_private *p;
};
extern int __must_check bus_register(struct bus_type * bus);
--
1.5.3.4
From: Kay Sievers <[email protected]>
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 = -EIO;
+
+ kattr = container_of(attr, struct kobj_attribute, attr);
+ if (kattr->store)
+ ret = kattr->store(kobj, kattr, buf, count);
+ return ret;
+}
+
+struct sysfs_ops kobj_sysfs_ops = {
+ .show = kobj_attr_show,
+ .store = kobj_attr_store,
+};
static void dir_release(struct kobject *kobj)
{
--
1.5.3.4
From: Kay Sievers <[email protected]>
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 <[email protected]>
Cc: Mike Halcrow <[email protected]>
Cc: Phillip Hellewell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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[] = {
&version_attr.attr,
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index b4f5116..ea07bcf 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -18,30 +18,34 @@
#include <linux/err.h>
#define KERNEL_ATTR_RO(_name) \
-static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
#define KERNEL_ATTR_RW(_name) \
-static struct subsys_attribute _name##_attr = \
+static struct kobj_attribute _name##_attr = \
__ATTR(_name, 0644, _name##_show, _name##_store)
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
/* current uevent sequence number */
-static ssize_t uevent_seqnum_show(struct kset *kset, char *page)
+static ssize_t uevent_seqnum_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum);
+ return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
}
KERNEL_ATTR_RO(uevent_seqnum);
/* uevent helper program, used during early boo */
-static ssize_t uevent_helper_show(struct kset *kset, char *page)
+static ssize_t uevent_helper_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return sprintf(page, "%s\n", uevent_helper);
+ return sprintf(buf, "%s\n", uevent_helper);
}
-static ssize_t uevent_helper_store(struct kset *kset, const char *page, size_t count)
+static ssize_t uevent_helper_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
if (count+1 > UEVENT_HELPER_PATH_LEN)
return -ENOENT;
- memcpy(uevent_helper, page, count);
+ memcpy(uevent_helper, buf, count);
uevent_helper[count] = '\0';
if (count && uevent_helper[count-1] == '\n')
uevent_helper[count-1] = '\0';
@@ -51,21 +55,24 @@ KERNEL_ATTR_RW(uevent_helper);
#endif
#ifdef CONFIG_KEXEC
-static ssize_t kexec_loaded_show(struct kset *kset, char *page)
+static ssize_t kexec_loaded_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return sprintf(page, "%d\n", !!kexec_image);
+ return sprintf(buf, "%d\n", !!kexec_image);
}
KERNEL_ATTR_RO(kexec_loaded);
-static ssize_t kexec_crash_loaded_show(struct kset *kset, char *page)
+static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return sprintf(page, "%d\n", !!kexec_crash_image);
+ return sprintf(buf, "%d\n", !!kexec_crash_image);
}
KERNEL_ATTR_RO(kexec_crash_loaded);
-static ssize_t vmcoreinfo_show(struct kset *kset, char *page)
+static ssize_t vmcoreinfo_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return sprintf(page, "%lx %x\n",
+ return sprintf(buf, "%lx %x\n",
paddr_vmcoreinfo_note(),
(unsigned int)vmcoreinfo_max_size);
}
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 05fbe67..c8062cc 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -557,7 +557,8 @@ static const char * const hibernation_modes[] = {
* supports it (as determined by having hibernation_ops).
*/
-static ssize_t disk_show(struct kset *kset, char *buf)
+static ssize_t disk_show(struct kobject *kobj, struct kobj_attribut *attr,
+ char *buf)
{
int i;
char *start = buf;
@@ -587,7 +588,8 @@ static ssize_t disk_show(struct kset *kset, char *buf)
}
-static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
+static ssize_t disk_store(struct kobject *kobj, struct kobj_attribut *attr,
+ const char *buf, size_t n)
{
int error = 0;
int i;
@@ -632,13 +634,15 @@ static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
power_attr(disk);
-static ssize_t resume_show(struct kset *kset, char *buf)
+static ssize_t resume_show(struct kobject *kobj, struct kobj_attribut *attr,
+ char *buf)
{
return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
MINOR(swsusp_resume_device));
}
-static ssize_t resume_store(struct kset *kset, const char *buf, size_t n)
+static ssize_t resume_store(struct kobject *kobj, struct kobj_attribut *attr,
+ const char *buf, size_t n)
{
unsigned int maj, min;
dev_t res;
@@ -664,12 +668,14 @@ static ssize_t resume_store(struct kset *kset, const char *buf, size_t n)
power_attr(resume);
-static ssize_t image_size_show(struct kset *kset, char *buf)
+static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribut *attr,
+ char *buf)
{
return sprintf(buf, "%lu\n", image_size);
}
-static ssize_t image_size_store(struct kset *kset, const char *buf, size_t n)
+static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribut *attr,
+ const char *buf, size_t n)
{
unsigned long size;
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 6651a3c..f0f506b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -287,7 +287,8 @@ struct kset *power_kset;
* proper enumerated value, and initiates a suspend transition.
*/
-static ssize_t state_show(struct kset *kset, char *buf)
+static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
{
char *s = buf;
#ifdef CONFIG_SUSPEND
@@ -308,7 +309,8 @@ static ssize_t state_show(struct kset *kset, char *buf)
return (s - buf);
}
-static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
+static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
suspend_state_t state = PM_SUSPEND_STANDBY;
@@ -345,13 +347,15 @@ power_attr(state);
#ifdef CONFIG_PM_TRACE
int pm_trace_enabled;
-static ssize_t pm_trace_show(struct kset *kset, char *buf)
+static ssize_t pm_trace_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
{
return sprintf(buf, "%d\n", pm_trace_enabled);
}
static ssize_t
-pm_trace_store(struct kset *kset, const char *buf, size_t n)
+pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t n)
{
int val;
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 1083e6b..2093c3a 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -54,7 +54,7 @@ extern int pfn_is_nosave(unsigned long);
extern struct mutex pm_mutex;
#define power_attr(_name) \
-static struct subsys_attribute _name##_attr = { \
+static struct kobj_attribute _name##_attr = { \
.attr = { \
.name = __stringify(_name), \
.mode = 0644, \
diff --git a/lib/kobject.c b/lib/kobject.c
index bc2ba8c..dda6614 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -524,9 +524,8 @@ static void dir_release(struct kobject *kobj)
}
static struct kobj_type dir_ktype = {
+ .sysfs_ops = &kobj_sysfs_ops,
.release = dir_release,
- .sysfs_ops = NULL,
- .default_attrs = NULL,
};
/**
@@ -699,7 +698,8 @@ static void kset_release(struct kobject *kobj)
kfree(kset);
}
-static struct kobj_type kset_type = {
+static struct kobj_type kset_ktype = {
+ .sysfs_ops = &kobj_sysfs_ops,
.release = kset_release,
};
@@ -741,7 +741,7 @@ static struct kset *kset_create(const char *name,
kset->uevent_ops = uevent_ops;
kset->kobj.parent = parent_kobj;
kset->kobj.kset = parent_kset;
- kset->kobj.ktype = &kset_type;
+ kset->kobj.ktype = &kset_ktype;
return kset;
}
--
1.5.3.4
From: Kay Sievers <[email protected]>
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 <[email protected]>
Cc: Srivatsa Vaddagiri <[email protected]>
Signed-off-by: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
+++ b/kernel/user.c
@@ -115,7 +115,7 @@ static void sched_switch_user(struct task_struct *p) { }
#if defined(CONFIG_FAIR_USER_SCHED) && defined(CONFIG_SYSFS)
-static struct kobject uids_kobject; /* represents /sys/kernel/uids directory */
+static struct kset *uids_kset; /* represents the /sys/kernel/uids/ directory */
static DEFINE_MUTEX(uids_mutex);
static inline void uids_mutex_lock(void)
@@ -128,86 +128,84 @@ static inline void uids_mutex_unlock(void)
mutex_unlock(&uids_mutex);
}
-/* return cpu shares held by the user */
-static ssize_t cpu_shares_show(struct kset *kset, char *buffer)
+/* uid directory attributes */
+static ssize_t cpu_shares_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
{
- struct user_struct *up = container_of(kset, struct user_struct, kset);
+ struct user_struct *up = container_of(kobj, struct user_struct, kobj);
- return sprintf(buffer, "%lu\n", sched_group_shares(up->tg));
+ return sprintf(buf, "%lu\n", sched_group_shares(up->tg));
}
-/* modify cpu shares held by the user */
-static ssize_t cpu_shares_store(struct kset *kset, const char *buffer,
- size_t size)
+static ssize_t cpu_shares_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t size)
{
- struct user_struct *up = container_of(kset, struct user_struct, kset);
+ struct user_struct *up = container_of(kobj, struct user_struct, kobj);
unsigned long shares;
int rc;
- sscanf(buffer, "%lu", &shares);
+ sscanf(buf, "%lu", &shares);
rc = sched_group_set_shares(up->tg, shares);
return (rc ? rc : size);
}
-static void user_attr_init(struct subsys_attribute *sa, char *name, int mode)
+static struct kobj_attribute cpu_share_attr =
+ __ATTR(cpu_share, 0644, cpu_shares_show, cpu_shares_store);
+
+/* default attributes per uid directory */
+static struct attribute *uids_attributes[] = {
+ &cpu_share_attr.attr,
+ NULL
+};
+
+/* the lifetime of user_struct is not managed by the core (now) */
+static void uids_release(struct kobject *kobj)
{
- sa->attr.name = name;
- sa->attr.mode = mode;
- sa->show = cpu_shares_show;
- sa->store = cpu_shares_store;
+ return;
}
-/* Create "/sys/kernel/uids/<uid>" directory and
- * "/sys/kernel/uids/<uid>/cpu_share" file for this user.
- */
-static int user_kobject_create(struct user_struct *up)
+static struct kobj_type uids_ktype = {
+ .sysfs_ops = &kobj_sysfs_ops,
+ .default_attrs = uids_attributes,
+ .release = uids_release,
+};
+
+/* create /sys/kernel/uids/<uid>/cpu_share file for this user */
+static int uids_user_create(struct user_struct *up)
{
- struct kset *kset = &up->kset;
- struct kobject *kobj = &kset->kobj;
+ struct kobject *kobj = &up->kobj;
int error;
- memset(kset, 0, sizeof(struct kset));
- kobj->parent = &uids_kobject; /* create under /sys/kernel/uids dir */
- kobject_set_name(kobj, "%d", up->uid);
- kset_init(kset);
- user_attr_init(&up->user_attr, "cpu_share", 0644);
-
+ memset(kobj, 0, sizeof(struct kobject));
+ kobject_init(kobj);
+ kobj->ktype = &uids_ktype;
+ kobj->kset = uids_kset;
+ kobject_set_name(&up->kobj, "%d", up->uid);
error = kobject_add(kobj);
if (error)
goto done;
- error = sysfs_create_file(kobj, &up->user_attr.attr);
- if (error)
- kobject_del(kobj);
-
kobject_uevent(kobj, KOBJ_ADD);
-
done:
return error;
}
-/* create these in sysfs filesystem:
+/* create these entries in sysfs:
* "/sys/kernel/uids" directory
* "/sys/kernel/uids/0" directory (for root user)
* "/sys/kernel/uids/0/cpu_share" file (for root user)
*/
-int __init uids_kobject_init(void)
+int __init uids_sysfs_init(void)
{
- int error;
+ uids_kset = kset_create_and_register("uids", NULL, NULL, kernel_kset);
+ if (IS_ERR(uids_kset))
+ return PTR_ERR(uids_kset);
- /* create under /sys/kernel dir */
- uids_kobject.parent = &kernel_kset->kobj;
- uids_kobject.kset = kernel_kset;
- kobject_set_name(&uids_kobject, "uids");
- kobject_init(&uids_kobject);
-
- error = kobject_add(&uids_kobject);
- if (!error)
- error = user_kobject_create(&root_user);
-
- return error;
+ return uids_user_create(&root_user);
}
/* work function to remove sysfs directory for a user and free up
@@ -216,7 +214,6 @@ int __init uids_kobject_init(void)
static void remove_user_sysfs_dir(struct work_struct *w)
{
struct user_struct *up = container_of(w, struct user_struct, work);
- struct kobject *kobj = &up->kset.kobj;
unsigned long flags;
int remove_user = 0;
@@ -238,9 +235,9 @@ static void remove_user_sysfs_dir(struct work_struct *w)
if (!remove_user)
goto done;
- sysfs_remove_file(kobj, &up->user_attr.attr);
- kobject_uevent(kobj, KOBJ_REMOVE);
- kobject_del(kobj);
+ kobject_uevent(&up->kobj, KOBJ_REMOVE);
+ kobject_del(&up->kobj);
+ kobject_put(&up->kobj);
sched_destroy_user(up);
key_put(up->uid_keyring);
@@ -267,7 +264,8 @@ static inline void free_user(struct user_struct *up, unsigned long flags)
#else /* CONFIG_FAIR_USER_SCHED && CONFIG_SYSFS */
-static inline int user_kobject_create(struct user_struct *up) { return 0; }
+int uids_sysfs_init(void) { return 0; }
+static inline int uids_user_create(struct user_struct *up) { return 0; }
static inline void uids_mutex_lock(void) { }
static inline void uids_mutex_unlock(void) { }
@@ -324,7 +322,7 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
struct hlist_head *hashent = uidhashentry(ns, uid);
struct user_struct *up;
- /* Make uid_hash_find() + user_kobject_create() + uid_hash_insert()
+ /* Make uid_hash_find() + uids_user_create() + uid_hash_insert()
* atomic.
*/
uids_mutex_lock();
@@ -365,7 +363,7 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
return NULL;
}
- if (user_kobject_create(new)) {
+ if (uids_user_create(new)) {
sched_destroy_user(new);
key_put(new->uid_keyring);
key_put(new->session_keyring);
--
1.5.3.4
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 <[email protected]>
Cc: Mike Halcrow <[email protected]>
Cc: Phillip Hellewell <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 = __ATTR_RO(version_str);
-
static struct attribute *attributes[] = {
&version_attr.attr,
- &version_attr_str.attr,
NULL,
};
--
1.5.3.4
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 <[email protected]>
Cc: Matt Domsch <[email protected]>
Cc: Matt Tolentino <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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?
- */
- list_for_each_entry_safe(search_efivar, n, &efivar_list, list) {
- strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024);
- strsize2 = utf8_strsize(new_var->VariableName, 1024);
- if (strsize1 == strsize2 &&
- !memcmp(&(search_efivar->var.VariableName),
- new_var->VariableName, strsize1) &&
- !efi_guidcmp(search_efivar->var.VendorGuid,
- new_var->VendorGuid)) {
- found = 1;
- break;
- }
- }
- if (found) {
- spin_unlock(&efivars_lock);
- return -EINVAL;
- }
-
- /* now *really* create the variable via EFI */
- status = efi.set_variable(new_var->VariableName,
- &new_var->VendorGuid,
- new_var->Attributes,
- new_var->DataSize,
- new_var->Data);
-
- if (status != EFI_SUCCESS) {
- printk(KERN_WARNING "efivars: set_variable() failed: status=%lx\n",
- status);
- spin_unlock(&efivars_lock);
- return -EIO;
- }
- spin_unlock(&efivars_lock);
-
- /* Create the entry in sysfs. Locking is not required here */
- status = efivar_create_sysfs_entry(utf8_strsize(new_var->VariableName,
- 1024), new_var->VariableName, &new_var->VendorGuid);
- if (status) {
- printk(KERN_WARNING "efivars: variable created, but sysfs entry wasn't.\n");
- }
- return count;
-}
-
-static ssize_t
-efivar_delete(struct kset *kset, const char *buf, size_t count)
-{
- struct efi_variable *del_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?
- */
- list_for_each_entry_safe(search_efivar, n, &efivar_list, list) {
- strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024);
- strsize2 = utf8_strsize(del_var->VariableName, 1024);
- if (strsize1 == strsize2 &&
- !memcmp(&(search_efivar->var.VariableName),
- del_var->VariableName, strsize1) &&
- !efi_guidcmp(search_efivar->var.VendorGuid,
- del_var->VendorGuid)) {
- found = 1;
- break;
- }
- }
- if (!found) {
- spin_unlock(&efivars_lock);
- return -EINVAL;
- }
- /* force the Attributes/DataSize to 0 to ensure deletion */
- del_var->Attributes = 0;
- del_var->DataSize = 0;
-
- status = efi.set_variable(del_var->VariableName,
- &del_var->VendorGuid,
- del_var->Attributes,
- del_var->DataSize,
- del_var->Data);
-
- if (status != EFI_SUCCESS) {
- printk(KERN_WARNING "efivars: set_variable() failed: status=%lx\n",
- status);
- spin_unlock(&efivars_lock);
- return -EIO;
- }
- list_del(&search_efivar->list);
- /* We need to release this lock before unregistering. */
- spin_unlock(&efivars_lock);
- efivar_unregister(search_efivar);
-
- /* It's dead Jim.... */
- return count;
-}
-
-static VAR_SUBSYS_ATTR(new_var, 0200, dummy, efivar_create);
-static VAR_SUBSYS_ATTR(del_var, 0200, dummy, efivar_delete);
-
-static struct subsys_attribute *var_subsys_attrs[] = {
- &var_subsys_attr_new_var,
- &var_subsys_attr_del_var,
- NULL,
-};
-
/*
* Let's not leave out systab information that snuck into
* the efivars driver
@@ -724,16 +585,6 @@ efivars_init(void)
}
} while (status != EFI_NOT_FOUND);
- /*
- * Now add attributes to allow creation of new vars
- * and deletion of existing ones...
- */
-
- for (i = 0; (attr = var_subsys_attrs[i]) && !error; i++) {
- if (attr->show && attr->store)
- error = subsys_create_file(&vars_subsys, attr);
- }
-
/* Don't forget the systab entry */
for (i = 0; (attr = efi_subsys_attrs[i]) && !error; i++) {
--
1.5.3.4
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 <[email protected]>
Cc: Matt Domsch <[email protected]>
Cc: Matt Tolentino <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 = efi_subsys_attrs,
+};
+
+
static decl_subsys(vars, NULL);
static decl_subsys(efi, NULL);
@@ -522,9 +521,8 @@ efivars_init(void)
efi_status_t status = EFI_NOT_FOUND;
efi_guid_t vendor_guid;
efi_char16_t *variable_name;
- struct subsys_attribute *attr;
unsigned long variable_name_size = 1024;
- int i, error = 0;
+ int error = 0;
if (!efi_enabled)
return -ENODEV;
@@ -586,12 +584,7 @@ efivars_init(void)
} while (status != EFI_NOT_FOUND);
/* Don't forget the systab entry */
-
- for (i = 0; (attr = efi_subsys_attrs[i]) && !error; i++) {
- if (attr->show)
- error = subsys_create_file(&efi_subsys, attr);
- }
-
+ error = sysfs_create_group(&efi_subsys.kobj, &efi_subsys_attr_group);
if (error)
printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error);
else
--
1.5.3.4
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 <[email protected]>
Cc: Matt Domsch <[email protected]>
Cc: Matt Tolentino <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Matt Domsch <[email protected]>
Cc: Matt Tolentino <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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)
}
subsystem_unregister(&vars_subsys);
- firmware_unregister(&efi_subsys);
+ kset_unregister(efi_kset);
}
module_init(efivars_init);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Matt Domsch <[email protected]>
Cc: Matt Tolentino <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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.
Cc: Kay Sievers <[email protected]>
Cc: Cliff Brake <[email protected]>
Cc: Dirk Behme <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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, &sleep_while_idle_attr);
if (error)
- printk(KERN_ERR "subsys_create_file failed: %d\n", error);
+ printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
if (cpu_is_omap16xx()) {
/* configure LOW_PWR pin */
--
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 <[email protected]>
Cc: Manish Ahuja <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
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 <[email protected]>
Cc: Michael Holzheu <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Volker Sameske <[email protected]>
Cc: Cornelia Huck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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) \
{ \
unsigned long long value; \
@@ -186,25 +189,27 @@ static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
_value = value; \
return len; \
} \
-static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
+static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
__ATTR(_name,(S_IRUGO | S_IWUSR), \
sys_##_prefix##_##_name##_show, \
sys_##_prefix##_##_name##_store);
#define DEFINE_IPL_ATTR_STR_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, _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) \
{ \
if (sscanf(buf, _fmt_in, _value) != 1) \
return -EINVAL; \
return len; \
} \
-static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
+static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
__ATTR(_name,(S_IRUGO | S_IWUSR), \
sys_##_prefix##_##_name##_show, \
sys_##_prefix##_##_name##_store);
@@ -270,14 +275,16 @@ void __init setup_ipl_info(void)
struct ipl_info ipl_info;
EXPORT_SYMBOL_GPL(ipl_info);
-static ssize_t ipl_type_show(struct kset *kset, char *page)
+static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *page)
{
return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
}
-static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
+static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
-static ssize_t sys_ipl_device_show(struct kset *kset, char *page)
+static ssize_t sys_ipl_device_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
@@ -292,7 +299,7 @@ static ssize_t sys_ipl_device_show(struct kset *kset, char *page)
}
}
-static struct subsys_attribute sys_ipl_device_attr =
+static struct kobj_attribute sys_ipl_device_attr =
__ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr,
@@ -367,7 +374,8 @@ static struct attribute_group ipl_fcp_attr_group = {
/* CCW ipl device attributes */
-static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page)
+static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
char loadparm[LOADPARM_LEN + 1] = {};
@@ -379,7 +387,7 @@ static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page)
return sprintf(page, "%s\n", loadparm);
}
-static struct subsys_attribute sys_ipl_ccw_loadparm_attr =
+static struct kobj_attribute sys_ipl_ccw_loadparm_attr =
__ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
static struct attribute *ipl_ccw_attrs[] = {
@@ -465,7 +473,8 @@ static void reipl_get_ascii_loadparm(char *loadparm)
strstrip(loadparm);
}
-static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page)
+static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
char buf[LOADPARM_LEN + 1];
@@ -473,7 +482,8 @@ static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page)
return sprintf(page, "%s\n", buf);
}
-static ssize_t reipl_ccw_loadparm_store(struct kset *kset,
+static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
const char *buf, size_t len)
{
int i, lp_len;
@@ -500,7 +510,7 @@ static ssize_t reipl_ccw_loadparm_store(struct kset *kset,
return len;
}
-static struct subsys_attribute sys_reipl_ccw_loadparm_attr =
+static struct kobj_attribute sys_reipl_ccw_loadparm_attr =
__ATTR(loadparm, 0644, reipl_ccw_loadparm_show,
reipl_ccw_loadparm_store);
@@ -568,13 +578,15 @@ static int reipl_set_type(enum ipl_type type)
return 0;
}
-static ssize_t reipl_type_show(struct kset *kset, char *page)
+static ssize_t reipl_type_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
return sprintf(page, "%s\n", ipl_type_str(reipl_type));
}
-static ssize_t reipl_type_store(struct kset *kset, const char *buf,
- size_t len)
+static ssize_t reipl_type_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t len)
{
int rc = -EINVAL;
@@ -587,7 +599,7 @@ static ssize_t reipl_type_store(struct kset *kset, const char *buf,
return (rc != 0) ? rc : len;
}
-static struct subsys_attribute reipl_type_attr =
+static struct kobj_attribute reipl_type_attr =
__ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
static decl_subsys(reipl, NULL);
@@ -663,13 +675,15 @@ static int dump_set_type(enum dump_type type)
return 0;
}
-static ssize_t dump_type_show(struct kset *kset, char *page)
+static ssize_t dump_type_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
return sprintf(page, "%s\n", dump_type_str(dump_type));
}
-static ssize_t dump_type_store(struct kset *kset, const char *buf,
- size_t len)
+static ssize_t dump_type_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t len)
{
int rc = -EINVAL;
@@ -682,7 +696,7 @@ static ssize_t dump_type_store(struct kset *kset, const char *buf,
return (rc != 0) ? rc : len;
}
-static struct subsys_attribute dump_type_attr =
+static struct kobj_attribute dump_type_attr =
__ATTR(dump_type, 0644, dump_type_show, dump_type_store);
static decl_subsys(dump, NULL);
@@ -695,13 +709,15 @@ static decl_subsys(shutdown_actions, NULL);
/* on panic */
-static ssize_t on_panic_show(struct kset *kset, char *page)
+static ssize_t on_panic_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *page)
{
return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
}
-static ssize_t on_panic_store(struct kset *kset, const char *buf,
- size_t len)
+static ssize_t on_panic_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t len)
{
if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
on_panic_action = SHUTDOWN_REIPL;
@@ -717,7 +733,7 @@ static ssize_t on_panic_store(struct kset *kset, const char *buf,
return len;
}
-static struct subsys_attribute on_panic_attr =
+static struct kobj_attribute on_panic_attr =
__ATTR(on_panic, 0644, on_panic_show, on_panic_store);
void do_reipl(void)
@@ -961,7 +977,7 @@ static int __init reipl_init(void)
rc = firmware_register(&reipl_subsys);
if (rc)
return rc;
- rc = subsys_create_file(&reipl_subsys, &reipl_type_attr);
+ rc = sysfs_create_file(&reipl_subsys.kobj, &reipl_type_attr);
if (rc) {
firmware_unregister(&reipl_subsys);
return rc;
@@ -1050,7 +1066,7 @@ static int __init dump_init(void)
rc = firmware_register(&dump_subsys);
if (rc)
return rc;
- rc = subsys_create_file(&dump_subsys, &dump_type_attr);
+ rc = sysfs_create_file(&dump_subsys.kobj, &dump_type_attr);
if (rc) {
firmware_unregister(&dump_subsys);
return rc;
@@ -1072,7 +1088,7 @@ static int __init shutdown_actions_init(void)
rc = firmware_register(&shutdown_actions_subsys);
if (rc)
return rc;
- rc = subsys_create_file(&shutdown_actions_subsys, &on_panic_attr);
+ rc = sysfs_create_file(&shutdown_actions_subsys.kobj, &on_panic_attr);
if (rc) {
firmware_unregister(&shutdown_actions_subsys);
return rc;
--
1.5.3.4
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 <[email protected]>
Cc: Michael Holzheu <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Volker Sameske <[email protected]>
Cc: Cornelia Huck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 (rc)
goto out;
- rc = sysfs_create_bin_file(&ipl_subsys.kobj,
+ rc = sysfs_create_bin_file(&ipl_kset->kobj,
&ipl_parameter_attr);
if (rc)
goto out_ipl_parm;
- rc = sysfs_create_bin_file(&ipl_subsys.kobj,
+ rc = sysfs_create_bin_file(&ipl_kset->kobj,
&ipl_scp_data_attr);
if (!rc)
goto out;
- sysfs_remove_bin_file(&ipl_subsys.kobj, &ipl_parameter_attr);
+ sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr);
out_ipl_parm:
- sysfs_remove_group(&ipl_subsys.kobj, &ipl_fcp_attr_group);
+ sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group);
out:
return rc;
}
@@ -855,12 +856,12 @@ static int __init ipl_init(void)
{
int rc;
- rc = firmware_register(&ipl_subsys);
- if (rc)
- return rc;
+ ipl_kset = kset_create_and_register("ipl", NULL, NULL, firmware_kset);
+ if (IS_ERR(ipl_kset))
+ return PTR_ERR(ipl_kset);
switch (ipl_info.type) {
case IPL_TYPE_CCW:
- rc = sysfs_create_group(&ipl_subsys.kobj,
+ rc = sysfs_create_group(&ipl_kset->kobj,
&ipl_ccw_attr_group);
break;
case IPL_TYPE_FCP:
@@ -868,16 +869,16 @@ static int __init ipl_init(void)
rc = ipl_register_fcp_files();
break;
case IPL_TYPE_NSS:
- rc = sysfs_create_group(&ipl_subsys.kobj,
+ rc = sysfs_create_group(&ipl_kset->kobj,
&ipl_nss_attr_group);
break;
default:
- rc = sysfs_create_group(&ipl_subsys.kobj,
+ rc = sysfs_create_group(&ipl_kset->kobj,
&ipl_unknown_attr_group);
break;
}
if (rc)
- firmware_unregister(&ipl_subsys);
+ kset_unregister(ipl_kset);
return rc;
}
@@ -899,7 +900,7 @@ static int __init reipl_nss_init(void)
if (!MACHINE_IS_VM)
return 0;
- rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_nss_attr_group);
+ rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group);
if (rc)
return rc;
strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1);
@@ -914,7 +915,7 @@ static int __init reipl_ccw_init(void)
reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
if (!reipl_block_ccw)
return -ENOMEM;
- rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_ccw_attr_group);
+ rc = sysfs_create_group(&reipl_kset->kobj, &reipl_ccw_attr_group);
if (rc) {
free_page((unsigned long)reipl_block_ccw);
return rc;
@@ -952,7 +953,7 @@ static int __init reipl_fcp_init(void)
reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
if (!reipl_block_fcp)
return -ENOMEM;
- rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_fcp_attr_group);
+ rc = sysfs_create_group(&reipl_kset->kobj, &reipl_fcp_attr_group);
if (rc) {
free_page((unsigned long)reipl_block_fcp);
return rc;
@@ -974,12 +975,12 @@ static int __init reipl_init(void)
{
int rc;
- rc = firmware_register(&reipl_subsys);
- if (rc)
- return rc;
- rc = sysfs_create_file(&reipl_subsys.kobj, &reipl_type_attr);
+ 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);
if (rc) {
- firmware_unregister(&reipl_subsys);
+ kset_unregister(reipl_kset);
return rc;
}
rc = reipl_ccw_init();
@@ -1004,7 +1005,7 @@ static int __init dump_ccw_init(void)
dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
if (!dump_block_ccw)
return -ENOMEM;
- rc = sysfs_create_group(&dump_subsys.kobj, &dump_ccw_attr_group);
+ rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group);
if (rc) {
free_page((unsigned long)dump_block_ccw);
return rc;
@@ -1028,7 +1029,7 @@ static int __init dump_fcp_init(void)
dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
if (!dump_block_fcp)
return -ENOMEM;
- rc = sysfs_create_group(&dump_subsys.kobj, &dump_fcp_attr_group);
+ rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group);
if (rc) {
free_page((unsigned long)dump_block_fcp);
return rc;
@@ -1063,12 +1064,12 @@ static int __init dump_init(void)
{
int rc;
- rc = firmware_register(&dump_subsys);
- if (rc)
- return rc;
- rc = sysfs_create_file(&dump_subsys.kobj, &dump_type_attr);
+ 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);
if (rc) {
- firmware_unregister(&dump_subsys);
+ kset_unregister(dump_kset);
return rc;
}
rc = dump_ccw_init();
@@ -1085,12 +1086,14 @@ static int __init shutdown_actions_init(void)
{
int rc;
- rc = firmware_register(&shutdown_actions_subsys);
- if (rc)
- return rc;
- rc = sysfs_create_file(&shutdown_actions_subsys.kobj, &on_panic_attr);
+ shutdown_actions_kset = kset_create_and_register("shutdown_actions",
+ NULL, NULL,
+ firmware_kset);
+ if (IS_ERR(shutdown_actions_kset))
+ return PTR_ERR(shutdown_actions_kset);
+ rc = sysfs_create_file(&shutdown_actions_kset->kobj, &on_panic_attr);
if (rc) {
- firmware_unregister(&shutdown_actions_subsys);
+ kset_unregister(shutdown_actions_kset);
return rc;
}
atomic_notifier_chain_register(&panic_notifier_list,
--
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 <[email protected]>
Cc: Thibaut VARENE <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Grant Grundler <[email protected]>
Cc: Kyle McMartin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
*/
-static ssize_t
-pdcs_auto_read(struct kset *kset, char *buf, int knob)
+static ssize_t pdcs_auto_read(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf, int knob)
{
char *out = buf;
struct pdcspath_entry *pathentry;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
/* Current flags are stored in primary boot path entry */
@@ -568,40 +568,37 @@ pdcs_auto_read(struct kset *kset, char *buf, int knob)
/**
* pdcs_autoboot_read - Stable Storage autoboot flag output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*/
-static inline ssize_t
-pdcs_autoboot_read(struct kset *kset, char *buf)
+static ssize_t pdcs_autoboot_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return pdcs_auto_read(kset, buf, PF_AUTOBOOT);
+ return pdcs_auto_read(kobj, attr, buf, PF_AUTOBOOT);
}
/**
* pdcs_autosearch_read - Stable Storage autoboot flag output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*/
-static inline ssize_t
-pdcs_autosearch_read(struct kset *kset, char *buf)
+static ssize_t pdcs_autosearch_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
- return pdcs_auto_read(kset, buf, PF_AUTOSEARCH);
+ return pdcs_auto_read(kobj, attr, buf, PF_AUTOSEARCH);
}
/**
* pdcs_timer_read - Stable Storage timer count output (in seconds).
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*
* The value of the timer field correponds to a number of seconds in powers of 2.
*/
-static ssize_t
-pdcs_timer_read(struct kset *kset, char *buf)
+static ssize_t pdcs_timer_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
struct pdcspath_entry *pathentry;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
/* Current flags are stored in primary boot path entry */
@@ -618,15 +615,14 @@ pdcs_timer_read(struct kset *kset, char *buf)
/**
* pdcs_osid_read - Stable Storage OS ID register 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_osid_read(struct kset *kset, char *buf)
+static ssize_t pdcs_osid_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
out += sprintf(out, "%s dependent data (0x%.4x)\n",
@@ -637,18 +633,17 @@ pdcs_osid_read(struct kset *kset, char *buf)
/**
* pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*
* This can hold 16 bytes of OS-Dependent data.
*/
-static ssize_t
-pdcs_osdep1_read(struct kset *kset, char *buf)
+static ssize_t pdcs_osdep1_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
u32 result[4];
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK)
@@ -664,18 +659,17 @@ pdcs_osdep1_read(struct kset *kset, char *buf)
/**
* pdcs_diagnostic_read - Stable Storage Diagnostic register output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*
* I have NFC how to interpret the content of that register ;-).
*/
-static ssize_t
-pdcs_diagnostic_read(struct kset *kset, char *buf)
+static ssize_t pdcs_diagnostic_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
u32 result;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
/* get diagnostic */
@@ -689,18 +683,17 @@ pdcs_diagnostic_read(struct kset *kset, char *buf)
/**
* pdcs_fastsize_read - Stable Storage FastSize register output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*
* This register holds the amount of system RAM to be tested during boot sequence.
*/
-static ssize_t
-pdcs_fastsize_read(struct kset *kset, char *buf)
+static ssize_t pdcs_fastsize_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
u32 result;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
/* get fast-size */
@@ -718,13 +711,12 @@ pdcs_fastsize_read(struct kset *kset, char *buf)
/**
* pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The output buffer to write to.
*
* This can hold pdcs_size - 224 bytes of OS-Dependent data, when available.
*/
-static ssize_t
-pdcs_osdep2_read(struct kset *kset, char *buf)
+static ssize_t pdcs_osdep2_read(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *out = buf;
unsigned long size;
@@ -736,7 +728,7 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
size = pdcs_size - 224;
- if (!kset || !buf)
+ if (!buf)
return -EINVAL;
for (i=0; i<size; i+=4) {
@@ -751,7 +743,6 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
/**
* pdcs_auto_write - This function handles autoboot/search flag modifying.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The input buffer to read from.
* @count: The number of bytes to be read.
* @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
@@ -760,8 +751,9 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
* We expect a precise syntax:
* \"n\" (n == 0 or 1) to toggle AutoBoot Off or On
*/
-static ssize_t
-pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob)
+static ssize_t pdcs_auto_write(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf,
+ size_t count, int knob)
{
struct pdcspath_entry *pathentry;
unsigned char flags;
@@ -771,7 +763,7 @@ pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob)
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!kset || !buf || !count)
+ if (!buf || !count)
return -EINVAL;
/* We'll use a local copy of buf */
@@ -826,7 +818,6 @@ parse_error:
/**
* pdcs_autoboot_write - This function handles autoboot flag modifying.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The input buffer to read from.
* @count: The number of bytes to be read.
*
@@ -834,15 +825,15 @@ parse_error:
* We expect a precise syntax:
* \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
*/
-static inline ssize_t
-pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count)
+static ssize_t pdcs_autoboot_write(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
- return pdcs_auto_write(kset, buf, count, PF_AUTOBOOT);
+ return pdcs_auto_write(kset, attr, buf, count, PF_AUTOBOOT);
}
/**
* pdcs_autosearch_write - This function handles autosearch flag modifying.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The input buffer to read from.
* @count: The number of bytes to be read.
*
@@ -850,15 +841,15 @@ pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count)
* We expect a precise syntax:
* \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
*/
-static inline ssize_t
-pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count)
+static ssize_t pdcs_autosearch_write(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
- return pdcs_auto_write(kset, buf, count, PF_AUTOSEARCH);
+ return pdcs_auto_write(kset, attr, buf, count, PF_AUTOSEARCH);
}
/**
* pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The input buffer to read from.
* @count: The number of bytes to be read.
*
@@ -866,15 +857,16 @@ pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count)
* write approach. It's up to userspace to deal with it when constructing
* its input buffer.
*/
-static ssize_t
-pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
+static ssize_t pdcs_osdep1_write(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
u8 in[16];
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!kset || !buf || !count)
+ if (!buf || !count)
return -EINVAL;
if (unlikely(pdcs_osid != OS_ID_LINUX))
@@ -895,7 +887,6 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
/**
* pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input.
- * @kset: An allocated and populated struct kset. We don't use it tho.
* @buf: The input buffer to read from.
* @count: The number of bytes to be read.
*
@@ -903,8 +894,9 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
* byte-by-byte write approach. It's up to userspace to deal with it when
* constructing its input buffer.
*/
-static ssize_t
-pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count)
+static ssize_t pdcs_osdep2_write(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
unsigned long size;
unsigned short i;
@@ -913,7 +905,7 @@ pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count)
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!kset || !buf || !count)
+ if (!buf || !count)
return -EINVAL;
if (unlikely(pdcs_size <= 224))
@@ -951,19 +943,23 @@ static PDCS_ATTR(diagnostic, 0400, pdcs_diagnostic_read, NULL);
static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL);
static PDCS_ATTR(osdep2, 0600, pdcs_osdep2_read, pdcs_osdep2_write);
-static struct subsys_attribute *pdcs_subsys_attrs[] = {
- &pdcs_attr_size,
- &pdcs_attr_autoboot,
- &pdcs_attr_autosearch,
- &pdcs_attr_timer,
- &pdcs_attr_osid,
- &pdcs_attr_osdep1,
- &pdcs_attr_diagnostic,
- &pdcs_attr_fastsize,
- &pdcs_attr_osdep2,
+static struct attribute *pdcs_subsys_attrs[] = {
+ &pdcs_attr_size.attr,
+ &pdcs_attr_autoboot.attr,
+ &pdcs_attr_autosearch.attr,
+ &pdcs_attr_timer.attr,
+ &pdcs_attr_osid.attr,
+ &pdcs_attr_osdep1.attr,
+ &pdcs_attr_diagnostic.attr,
+ &pdcs_attr_fastsize.attr,
+ &pdcs_attr_osdep2.attr,
NULL,
};
+static struct attribute_group pdcs_attr_group = {
+ .attrs = pdcs_subsys_attrs,
+};
+
static decl_subsys(paths, NULL);
static decl_subsys(stable, NULL);
@@ -1042,8 +1038,7 @@ pdcs_unregister_pathentries(void)
static int __init
pdc_stable_init(void)
{
- struct subsys_attribute *attr;
- int i, rc = 0, error = 0;
+ int rc = 0, error = 0;
u32 result;
/* find the size of the stable storage */
@@ -1068,10 +1063,8 @@ pdc_stable_init(void)
goto fail_firmreg;
/* Don't forget the root entries */
- for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++)
- if (attr->show)
- error = subsys_create_file(&stable_subsys, attr);
-
+ error = sysfs_create_group(&stable_subsys.kobj, pdcs_attr_group);
+
/* register the paths subsys as a subsystem of stable subsys */
paths_subsys.kobj.kset = &stable_subsys;
if ((rc = subsystem_register(&paths_subsys)))
--
1.5.3.4
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 <[email protected]>
Cc: Thibaut VARENE <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Grant Grundler <[email protected]>
Cc: Kyle McMartin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 subsystem of stable subsys */
- paths_subsys.kobj.kset = &stable_subsys;
- if ((rc = subsystem_register(&paths_subsys)))
- goto fail_subsysreg;
+ error = sysfs_create_group(&stable_kset->kobj, pdcs_attr_group);
+
+ /* register the paths kset as a child of the stable kset */
+ paths_kset = kset_create_and_register("paths", NULL, NULL,
+ stable_kset);
+ if (IS_ERR(paths_kset)) {
+ rc = PTR_ERR(paths_kset);
+ goto fail_ksetreg;
+ }
- /* now we create all "files" for the paths subsys */
+ /* now we create all "files" for the paths kset */
if ((rc = pdcs_register_pathentries()))
goto fail_pdcsreg;
@@ -1078,10 +1085,10 @@ pdc_stable_init(void)
fail_pdcsreg:
pdcs_unregister_pathentries();
- subsystem_unregister(&paths_subsys);
+ kset_unregister(paths_kset);
-fail_subsysreg:
- firmware_unregister(&stable_subsys);
+fail_ksetreg:
+ kset_unregister(stable_kset);
fail_firmreg:
printk(KERN_INFO PDCS_PREFIX " bailing out\n");
@@ -1092,9 +1099,8 @@ static void __exit
pdc_stable_exit(void)
{
pdcs_unregister_pathentries();
- subsystem_unregister(&paths_subsys);
-
- firmware_unregister(&stable_subsys);
+ kset_unregister(paths_kset);
+ kset_unregister(stable_kset);
}
--
1.5.3.4
From: Kay Sievers <[email protected]>
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 *attr_sd = file->f_path.dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
- struct sysfs_buffer * buffer;
- struct sysfs_ops * ops = NULL;
- int error;
+ struct sysfs_buffer *buffer;
+ struct sysfs_ops *ops;
+ int error = -EACCES;
/* need attr_sd for attr and ops, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
return -ENODEV;
- /* if the kobject has no ktype, then we assume that it is a subsystem
- * itself, and use ops for it.
- */
- if (kobj->ktype)
+ /* every kobject with an attribute needs a ktype assigned */
+ if (kobj->ktype && kobj->ktype->sysfs_ops)
ops = kobj->ktype->sysfs_ops;
- else
- ops = &subsys_sysfs_ops;
-
- error = -EACCES;
-
- /* No sysfs operations, either from having no subsystem,
- * or the subsystem have no operations.
- */
- if (!ops)
+ else {
+ printk(KERN_ERR "missing sysfs attribute operations for "
+ "kobject: %s\n", kobject_name(kobj));
+ WARN_ON(1);
goto err_out;
+ }
/* File needs write support.
* The inode's perms must say it's ok,
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 3aa8108..05c8ef8 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -210,15 +210,6 @@ extern struct kset *firmware_kset;
extern int __must_check subsystem_register(struct kset *);
extern void subsystem_unregister(struct kset *);
-struct subsys_attribute {
- struct attribute attr;
- ssize_t (*show)(struct kset *, char *);
- ssize_t (*store)(struct kset *, const char *, size_t);
-};
-
-extern int __must_check subsys_create_file(struct kset *,
- struct subsys_attribute *);
-
#if defined(CONFIG_HOTPLUG)
int kobject_uevent(struct kobject *kobj, enum kobject_action action);
int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
diff --git a/lib/kobject.c b/lib/kobject.c
index dda6614..c768e0c 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -671,26 +671,6 @@ void subsystem_unregister(struct kset *s)
kset_unregister(s);
}
-/**
- * subsystem_create_file - export sysfs attribute file.
- * @s: subsystem.
- * @a: subsystem attribute descriptor.
- */
-
-int subsys_create_file(struct kset *s, struct subsys_attribute *a)
-{
- int error = 0;
-
- if (!s || !a)
- return -EINVAL;
-
- if (kset_get(s)) {
- error = sysfs_create_file(&s->kobj, &a->attr);
- kset_put(s);
- }
- return error;
-}
-
static void kset_release(struct kobject *kobj)
{
struct kset *kset = container_of(kobj, struct kset, kobj);
@@ -795,4 +775,3 @@ EXPORT_SYMBOL(kset_unregister);
EXPORT_SYMBOL(subsystem_register);
EXPORT_SYMBOL(subsystem_unregister);
-EXPORT_SYMBOL(subsys_create_file);
--
1.5.3.4
Dynamically create the kset instead of declaring it statically.
Cc: Kay Sievers <[email protected]>
Cc: Matt Domsch <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
Cc: Len Brown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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 <[email protected]>
+ * 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 *dev);
#define dev_printk(level, dev, format, arg...) \
--
1.5.3.4
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 <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Kurt Hackel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
}
-
-static O2CB_ATTR(interface_revision, S_IFREG | S_IRUGO, o2cb_interface_revision_show, NULL);
+static struct kobj_attribute attr_version =
+ __ATTR(interface_revision, S_IFREG | S_IRUGO, version_show, NULL);
static struct attribute *o2cb_attrs[] = {
- &o2cb_attr_interface_revision.attr,
+ &attr_version.attr,
NULL,
};
-static ssize_t
-o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer);
-static ssize_t
-o2cb_store(struct kobject * kobj, struct attribute * attr,
- const char * buffer, size_t count);
-static struct sysfs_ops o2cb_sysfs_ops = {
- .show = o2cb_show,
- .store = o2cb_store,
+static struct attribute_group o2cb_attr_group = {
+ .attrs = o2cb_attrs,
};
-static struct kobj_type o2cb_subsys_type = {
- .default_attrs = o2cb_attrs,
- .sysfs_ops = &o2cb_sysfs_ops,
-};
-
-/* gives us o2cb_subsys */
-static decl_subsys(o2cb, NULL);
-
-static ssize_t
-o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer)
-{
- struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
- struct kset *sbs = to_kset(kobj);
-
- BUG_ON(sbs != &o2cb_subsys);
-
- if (o2cb_attr->show)
- return o2cb_attr->show(buffer);
- return -EIO;
-}
-
-static ssize_t
-o2cb_store(struct kobject * kobj, struct attribute * attr,
- const char * buffer, size_t count)
-{
- struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
- struct kset *sbs = to_kset(kobj);
-
- BUG_ON(sbs != &o2cb_subsys);
-
- if (o2cb_attr->store)
- return o2cb_attr->store(buffer, count);
- return -EIO;
-}
+static struct kset *o2cb_kset;
void o2cb_sys_shutdown(void)
{
mlog_sys_shutdown();
- subsystem_unregister(&o2cb_subsys);
+ kset_unregister(o2cb_kset);
}
int o2cb_sys_init(void)
{
int ret;
- o2cb_subsys.kobj.ktype = &o2cb_subsys_type;
- ret = subsystem_register(&o2cb_subsys);
+ o2cb_kset = kset_create_and_register("o2cb", NULL, NULL, fs_kset);
+ if (IS_ERR(o2cb_kset))
+ return PTR_ERR(o2cb_kset);
+
+ ret = sysfs_create_group(&o2cb_kset->kobj, &o2cb_attr_group);
if (ret)
- return ret;
+ goto error;
- ret = mlog_sys_init(&o2cb_subsys);
+ ret = mlog_sys_init(o2cb_kset);
if (ret)
- subsystem_unregister(&o2cb_subsys);
+ goto error;
+ return 0;
+error:
+ kset_unregister(o2cb_kset);
return ret;
}
--
1.5.3.4
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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
On Fri, 2 Nov 2007 16:59:24 -0700,
Greg Kroah-Hartman <[email protected]> wrote:
> 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 <[email protected]>
> Cc: Michael Holzheu <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Volker Sameske <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> arch/s390/kernel/ipl.c | 75 +++++++++++++++++++++++++-----------------------
> 1 files changed, 39 insertions(+), 36 deletions(-)
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 <[email protected]>
---
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, &on_panic_attr);
+ rc = sysfs_create_file(&shutdown_actions_kset->kobj,
+ &on_panic_attr.attr);
if (rc) {
kset_unregister(shutdown_actions_kset);
return rc;
On Fri, 2 Nov 2007 16:59:11 -0700,
Greg Kroah-Hartman <[email protected]> wrote:
> 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 <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> 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(-)
>
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 <[email protected]>
---
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)
On Fri, 2 Nov 2007 16:59:12 -0700,
Greg Kroah-Hartman <[email protected]> wrote:
> From: Kay Sievers <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> include/linux/kobject.h | 10 ++++++++++
> lib/kobject.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 39 insertions(+), 0 deletions(-)
How about adding some simple wrappers around the new kobj_attribute
structure? This makes the layering clearer.
Signed-off-by: Cornelia Huck <[email protected]>
---
include/linux/kobject.h | 7 ++++++-
lib/kobject.c | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
Index: linux-2.6/include/linux/kobject.h
===================================================================
--- linux-2.6.orig/include/linux/kobject.h 2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/include/linux/kobject.h 2007-11-05 13:24:55.000000000 +0100
@@ -126,7 +126,12 @@ struct kobj_attribute {
ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count);
};
-
+#define KOBJ_ATTR(_name,_mode,_show,_store) \
+ struct kobj_attribute kobj_attr_##_name = \
+ __ATTR(_name,_mode,_show,_store)
+extern int __must_check kobject_create_file(struct kobject *,
+ struct kobj_attribute *);
+extern void kobject_remove_file(struct kobject *,struct kobj_attribute *);
extern struct sysfs_ops kobj_sysfs_ops;
/**
Index: linux-2.6/lib/kobject.c
===================================================================
--- linux-2.6.orig/lib/kobject.c 2007-11-05 11:12:49.000000000 +0100
+++ linux-2.6/lib/kobject.c 2007-11-05 13:36:45.000000000 +0100
@@ -577,6 +577,28 @@ struct sysfs_ops kobj_sysfs_ops = {
.store = kobj_attr_store,
};
+/**
+ * kobject_create_file() - create an attribute file for a kobject
+ * @kobj: kobject the attribute is created for
+ * @attr: attribute to be created
+ */
+int kobject_create_file(struct kobject *kobj, struct kobj_attribute *attr)
+{
+ return sysfs_create_file(kobj, &attr->attr);
+}
+EXPORT_SYMBOL_GPL(kobject_create_file);
+
+/**
+ * kobject_remove_file() - remove an attribute file from a kobject
+ * @kobj: kobject the attribute is removed from
+ * @attr: attribute to be removed
+ */
+void kobject_remove_file(struct kobject *kobj, struct kobj_attribute *attr)
+{
+ sysfs_remove_file(kobj, &attr->attr);
+}
+EXPORT_SYMBOL_GPL(kobject_remove_file);
+
static void dir_release(struct kobject *kobj)
{
kfree(kobj);
On Fri, 2 Nov 2007 16:59:05 -0700,
Greg Kroah-Hartman <[email protected]> wrote:
> Dynamically create the kset instead of declaring it statically.
>
> Cc: Kay Sievers <[email protected]>
> Cc: Michael Holzheu <[email protected]>
> Cc: Cornelia Huck <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> arch/s390/hypfs/inode.c | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
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 <[email protected]>
---
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;
}
On Mon, 2007-11-05 at 13:42 +0100, Cornelia Huck wrote:
> On Fri, 2 Nov 2007 16:59:12 -0700,
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > From: Kay Sievers <[email protected]>
> >
> > 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 <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > include/linux/kobject.h | 10 ++++++++++
> > lib/kobject.c | 29 +++++++++++++++++++++++++++++
> > 2 files changed, 39 insertions(+), 0 deletions(-)
>
> How about adding some simple wrappers around the new kobj_attribute
> structure? This makes the layering clearer.
> +#define KOBJ_ATTR(_name,_mode,_show,_store) \
> + struct kobj_attribute kobj_attr_##_name = \
> + __ATTR(_name,_mode,_show,_store)
That sounds fine.
> +extern int __must_check kobject_create_file(struct kobject *,
>
> struct kobj_attribute *);
> +extern void kobject_remove_file(struct kobject *,struct kobj_attribute *);
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
On Mon, Nov 05, 2007 at 11:27:31AM +0100, Cornelia Huck wrote:
> On Fri, 2 Nov 2007 16:59:24 -0700,
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > 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 <[email protected]>
> > Cc: Michael Holzheu <[email protected]>
> > Cc: Heiko Carstens <[email protected]>
> > Cc: Volker Sameske <[email protected]>
> > Cc: Cornelia Huck <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > arch/s390/kernel/ipl.c | 75 +++++++++++++++++++++++++-----------------------
> > 1 files changed, 39 insertions(+), 36 deletions(-)
>
> 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 <[email protected]>
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
On Mon, Nov 05, 2007 at 11:33:19AM +0100, Cornelia Huck wrote:
> On Fri, 2 Nov 2007 16:59:11 -0700,
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > 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 <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > 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(-)
> >
>
> 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 <[email protected]>
>
> ---
> 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
On Mon, Nov 05, 2007 at 02:18:19PM +0100, Cornelia Huck wrote:
> On Fri, 2 Nov 2007 16:59:05 -0700,
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > Dynamically create the kset instead of declaring it statically.
> >
> > Cc: Kay Sievers <[email protected]>
> > Cc: Michael Holzheu <[email protected]>
> > Cc: Cornelia Huck <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > arch/s390/hypfs/inode.c | 15 +++++++++------
> > 1 files changed, 9 insertions(+), 6 deletions(-)
>
> arch/s390/hypfs/inode.c: In function 'hypfs_init':
> arch/s390/hypfs/inode.c:512: error: implicit declaration of function 'IS_PTR'
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
On Mon, Nov 05, 2007 at 05:23:32PM +0100, Kay Sievers wrote:
> On Mon, 2007-11-05 at 13:42 +0100, Cornelia Huck wrote:
> > On Fri, 2 Nov 2007 16:59:12 -0700,
> > Greg Kroah-Hartman <[email protected]> wrote:
> >
> > > From: Kay Sievers <[email protected]>
> > >
> > > 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 <[email protected]>
> > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > ---
> > > include/linux/kobject.h | 10 ++++++++++
> > > lib/kobject.c | 29 +++++++++++++++++++++++++++++
> > > 2 files changed, 39 insertions(+), 0 deletions(-)
> >
> > How about adding some simple wrappers around the new kobj_attribute
> > structure? This makes the layering clearer.
>
> > +#define KOBJ_ATTR(_name,_mode,_show,_store) \
> > + struct kobj_attribute kobj_attr_##_name = \
> > + __ATTR(_name,_mode,_show,_store)
>
> That sounds fine.
>
> > +extern int __must_check kobject_create_file(struct kobject *,
> >
> > struct kobj_attribute *);
> > +extern void kobject_remove_file(struct kobject *,struct kobj_attribute *);
>
> 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?
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
On Mon, 2007-11-05 at 09:11 -0800, Greg KH wrote:
> On Mon, Nov 05, 2007 at 05:23:32PM +0100, Kay Sievers wrote:
> > On Mon, 2007-11-05 at 13:42 +0100, Cornelia Huck wrote:
> > > On Fri, 2 Nov 2007 16:59:12 -0700,
> > > Greg Kroah-Hartman <[email protected]> wrote:
> > >
> > > > From: Kay Sievers <[email protected]>
> > > >
> > > > 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 <[email protected]>
> > > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > > ---
> > > > include/linux/kobject.h | 10 ++++++++++
> > > > lib/kobject.c | 29 +++++++++++++++++++++++++++++
> > > > 2 files changed, 39 insertions(+), 0 deletions(-)
> > >
> > > How about adding some simple wrappers around the new kobj_attribute
> > > structure? This makes the layering clearer.
> >
> > > +#define KOBJ_ATTR(_name,_mode,_show,_store) \
> > > + struct kobj_attribute kobj_attr_##_name = \
> > > + __ATTR(_name,_mode,_show,_store)
> >
> > That sounds fine.
> >
> > > +extern int __must_check kobject_create_file(struct kobject *,
> > >
> > > struct kobj_attribute *);
> > > +extern void kobject_remove_file(struct kobject *,struct kobj_attribute *);
> >
> > 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?
>
> 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.
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,
Kay Sievers <[email protected]> wrote:
> > > 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?
> >
> > 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.
>
> 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.
But where should I specify those default attributes?
kset_create_and_register() sets the ktype to kset_ktype...
On Mon, 2007-11-05 at 18:43 +0100, Cornelia Huck wrote:
> On Mon, 05 Nov 2007 18:25:40 +0100,
> Kay Sievers <[email protected]> wrote:
>
> > > > 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?
> > >
> > > 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.
> >
> > 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.
>
> 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 Fri, 2 Nov 2007 16:59:00 -0700,
Greg Kroah-Hartman <[email protected]> wrote:
> Dynamically create the kset instead of declaring it statically.
>
> Cc: Kay Sievers <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> drivers/base/sys.c | 28 ++++++++++++----------------
> 1 files changed, 12 insertions(+), 16 deletions(-)
Unfortunately, at that point in the patch series reipl breaks for me :(
I used the following silly debug patch:
---
drivers/base/power/shutdown.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
Index: linux-2.6/drivers/base/power/shutdown.c
===================================================================
--- linux-2.6.orig/drivers/base/power/shutdown.c 2007-11-05 18:51:51.000000000 +0100
+++ linux-2.6/drivers/base/power/shutdown.c 2007-11-05 18:52:50.000000000 +0100
@@ -37,10 +37,11 @@ void device_shutdown(void)
list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
kobj.entry) {
if (dev->bus && dev->bus->shutdown) {
- dev_dbg(dev, "shutdown\n");
+ dev_dbg(dev, "shutdown (bus %s)\n", dev->bus->name);
dev->bus->shutdown(dev);
} else if (dev->driver && dev->driver->shutdown) {
- dev_dbg(dev, "shutdown\n");
+ dev_dbg(dev, "shutdown (driver %s)\n",
+ dev->driver->name);
dev->driver->shutdown(dev);
}
}
and get as the kernel's last words:
<loads of sane shutdowns for the ccw and css busses>
<7>io_subchannel 0.0.095c: shutdown (bus css)
<7>io_subchannel 0.0.095b: shutdown (bus css)
<7>io_subchannel 0.0.095a: shutdown (bus css)
<7> : shutdown (bus )
<1>Unable to handle kernel pointer dereference at virtual kernel address 0000000500000000
<4>Oops: 003b [#1]
<4>Modules linked in: dm_multipath sunrpc qeth ccwgroup dm_mod
<4>CPU: 2 Not tainted
<4>Process reboot (pid: 2892, task: 0000000002cae048, ksp: 00000000045c39b8)
<4>Krnl PSW : 0704000180000000 0000000500000006 (0x500000006)
<4> R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:0 PM:0 EA:3
<4>Krnl GPRS: 0000000000019e75 0000000500000006 0000000002c42810 0000000002c429b0
<4> 00000000002a36ec 0000000000000000 000003ffffb76d48 0000000000000160
<4> 00000000001423a4 000002000015e390 00000000006e06b8 0000000000634638
<4> 0000000002c42810 000000000041f670 00000000002a36fe 00000000045c3d00
<4>Krnl Code: Bad PSW.
<4>Call Trace:
<4>([<00000000002a36ec>] device_shutdown+0x78/0x144)
<4> [<000000000013f18c>] kernel_restart_prepare+0x44/0x50
<4> [<000000000013f1be>] kernel_restart+0x26/0x6c
<4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
<4> [<0000000000111038>] sysc_noemu+0x10/0x16
<4> [<00000200001048e0>] 0x200001048e0
<4>
<4>
Huh? We want to shutdown an unknown device on a bus that wishes to stay
anonymous?
Any hints would be appreciated...
On Mon, 05 Nov 2007 19:07:50 +0100,
Kay Sievers <[email protected]> wrote:
> On Mon, 2007-11-05 at 18:43 +0100, Cornelia Huck wrote:
> > On Mon, 05 Nov 2007 18:25:40 +0100,
> > Kay Sievers <[email protected]> wrote:
> >
> > > > > 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?
> > > >
> > > > 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.
> > >
> > > 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.
> >
> > 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?
Yes, see arch/s390/kernel/ipl.c (and I guess anything that uses
subsys_create_file() before).
On Mon, 2007-11-05 at 19:17 +0100, Cornelia Huck wrote:
> On Mon, 05 Nov 2007 19:07:50 +0100,
> Kay Sievers <[email protected]> wrote:
>
> > On Mon, 2007-11-05 at 18:43 +0100, Cornelia Huck wrote:
> > > On Mon, 05 Nov 2007 18:25:40 +0100,
> > > Kay Sievers <[email protected]> wrote:
> > >
> > > > > > 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?
> > > > >
> > > > > 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.
> > > >
> > > > 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.
> > >
> > > 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?
>
> Yes, see arch/s390/kernel/ipl.c
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
run into all sorts of timing problems.
> (and I guess anything that uses
> subsys_create_file() before).
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
On Mon, Nov 05, 2007 at 07:39:31PM +0100, Kay Sievers wrote:
> On Mon, 2007-11-05 at 19:17 +0100, Cornelia Huck wrote:
> > On Mon, 05 Nov 2007 19:07:50 +0100,
> > Kay Sievers <[email protected]> wrote:
> >
> > > On Mon, 2007-11-05 at 18:43 +0100, Cornelia Huck wrote:
> > > > On Mon, 05 Nov 2007 18:25:40 +0100,
> > > > Kay Sievers <[email protected]> wrote:
> > > >
> > > > > > > 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?
> > > > > >
> > > > > > 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.
> > > > >
> > > > > 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.
> > > >
> > > > 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?
> >
> > Yes, see arch/s390/kernel/ipl.c
>
> 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
> run into all sorts of timing problems.
Kay is right, it should be simple to add the kobject attributes to the
kobject itself when it is registered to this kset, right?
> > (and I guess anything that uses
> > subsys_create_file() before).
>
> 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. :)
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, Nov 05, 2007 at 07:11:09PM +0100, Cornelia Huck wrote:
> On Fri, 2 Nov 2007 16:59:00 -0700,
> Greg Kroah-Hartman <[email protected]> wrote:
>
> > Dynamically create the kset instead of declaring it statically.
> >
> > Cc: Kay Sievers <[email protected]>
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > drivers/base/sys.c | 28 ++++++++++++----------------
> > 1 files changed, 12 insertions(+), 16 deletions(-)
>
> Unfortunately, at that point in the patch series reipl breaks for me :(
>
> I used the following silly debug patch:
What does reipl have to do with shutdown?
> ---
> drivers/base/power/shutdown.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> Index: linux-2.6/drivers/base/power/shutdown.c
> ===================================================================
> --- linux-2.6.orig/drivers/base/power/shutdown.c 2007-11-05 18:51:51.000000000 +0100
> +++ linux-2.6/drivers/base/power/shutdown.c 2007-11-05 18:52:50.000000000 +0100
> @@ -37,10 +37,11 @@ void device_shutdown(void)
> list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
> kobj.entry) {
> if (dev->bus && dev->bus->shutdown) {
> - dev_dbg(dev, "shutdown\n");
> + dev_dbg(dev, "shutdown (bus %s)\n", dev->bus->name);
> dev->bus->shutdown(dev);
> } else if (dev->driver && dev->driver->shutdown) {
> - dev_dbg(dev, "shutdown\n");
> + dev_dbg(dev, "shutdown (driver %s)\n",
> + dev->driver->name);
> dev->driver->shutdown(dev);
> }
> }
>
> and get as the kernel's last words:
>
> <loads of sane shutdowns for the ccw and css busses>
> <7>io_subchannel 0.0.095c: shutdown (bus css)
> <7>io_subchannel 0.0.095b: shutdown (bus css)
> <7>io_subchannel 0.0.095a: shutdown (bus css)
> <7> : shutdown (bus )
> <1>Unable to handle kernel pointer dereference at virtual kernel address 0000000500000000
> <4>Oops: 003b [#1]
> <4>Modules linked in: dm_multipath sunrpc qeth ccwgroup dm_mod
> <4>CPU: 2 Not tainted
> <4>Process reboot (pid: 2892, task: 0000000002cae048, ksp: 00000000045c39b8)
> <4>Krnl PSW : 0704000180000000 0000000500000006 (0x500000006)
> <4> R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:0 PM:0 EA:3
> <4>Krnl GPRS: 0000000000019e75 0000000500000006 0000000002c42810 0000000002c429b0
> <4> 00000000002a36ec 0000000000000000 000003ffffb76d48 0000000000000160
> <4> 00000000001423a4 000002000015e390 00000000006e06b8 0000000000634638
> <4> 0000000002c42810 000000000041f670 00000000002a36fe 00000000045c3d00
> <4>Krnl Code: Bad PSW.
> <4>Call Trace:
> <4>([<00000000002a36ec>] device_shutdown+0x78/0x144)
> <4> [<000000000013f18c>] kernel_restart_prepare+0x44/0x50
> <4> [<000000000013f1be>] kernel_restart+0x26/0x6c
> <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> <4> [<00000200001048e0>] 0x200001048e0
> <4>
> <4>
>
> Huh? We want to shutdown an unknown device on a bus that wishes to stay
> anonymous?
>
> Any hints would be appreciated...
I'll look into this, I wonder if we are walking off the end of an
unterminated list...
thanks,
greg k-h
On Mon, 05 Nov 2007 19:39:31 +0100,
Kay Sievers <[email protected]> wrote:
> 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. :)
Yes, ipl.c looks a lot like "we need a subdirectory under /sys/firmware/
and need to jump through hoops to get it there".
> 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
> run into all sorts of timing problems.
Maybe they need something like device->uevent_suppress, but at the
kobject level?
On Mon, 5 Nov 2007 10:58:28 -0800,
Greg KH <[email protected]> wrote:
> On Mon, Nov 05, 2007 at 07:11:09PM +0100, Cornelia Huck wrote:
> > On Fri, 2 Nov 2007 16:59:00 -0700,
> > Greg Kroah-Hartman <[email protected]> wrote:
> >
> > > Dynamically create the kset instead of declaring it statically.
> > >
> > > Cc: Kay Sievers <[email protected]>
> > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > ---
> > > drivers/base/sys.c | 28 ++++++++++++----------------
> > > 1 files changed, 12 insertions(+), 16 deletions(-)
> >
> > Unfortunately, at that point in the patch series reipl breaks for me :(
> >
> > I used the following silly debug patch:
>
> What does reipl have to do with shutdown?
Before we reipl (reboot), device_shutdown() is called.
> > <loads of sane shutdowns for the ccw and css busses>
> > <7>io_subchannel 0.0.095c: shutdown (bus css)
> > <7>io_subchannel 0.0.095b: shutdown (bus css)
> > <7>io_subchannel 0.0.095a: shutdown (bus css)
> > <7> : shutdown (bus )
> > <1>Unable to handle kernel pointer dereference at virtual kernel address 0000000500000000
> > <4>Oops: 003b [#1]
> > <4>Modules linked in: dm_multipath sunrpc qeth ccwgroup dm_mod
> > <4>CPU: 2 Not tainted
> > <4>Process reboot (pid: 2892, task: 0000000002cae048, ksp: 00000000045c39b8)
> > <4>Krnl PSW : 0704000180000000 0000000500000006 (0x500000006)
> > <4> R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:0 PM:0 EA:3
> > <4>Krnl GPRS: 0000000000019e75 0000000500000006 0000000002c42810 0000000002c429b0
> > <4> 00000000002a36ec 0000000000000000 000003ffffb76d48 0000000000000160
> > <4> 00000000001423a4 000002000015e390 00000000006e06b8 0000000000634638
> > <4> 0000000002c42810 000000000041f670 00000000002a36fe 00000000045c3d00
> > <4>Krnl Code: Bad PSW.
> > <4>Call Trace:
> > <4>([<00000000002a36ec>] device_shutdown+0x78/0x144)
> > <4> [<000000000013f18c>] kernel_restart_prepare+0x44/0x50
> > <4> [<000000000013f1be>] kernel_restart+0x26/0x6c
> > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > <4> [<00000200001048e0>] 0x200001048e0
> > <4>
> > <4>
> >
> > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > anonymous?
> >
> > Any hints would be appreciated...
>
> I'll look into this, I wonder if we are walking off the end of an
> unterminated list...
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.
On Mon, Nov 05, 2007 at 07:59:50PM +0100, Cornelia Huck wrote:
> On Mon, 05 Nov 2007 19:39:31 +0100,
> Kay Sievers <[email protected]> wrote:
>
> > 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. :)
>
> Yes, ipl.c looks a lot like "we need a subdirectory under /sys/firmware/
> and need to jump through hoops to get it there".
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
ksets as they just need to be directories, not full-blown ksets.
> > 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
> > run into all sorts of timing problems.
>
> Maybe they need something like device->uevent_suppress, but at the
> kobject level?
Ugh, I hope not :)
thanks,
greg k-h
On Mon, Nov 05, 2007 at 08:11:32PM +0100, Cornelia Huck wrote:
> On Mon, 5 Nov 2007 10:58:28 -0800,
> Greg KH <[email protected]> wrote:
>
> > On Mon, Nov 05, 2007 at 07:11:09PM +0100, Cornelia Huck wrote:
> > > On Fri, 2 Nov 2007 16:59:00 -0700,
> > > Greg Kroah-Hartman <[email protected]> wrote:
> > >
> > > > Dynamically create the kset instead of declaring it statically.
> > > >
> > > > Cc: Kay Sievers <[email protected]>
> > > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > > ---
> > > > drivers/base/sys.c | 28 ++++++++++++----------------
> > > > 1 files changed, 12 insertions(+), 16 deletions(-)
> > >
> > > Unfortunately, at that point in the patch series reipl breaks for me :(
> > >
> > > I used the following silly debug patch:
> >
> > What does reipl have to do with shutdown?
>
> Before we reipl (reboot), device_shutdown() is called.
Ah, ok.
> > > <loads of sane shutdowns for the ccw and css busses>
> > > <7>io_subchannel 0.0.095c: shutdown (bus css)
> > > <7>io_subchannel 0.0.095b: shutdown (bus css)
> > > <7>io_subchannel 0.0.095a: shutdown (bus css)
> > > <7> : shutdown (bus )
> > > <1>Unable to handle kernel pointer dereference at virtual kernel address 0000000500000000
> > > <4>Oops: 003b [#1]
> > > <4>Modules linked in: dm_multipath sunrpc qeth ccwgroup dm_mod
> > > <4>CPU: 2 Not tainted
> > > <4>Process reboot (pid: 2892, task: 0000000002cae048, ksp: 00000000045c39b8)
> > > <4>Krnl PSW : 0704000180000000 0000000500000006 (0x500000006)
> > > <4> R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:0 PM:0 EA:3
> > > <4>Krnl GPRS: 0000000000019e75 0000000500000006 0000000002c42810 0000000002c429b0
> > > <4> 00000000002a36ec 0000000000000000 000003ffffb76d48 0000000000000160
> > > <4> 00000000001423a4 000002000015e390 00000000006e06b8 0000000000634638
> > > <4> 0000000002c42810 000000000041f670 00000000002a36fe 00000000045c3d00
> > > <4>Krnl Code: Bad PSW.
> > > <4>Call Trace:
> > > <4>([<00000000002a36ec>] device_shutdown+0x78/0x144)
> > > <4> [<000000000013f18c>] kernel_restart_prepare+0x44/0x50
> > > <4> [<000000000013f1be>] kernel_restart+0x26/0x6c
> > > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > > <4> [<00000200001048e0>] 0x200001048e0
> > > <4>
> > > <4>
> > >
> > > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > > anonymous?
> > >
> > > Any hints would be appreciated...
> >
> > I'll look into this, I wonder if we are walking off the end of an
> > unterminated list...
>
> 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
On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
> 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.
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.
On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
> 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.
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.
On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
> 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.
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.
Andrew, Greg,
On Mon, Nov 05, 2007 at 11:11:48PM -0800, Andrew Morton wrote:
> On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
>
> > 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.
>
> 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.
I am sure we can fix this. I just need to get the kset patch from Greg.
--
-Stephane
On Tue, Nov 06, 2007 at 12:14:13AM -0800, Stephane Eranian wrote:
> Andrew, Greg,
>
> On Mon, Nov 05, 2007 at 11:11:48PM -0800, Andrew Morton wrote:
> > On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
> >
> > > 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.
> >
> > 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.
>
> I am sure we can fix this. I just need to get the kset patch from Greg.
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,
On Tue, Nov 06, 2007 at 01:15:27PM -0800, Greg KH wrote:
> On Tue, Nov 06, 2007 at 12:14:13AM -0800, Stephane Eranian wrote:
> > Andrew, Greg,
> >
> > On Mon, Nov 05, 2007 at 11:11:48PM -0800, Andrew Morton wrote:
> > > On Fri, 2 Nov 2007 16:57:58 -0700 Greg KH <[email protected]> wrote:
> > >
> > > > 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.
> > >
> > > 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.
> >
> > I am sure we can fix this. I just need to get the kset patch from Greg.
>
> 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...
>
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
On Mon, 5 Nov 2007 12:03:34 -0800 Greg KH <[email protected]> wrote:
> > > > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > > > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > > > <4> [<00000200001048e0>] 0x200001048e0
> > > > <4>
> > > > <4>
> > > >
> > > > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > > > anonymous?
> > > >
> > > > Any hints would be appreciated...
> > >
> > > I'll look into this, I wonder if we are walking off the end of an
> > > unterminated list...
> >
> > 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...
<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
On Tue, 13 Nov 2007 15:14:10 -0800 Andrew Morton <[email protected]> wrote:
> On Mon, 5 Nov 2007 12:03:34 -0800 Greg KH <[email protected]> wrote:
>
> > > > > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > > > > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > > > > <4> [<00000200001048e0>] 0x200001048e0
> > > > > <4>
> > > > > <4>
> > > > >
> > > > > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > > > > anonymous?
> > > > >
> > > > > Any hints would be appreciated...
> > > >
> > > > I'll look into this, I wonder if we are walking off the end of an
> > > > unterminated list...
> > >
> > > 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...
>
> <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'.
On Tue, Nov 13, 2007 at 04:01:44PM -0800, Andrew Morton wrote:
> On Tue, 13 Nov 2007 15:14:10 -0800 Andrew Morton <[email protected]> wrote:
>
> > On Mon, 5 Nov 2007 12:03:34 -0800 Greg KH <[email protected]> wrote:
> >
> > > > > > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > > > > > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > > > > > <4> [<00000200001048e0>] 0x200001048e0
> > > > > > <4>
> > > > > > <4>
> > > > > >
> > > > > > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > > > > > anonymous?
> > > > > >
> > > > > > Any hints would be appreciated...
> > > > >
> > > > > I'll look into this, I wonder if we are walking off the end of an
> > > > > unterminated list...
> > > >
> > > > 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...
> >
> > <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
On Tue, 13 Nov 2007 16:35:15 -0800 Greg KH <[email protected]> wrote:
> On Tue, Nov 13, 2007 at 04:01:44PM -0800, Andrew Morton wrote:
> > On Tue, 13 Nov 2007 15:14:10 -0800 Andrew Morton <[email protected]> wrote:
> >
> > > On Mon, 5 Nov 2007 12:03:34 -0800 Greg KH <[email protected]> wrote:
> > >
> > > > > > > <4> [<0000000000142548>] sys_reboot+0x1a4/0x1f4
> > > > > > > <4> [<0000000000111038>] sysc_noemu+0x10/0x16
> > > > > > > <4> [<00000200001048e0>] 0x200001048e0
> > > > > > > <4>
> > > > > > > <4>
> > > > > > >
> > > > > > > Huh? We want to shutdown an unknown device on a bus that wishes to stay
> > > > > > > anonymous?
> > > > > > >
> > > > > > > Any hints would be appreciated...
> > > > > >
> > > > > > I'll look into this, I wonder if we are walking off the end of an
> > > > > > unterminated list...
> > > > >
> > > > > 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...
> > >
> > > <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...
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.
On Fri, Nov 02, 2007 at 04:59:16PM -0700, Greg Kroah-Hartman wrote:
> 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.
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 <[email protected]>
Thanks,
Matt
--
Matt Domsch
Linux Technology Strategist, Dell Office of the CTO
linux.dell.com & http://www.dell.com/linux
On Fri, Nov 16, 2007 at 09:01:16AM -0600, Matt Domsch wrote:
> On Fri, Nov 02, 2007 at 04:59:16PM -0700, Greg Kroah-Hartman wrote:
> > 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.
>
>
> 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 <[email protected]>
Great, thanks for doing this, I appreciate it.
greg k-h