Skip to content

Commit 039a5dc

Browse files
committed
kset: convert /sys/power to use kset_create
Dynamically create the kset instead of declaring it statically. We also rename power_subsys to power_kset to catch all users of the variable and we properly export it so that people don't have to guess that it really is present in the system. The pseries code is wierd, why is it createing /sys/power if CONFIG_PM is disabled? Oh well, stupid big boxes ignoring config options... Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 7405c1e commit 039a5dc

6 files changed

Lines changed: 15 additions & 19 deletions

File tree

‎arch/arm/mach-omap1/pm.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ static struct subsys_attribute sleep_while_idle_attr = {
9797
.store = omap_pm_sleep_while_idle_store,
9898
};
9999

100-
extern struct kset power_subsys;
101100
static void (*omap_sram_idle)(void) = NULL;
102101
static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
103102

@@ -726,7 +725,7 @@ static int __init omap_pm_init(void)
726725
omap_pm_init_proc();
727726
#endif
728727

729-
error = subsys_create_file(&power_subsys, &sleep_while_idle_attr);
728+
error = subsys_create_file(power_kset, &sleep_while_idle_attr);
730729
if (error)
731730
printk(KERN_ERR "subsys_create_file failed: %d\n", error);
732731

‎arch/powerpc/platforms/pseries/power.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static struct subsys_attribute auto_poweron_attr = {
5757
};
5858

5959
#ifndef CONFIG_PM
60-
decl_subsys(power, NULL);
60+
struct kset *power_kset;
6161

6262
static struct attribute *g[] = {
6363
&auto_poweron_attr.attr,
@@ -70,18 +70,16 @@ static struct attribute_group attr_group = {
7070

7171
static int __init pm_init(void)
7272
{
73-
int error = subsystem_register(&power_subsys);
74-
if (!error)
75-
error = sysfs_create_group(&power_subsys.kobj, &attr_group);
76-
return error;
73+
power_kset = kset_create_and_add("power", NULL, NULL);
74+
if (!power_kset)
75+
return -ENOMEM;
76+
return sysfs_create_group(&power_kset->kobj, &attr_group);
7777
}
7878
core_initcall(pm_init);
7979
#else
80-
extern struct kset power_subsys;
81-
8280
static int __init apo_pm_init(void)
8381
{
84-
return (subsys_create_file(&power_subsys, &auto_poweron_attr));
82+
return (subsys_create_file(power_kset, &auto_poweron_attr));
8583
}
8684
__initcall(apo_pm_init);
8785
#endif

‎include/linux/kobject.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ struct kset _name##_subsys = { \
198198
extern struct kset *kernel_kset;
199199
/* The global /sys/hypervisor/ kobject for people to chain off of */
200200
extern struct kobject *hypervisor_kobj;
201+
/* The global /sys/power/ kset for people to chain off of */
202+
extern struct kset *power_kset;
201203

202204
extern int __must_check subsystem_register(struct kset *);
203205
extern void subsystem_unregister(struct kset *);

‎kernel/power/disk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static struct attribute_group attr_group = {
708708

709709
static int __init pm_disk_init(void)
710710
{
711-
return sysfs_create_group(&power_subsys.kobj, &attr_group);
711+
return sysfs_create_group(&power_kset->kobj, &attr_group);
712712
}
713713

714714
core_initcall(pm_disk_init);

‎kernel/power/main.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ EXPORT_SYMBOL(pm_suspend);
276276

277277
#endif /* CONFIG_SUSPEND */
278278

279-
decl_subsys(power, NULL);
280-
279+
struct kset *power_kset;
281280

282281
/**
283282
* state - control system power state.
@@ -386,10 +385,10 @@ static struct attribute_group attr_group = {
386385

387386
static int __init pm_init(void)
388387
{
389-
int error = subsystem_register(&power_subsys);
390-
if (!error)
391-
error = sysfs_create_group(&power_subsys.kobj,&attr_group);
392-
return error;
388+
power_kset = kset_create_and_add("power", NULL, NULL);
389+
if (!power_kset)
390+
return -ENOMEM;
391+
return sysfs_create_group(&power_kset->kobj, &attr_group);
393392
}
394393

395394
core_initcall(pm_init);

‎kernel/power/power.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ static struct subsys_attribute _name##_attr = { \
6363
.store = _name##_store, \
6464
}
6565

66-
extern struct kset power_subsys;
67-
6866
/* Preferred image size in bytes (default 500 MB) */
6967
extern unsigned long image_size;
7068
extern int in_suspend;

0 commit comments

Comments
 (0)