diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-12-21 17:29:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-12-21 17:29:42 -0500 |
commit | 8a25a2fd126c621f44f3aeaef80d51f00fc11639 (patch) | |
tree | 41694ab1a9c82a7a02d9cd33c929fd039c98c815 /drivers/cpuidle | |
parent | cb0c05c5fae12eeb7c85c205578df277bd706155 (diff) |
cpu: convert 'cpu' and 'machinecheck' sysdev_class to a regular subsystem
This moves the 'cpu sysdev_class' over to a regular 'cpu' subsystem
and converts the devices to regular devices. The sysdev drivers are
implemented as subsystem interfaces now.
After all sysdev classes are ported to regular driver core entities, the
sysdev implementation will be entirely removed from the kernel.
Userspace relies on events and generic sysfs subsystem infrastructure
from sysdev devices, which are made available with this conversion.
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Cc: Len Brown <lenb@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 12 | ||||
-rw-r--r-- | drivers/cpuidle/cpuidle.h | 10 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 74 |
3 files changed, 47 insertions, 49 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 06ce2680d00d..59f4261c753a 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -291,10 +291,10 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device); | |||
291 | static int __cpuidle_register_device(struct cpuidle_device *dev) | 291 | static int __cpuidle_register_device(struct cpuidle_device *dev) |
292 | { | 292 | { |
293 | int ret; | 293 | int ret; |
294 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); | 294 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); |
295 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); | 295 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
296 | 296 | ||
297 | if (!sys_dev) | 297 | if (!dev) |
298 | return -EINVAL; | 298 | return -EINVAL; |
299 | if (!try_module_get(cpuidle_driver->owner)) | 299 | if (!try_module_get(cpuidle_driver->owner)) |
300 | return -EINVAL; | 300 | return -EINVAL; |
@@ -303,7 +303,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
303 | 303 | ||
304 | per_cpu(cpuidle_devices, dev->cpu) = dev; | 304 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
305 | list_add(&dev->device_list, &cpuidle_detected_devices); | 305 | list_add(&dev->device_list, &cpuidle_detected_devices); |
306 | if ((ret = cpuidle_add_sysfs(sys_dev))) { | 306 | if ((ret = cpuidle_add_sysfs(cpu_dev))) { |
307 | module_put(cpuidle_driver->owner); | 307 | module_put(cpuidle_driver->owner); |
308 | return ret; | 308 | return ret; |
309 | } | 309 | } |
@@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device); | |||
344 | */ | 344 | */ |
345 | void cpuidle_unregister_device(struct cpuidle_device *dev) | 345 | void cpuidle_unregister_device(struct cpuidle_device *dev) |
346 | { | 346 | { |
347 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); | 347 | struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); |
348 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); | 348 | struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); |
349 | 349 | ||
350 | if (dev->registered == 0) | 350 | if (dev->registered == 0) |
@@ -354,7 +354,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) | |||
354 | 354 | ||
355 | cpuidle_disable_device(dev); | 355 | cpuidle_disable_device(dev); |
356 | 356 | ||
357 | cpuidle_remove_sysfs(sys_dev); | 357 | cpuidle_remove_sysfs(cpu_dev); |
358 | list_del(&dev->device_list); | 358 | list_del(&dev->device_list); |
359 | wait_for_completion(&dev->kobj_unregister); | 359 | wait_for_completion(&dev->kobj_unregister); |
360 | per_cpu(cpuidle_devices, dev->cpu) = NULL; | 360 | per_cpu(cpuidle_devices, dev->cpu) = NULL; |
@@ -411,7 +411,7 @@ static int __init cpuidle_init(void) | |||
411 | if (cpuidle_disabled()) | 411 | if (cpuidle_disabled()) |
412 | return -ENODEV; | 412 | return -ENODEV; |
413 | 413 | ||
414 | ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); | 414 | ret = cpuidle_add_interface(cpu_subsys.dev_root); |
415 | if (ret) | 415 | if (ret) |
416 | return ret; | 416 | return ret; |
417 | 417 | ||
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h index 38c3fd8b9d76..7db186685c27 100644 --- a/drivers/cpuidle/cpuidle.h +++ b/drivers/cpuidle/cpuidle.h | |||
@@ -5,7 +5,7 @@ | |||
5 | #ifndef __DRIVER_CPUIDLE_H | 5 | #ifndef __DRIVER_CPUIDLE_H |
6 | #define __DRIVER_CPUIDLE_H | 6 | #define __DRIVER_CPUIDLE_H |
7 | 7 | ||
8 | #include <linux/sysdev.h> | 8 | #include <linux/device.h> |
9 | 9 | ||
10 | /* For internal use only */ | 10 | /* For internal use only */ |
11 | extern struct cpuidle_governor *cpuidle_curr_governor; | 11 | extern struct cpuidle_governor *cpuidle_curr_governor; |
@@ -23,11 +23,11 @@ extern void cpuidle_uninstall_idle_handler(void); | |||
23 | extern int cpuidle_switch_governor(struct cpuidle_governor *gov); | 23 | extern int cpuidle_switch_governor(struct cpuidle_governor *gov); |
24 | 24 | ||
25 | /* sysfs */ | 25 | /* sysfs */ |
26 | extern int cpuidle_add_class_sysfs(struct sysdev_class *cls); | 26 | extern int cpuidle_add_interface(struct device *dev); |
27 | extern void cpuidle_remove_class_sysfs(struct sysdev_class *cls); | 27 | extern void cpuidle_remove_interface(struct device *dev); |
28 | extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); | 28 | extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); |
29 | extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); | 29 | extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); |
30 | extern int cpuidle_add_sysfs(struct sys_device *sysdev); | 30 | extern int cpuidle_add_sysfs(struct device *dev); |
31 | extern void cpuidle_remove_sysfs(struct sys_device *sysdev); | 31 | extern void cpuidle_remove_sysfs(struct device *dev); |
32 | 32 | ||
33 | #endif /* __DRIVER_CPUIDLE_H */ | 33 | #endif /* __DRIVER_CPUIDLE_H */ |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 1e756e160dca..3fe41fe4851a 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -22,8 +22,8 @@ static int __init cpuidle_sysfs_setup(char *unused) | |||
22 | } | 22 | } |
23 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); | 23 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); |
24 | 24 | ||
25 | static ssize_t show_available_governors(struct sysdev_class *class, | 25 | static ssize_t show_available_governors(struct device *dev, |
26 | struct sysdev_class_attribute *attr, | 26 | struct device_attribute *attr, |
27 | char *buf) | 27 | char *buf) |
28 | { | 28 | { |
29 | ssize_t i = 0; | 29 | ssize_t i = 0; |
@@ -42,8 +42,8 @@ out: | |||
42 | return i; | 42 | return i; |
43 | } | 43 | } |
44 | 44 | ||
45 | static ssize_t show_current_driver(struct sysdev_class *class, | 45 | static ssize_t show_current_driver(struct device *dev, |
46 | struct sysdev_class_attribute *attr, | 46 | struct device_attribute *attr, |
47 | char *buf) | 47 | char *buf) |
48 | { | 48 | { |
49 | ssize_t ret; | 49 | ssize_t ret; |
@@ -59,8 +59,8 @@ static ssize_t show_current_driver(struct sysdev_class *class, | |||
59 | return ret; | 59 | return ret; |
60 | } | 60 | } |
61 | 61 | ||
62 | static ssize_t show_current_governor(struct sysdev_class *class, | 62 | static ssize_t show_current_governor(struct device *dev, |
63 | struct sysdev_class_attribute *attr, | 63 | struct device_attribute *attr, |
64 | char *buf) | 64 | char *buf) |
65 | { | 65 | { |
66 | ssize_t ret; | 66 | ssize_t ret; |
@@ -75,8 +75,8 @@ static ssize_t show_current_governor(struct sysdev_class *class, | |||
75 | return ret; | 75 | return ret; |
76 | } | 76 | } |
77 | 77 | ||
78 | static ssize_t store_current_governor(struct sysdev_class *class, | 78 | static ssize_t store_current_governor(struct device *dev, |
79 | struct sysdev_class_attribute *attr, | 79 | struct device_attribute *attr, |
80 | const char *buf, size_t count) | 80 | const char *buf, size_t count) |
81 | { | 81 | { |
82 | char gov_name[CPUIDLE_NAME_LEN]; | 82 | char gov_name[CPUIDLE_NAME_LEN]; |
@@ -109,50 +109,48 @@ static ssize_t store_current_governor(struct sysdev_class *class, | |||
109 | return count; | 109 | return count; |
110 | } | 110 | } |
111 | 111 | ||
112 | static SYSDEV_CLASS_ATTR(current_driver, 0444, show_current_driver, NULL); | 112 | static DEVICE_ATTR(current_driver, 0444, show_current_driver, NULL); |
113 | static SYSDEV_CLASS_ATTR(current_governor_ro, 0444, show_current_governor, | 113 | static DEVICE_ATTR(current_governor_ro, 0444, show_current_governor, NULL); |
114 | NULL); | ||
115 | 114 | ||
116 | static struct attribute *cpuclass_default_attrs[] = { | 115 | static struct attribute *cpuidle_default_attrs[] = { |
117 | &attr_current_driver.attr, | 116 | &dev_attr_current_driver.attr, |
118 | &attr_current_governor_ro.attr, | 117 | &dev_attr_current_governor_ro.attr, |
119 | NULL | 118 | NULL |
120 | }; | 119 | }; |
121 | 120 | ||
122 | static SYSDEV_CLASS_ATTR(available_governors, 0444, show_available_governors, | 121 | static DEVICE_ATTR(available_governors, 0444, show_available_governors, NULL); |
123 | NULL); | 122 | static DEVICE_ATTR(current_governor, 0644, show_current_governor, |
124 | static SYSDEV_CLASS_ATTR(current_governor, 0644, show_current_governor, | 123 | store_current_governor); |
125 | store_current_governor); | ||
126 | 124 | ||
127 | static struct attribute *cpuclass_switch_attrs[] = { | 125 | static struct attribute *cpuidle_switch_attrs[] = { |
128 | &attr_available_governors.attr, | 126 | &dev_attr_available_governors.attr, |
129 | &attr_current_driver.attr, | 127 | &dev_attr_current_driver.attr, |
130 | &attr_current_governor.attr, | 128 | &dev_attr_current_governor.attr, |
131 | NULL | 129 | NULL |
132 | }; | 130 | }; |
133 | 131 | ||
134 | static struct attribute_group cpuclass_attr_group = { | 132 | static struct attribute_group cpuidle_attr_group = { |
135 | .attrs = cpuclass_default_attrs, | 133 | .attrs = cpuidle_default_attrs, |
136 | .name = "cpuidle", | 134 | .name = "cpuidle", |
137 | }; | 135 | }; |
138 | 136 | ||
139 | /** | 137 | /** |
140 | * cpuidle_add_class_sysfs - add CPU global sysfs attributes | 138 | * cpuidle_add_interface - add CPU global sysfs attributes |
141 | */ | 139 | */ |
142 | int cpuidle_add_class_sysfs(struct sysdev_class *cls) | 140 | int cpuidle_add_interface(struct device *dev) |
143 | { | 141 | { |
144 | if (sysfs_switch) | 142 | if (sysfs_switch) |
145 | cpuclass_attr_group.attrs = cpuclass_switch_attrs; | 143 | cpuidle_attr_group.attrs = cpuidle_switch_attrs; |
146 | 144 | ||
147 | return sysfs_create_group(&cls->kset.kobj, &cpuclass_attr_group); | 145 | return sysfs_create_group(&dev->kobj, &cpuidle_attr_group); |
148 | } | 146 | } |
149 | 147 | ||
150 | /** | 148 | /** |
151 | * cpuidle_remove_class_sysfs - remove CPU global sysfs attributes | 149 | * cpuidle_remove_interface - remove CPU global sysfs attributes |
152 | */ | 150 | */ |
153 | void cpuidle_remove_class_sysfs(struct sysdev_class *cls) | 151 | void cpuidle_remove_interface(struct device *dev) |
154 | { | 152 | { |
155 | sysfs_remove_group(&cls->kset.kobj, &cpuclass_attr_group); | 153 | sysfs_remove_group(&dev->kobj, &cpuidle_attr_group); |
156 | } | 154 | } |
157 | 155 | ||
158 | struct cpuidle_attr { | 156 | struct cpuidle_attr { |
@@ -365,16 +363,16 @@ void cpuidle_remove_state_sysfs(struct cpuidle_device *device) | |||
365 | 363 | ||
366 | /** | 364 | /** |
367 | * cpuidle_add_sysfs - creates a sysfs instance for the target device | 365 | * cpuidle_add_sysfs - creates a sysfs instance for the target device |
368 | * @sysdev: the target device | 366 | * @dev: the target device |
369 | */ | 367 | */ |
370 | int cpuidle_add_sysfs(struct sys_device *sysdev) | 368 | int cpuidle_add_sysfs(struct device *cpu_dev) |
371 | { | 369 | { |
372 | int cpu = sysdev->id; | 370 | int cpu = cpu_dev->id; |
373 | struct cpuidle_device *dev; | 371 | struct cpuidle_device *dev; |
374 | int error; | 372 | int error; |
375 | 373 | ||
376 | dev = per_cpu(cpuidle_devices, cpu); | 374 | dev = per_cpu(cpuidle_devices, cpu); |
377 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj, | 375 | error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, |
378 | "cpuidle"); | 376 | "cpuidle"); |
379 | if (!error) | 377 | if (!error) |
380 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 378 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
@@ -383,11 +381,11 @@ int cpuidle_add_sysfs(struct sys_device *sysdev) | |||
383 | 381 | ||
384 | /** | 382 | /** |
385 | * cpuidle_remove_sysfs - deletes a sysfs instance on the target device | 383 | * cpuidle_remove_sysfs - deletes a sysfs instance on the target device |
386 | * @sysdev: the target device | 384 | * @dev: the target device |
387 | */ | 385 | */ |
388 | void cpuidle_remove_sysfs(struct sys_device *sysdev) | 386 | void cpuidle_remove_sysfs(struct device *cpu_dev) |
389 | { | 387 | { |
390 | int cpu = sysdev->id; | 388 | int cpu = cpu_dev->id; |
391 | struct cpuidle_device *dev; | 389 | struct cpuidle_device *dev; |
392 | 390 | ||
393 | dev = per_cpu(cpuidle_devices, cpu); | 391 | dev = per_cpu(cpuidle_devices, cpu); |