kset: convert /sys/devices to use kset_create
Dynamically create the kset instead of declaring it statically. We also rename devices_subsys to devices_kset to catch all users of the variable. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
@@ -44,4 +44,4 @@ extern char *make_class_name(const char *name, struct kobject *kobj);
|
|||||||
|
|
||||||
extern int devres_release_all(struct device *dev);
|
extern int devres_release_all(struct device *dev);
|
||||||
|
|
||||||
extern struct kset devices_subsys;
|
extern struct kset *devices_kset;
|
||||||
|
@@ -401,11 +401,8 @@ static ssize_t show_dev(struct device *dev, struct device_attribute *attr,
|
|||||||
static struct device_attribute devt_attr =
|
static struct device_attribute devt_attr =
|
||||||
__ATTR(dev, S_IRUGO, show_dev, NULL);
|
__ATTR(dev, S_IRUGO, show_dev, NULL);
|
||||||
|
|
||||||
/*
|
/* kset to create /sys/devices/ */
|
||||||
* devices_subsys - structure to be registered with kobject core.
|
struct kset *devices_kset;
|
||||||
*/
|
|
||||||
|
|
||||||
decl_subsys(devices, &device_uevent_ops);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -525,7 +522,7 @@ static void klist_children_put(struct klist_node *n)
|
|||||||
|
|
||||||
void device_initialize(struct device *dev)
|
void device_initialize(struct device *dev)
|
||||||
{
|
{
|
||||||
dev->kobj.kset = &devices_subsys;
|
dev->kobj.kset = devices_kset;
|
||||||
dev->kobj.ktype = &device_ktype;
|
dev->kobj.ktype = &device_ktype;
|
||||||
kobject_init(&dev->kobj);
|
kobject_init(&dev->kobj);
|
||||||
klist_init(&dev->klist_children, klist_children_get,
|
klist_init(&dev->klist_children, klist_children_get,
|
||||||
@@ -563,7 +560,7 @@ static struct kobject *virtual_device_parent(struct device *dev)
|
|||||||
|
|
||||||
if (!virtual_dir)
|
if (!virtual_dir)
|
||||||
virtual_dir = kobject_create_and_add("virtual",
|
virtual_dir = kobject_create_and_add("virtual",
|
||||||
&devices_subsys.kobj);
|
&devices_kset->kobj);
|
||||||
|
|
||||||
return virtual_dir;
|
return virtual_dir;
|
||||||
}
|
}
|
||||||
@@ -1097,7 +1094,10 @@ struct device * device_find_child(struct device *parent, void *data,
|
|||||||
|
|
||||||
int __init devices_init(void)
|
int __init devices_init(void)
|
||||||
{
|
{
|
||||||
return subsystem_register(&devices_subsys);
|
devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
|
||||||
|
if (!devices_kset)
|
||||||
|
return -ENOMEM;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(device_for_each_child);
|
EXPORT_SYMBOL_GPL(device_for_each_child);
|
||||||
|
@@ -34,7 +34,7 @@ void device_shutdown(void)
|
|||||||
{
|
{
|
||||||
struct device * dev, *devn;
|
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) {
|
kobj.entry) {
|
||||||
if (dev->bus && dev->bus->shutdown) {
|
if (dev->bus && dev->bus->shutdown) {
|
||||||
dev_dbg(dev, "shutdown\n");
|
dev_dbg(dev, "shutdown\n");
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
|
|
||||||
extern struct kset devices_subsys;
|
|
||||||
|
|
||||||
#define to_sysdev(k) container_of(k, struct sys_device, kobj)
|
#define to_sysdev(k) container_of(k, struct sys_device, kobj)
|
||||||
#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
|
#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)
|
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);
|
return subsystem_register(&system_subsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user