aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-12-21 17:29:42 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-21 17:29:42 -0500
commit8a25a2fd126c621f44f3aeaef80d51f00fc11639 (patch)
tree41694ab1a9c82a7a02d9cd33c929fd039c98c815 /drivers
parentcb0c05c5fae12eeb7c85c205578df277bd706155 (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')
-rw-r--r--drivers/acpi/processor_driver.c6
-rw-r--r--drivers/acpi/processor_thermal.c1
-rw-r--r--drivers/base/cpu.c146
-rw-r--r--drivers/base/node.c8
-rw-r--r--drivers/base/topology.c51
-rw-r--r--drivers/cpufreq/cpufreq.c79
-rw-r--r--drivers/cpufreq/cpufreq_stats.c1
-rw-r--r--drivers/cpuidle/cpuidle.c12
-rw-r--r--drivers/cpuidle/cpuidle.h10
-rw-r--r--drivers/cpuidle/sysfs.c74
-rw-r--r--drivers/s390/char/sclp_config.c8
11 files changed, 199 insertions, 197 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 9d7bc9f6b6cc..20a68ca386de 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -446,7 +446,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
446{ 446{
447 struct acpi_processor *pr = NULL; 447 struct acpi_processor *pr = NULL;
448 int result = 0; 448 int result = 0;
449 struct sys_device *sysdev; 449 struct device *dev;
450 450
451 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); 451 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
452 if (!pr) 452 if (!pr)
@@ -491,8 +491,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
491 491
492 per_cpu(processors, pr->id) = pr; 492 per_cpu(processors, pr->id) = pr;
493 493
494 sysdev = get_cpu_sysdev(pr->id); 494 dev = get_cpu_device(pr->id);
495 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) { 495 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
496 result = -EFAULT; 496 result = -EFAULT;
497 goto err_free_cpumask; 497 goto err_free_cpumask;
498 } 498 }
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 870550d6a4bf..3b599abf2b40 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -30,7 +30,6 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33#include <linux/sysdev.h>
34 33
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36 35
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 251acea3d359..5bb0298fbcc0 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * drivers/base/cpu.c - basic CPU class support 2 * CPU subsystem support
3 */ 3 */
4 4
5#include <linux/sysdev.h>
6#include <linux/module.h> 5#include <linux/module.h>
7#include <linux/init.h> 6#include <linux/init.h>
8#include <linux/sched.h> 7#include <linux/sched.h>
@@ -14,40 +13,40 @@
14 13
15#include "base.h" 14#include "base.h"
16 15
17static struct sysdev_class_attribute *cpu_sysdev_class_attrs[]; 16struct bus_type cpu_subsys = {
18
19struct sysdev_class cpu_sysdev_class = {
20 .name = "cpu", 17 .name = "cpu",
21 .attrs = cpu_sysdev_class_attrs, 18 .dev_name = "cpu",
22}; 19};
23EXPORT_SYMBOL(cpu_sysdev_class); 20EXPORT_SYMBOL_GPL(cpu_subsys);
24 21
25static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); 22static DEFINE_PER_CPU(struct device *, cpu_sys_devices);
26 23
27#ifdef CONFIG_HOTPLUG_CPU 24#ifdef CONFIG_HOTPLUG_CPU
28static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr, 25static ssize_t show_online(struct device *dev,
26 struct device_attribute *attr,
29 char *buf) 27 char *buf)
30{ 28{
31 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 29 struct cpu *cpu = container_of(dev, struct cpu, dev);
32 30
33 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); 31 return sprintf(buf, "%u\n", !!cpu_online(cpu->dev.id));
34} 32}
35 33
36static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr, 34static ssize_t __ref store_online(struct device *dev,
37 const char *buf, size_t count) 35 struct device_attribute *attr,
36 const char *buf, size_t count)
38{ 37{
39 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 38 struct cpu *cpu = container_of(dev, struct cpu, dev);
40 ssize_t ret; 39 ssize_t ret;
41 40
42 cpu_hotplug_driver_lock(); 41 cpu_hotplug_driver_lock();
43 switch (buf[0]) { 42 switch (buf[0]) {
44 case '0': 43 case '0':
45 ret = cpu_down(cpu->sysdev.id); 44 ret = cpu_down(cpu->dev.id);
46 if (!ret) 45 if (!ret)
47 kobject_uevent(&dev->kobj, KOBJ_OFFLINE); 46 kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
48 break; 47 break;
49 case '1': 48 case '1':
50 ret = cpu_up(cpu->sysdev.id); 49 ret = cpu_up(cpu->dev.id);
51 if (!ret) 50 if (!ret)
52 kobject_uevent(&dev->kobj, KOBJ_ONLINE); 51 kobject_uevent(&dev->kobj, KOBJ_ONLINE);
53 break; 52 break;
@@ -60,44 +59,44 @@ static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribut
60 ret = count; 59 ret = count;
61 return ret; 60 return ret;
62} 61}
63static SYSDEV_ATTR(online, 0644, show_online, store_online); 62static DEVICE_ATTR(online, 0644, show_online, store_online);
64 63
65static void __cpuinit register_cpu_control(struct cpu *cpu) 64static void __cpuinit register_cpu_control(struct cpu *cpu)
66{ 65{
67 sysdev_create_file(&cpu->sysdev, &attr_online); 66 device_create_file(&cpu->dev, &dev_attr_online);
68} 67}
69void unregister_cpu(struct cpu *cpu) 68void unregister_cpu(struct cpu *cpu)
70{ 69{
71 int logical_cpu = cpu->sysdev.id; 70 int logical_cpu = cpu->dev.id;
72 71
73 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); 72 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));
74 73
75 sysdev_remove_file(&cpu->sysdev, &attr_online); 74 device_remove_file(&cpu->dev, &dev_attr_online);
76 75
77 sysdev_unregister(&cpu->sysdev); 76 device_unregister(&cpu->dev);
78 per_cpu(cpu_sys_devices, logical_cpu) = NULL; 77 per_cpu(cpu_sys_devices, logical_cpu) = NULL;
79 return; 78 return;
80} 79}
81 80
82#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 81#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
83static ssize_t cpu_probe_store(struct sysdev_class *class, 82static ssize_t cpu_probe_store(struct device *dev,
84 struct sysdev_class_attribute *attr, 83 struct device_attribute *attr,
85 const char *buf, 84 const char *buf,
86 size_t count) 85 size_t count)
87{ 86{
88 return arch_cpu_probe(buf, count); 87 return arch_cpu_probe(buf, count);
89} 88}
90 89
91static ssize_t cpu_release_store(struct sysdev_class *class, 90static ssize_t cpu_release_store(struct device *dev,
92 struct sysdev_class_attribute *attr, 91 struct device_attribute *attr,
93 const char *buf, 92 const char *buf,
94 size_t count) 93 size_t count)
95{ 94{
96 return arch_cpu_release(buf, count); 95 return arch_cpu_release(buf, count);
97} 96}
98 97
99static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 98static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
100static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); 99static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store);
101#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 100#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
102 101
103#else /* ... !CONFIG_HOTPLUG_CPU */ 102#else /* ... !CONFIG_HOTPLUG_CPU */
@@ -109,15 +108,15 @@ static inline void register_cpu_control(struct cpu *cpu)
109#ifdef CONFIG_KEXEC 108#ifdef CONFIG_KEXEC
110#include <linux/kexec.h> 109#include <linux/kexec.h>
111 110
112static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr, 111static ssize_t show_crash_notes(struct device *dev, struct device_attribute *attr,
113 char *buf) 112 char *buf)
114{ 113{
115 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 114 struct cpu *cpu = container_of(dev, struct cpu, dev);
116 ssize_t rc; 115 ssize_t rc;
117 unsigned long long addr; 116 unsigned long long addr;
118 int cpunum; 117 int cpunum;
119 118
120 cpunum = cpu->sysdev.id; 119 cpunum = cpu->dev.id;
121 120
122 /* 121 /*
123 * Might be reading other cpu's data based on which cpu read thread 122 * Might be reading other cpu's data based on which cpu read thread
@@ -129,7 +128,7 @@ static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute
129 rc = sprintf(buf, "%Lx\n", addr); 128 rc = sprintf(buf, "%Lx\n", addr);
130 return rc; 129 return rc;
131} 130}
132static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); 131static DEVICE_ATTR(crash_notes, 0400, show_crash_notes, NULL);
133#endif 132#endif
134 133
135/* 134/*
@@ -137,12 +136,12 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
137 */ 136 */
138 137
139struct cpu_attr { 138struct cpu_attr {
140 struct sysdev_class_attribute attr; 139 struct device_attribute attr;
141 const struct cpumask *const * const map; 140 const struct cpumask *const * const map;
142}; 141};
143 142
144static ssize_t show_cpus_attr(struct sysdev_class *class, 143static ssize_t show_cpus_attr(struct device *dev,
145 struct sysdev_class_attribute *attr, 144 struct device_attribute *attr,
146 char *buf) 145 char *buf)
147{ 146{
148 struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); 147 struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr);
@@ -153,10 +152,10 @@ static ssize_t show_cpus_attr(struct sysdev_class *class,
153 return n; 152 return n;
154} 153}
155 154
156#define _CPU_ATTR(name, map) \ 155#define _CPU_ATTR(name, map) \
157 { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } 156 { __ATTR(name, 0444, show_cpus_attr, NULL), map }
158 157
159/* Keep in sync with cpu_sysdev_class_attrs */ 158/* Keep in sync with cpu_subsys_attrs */
160static struct cpu_attr cpu_attrs[] = { 159static struct cpu_attr cpu_attrs[] = {
161 _CPU_ATTR(online, &cpu_online_mask), 160 _CPU_ATTR(online, &cpu_online_mask),
162 _CPU_ATTR(possible, &cpu_possible_mask), 161 _CPU_ATTR(possible, &cpu_possible_mask),
@@ -166,19 +165,19 @@ static struct cpu_attr cpu_attrs[] = {
166/* 165/*
167 * Print values for NR_CPUS and offlined cpus 166 * Print values for NR_CPUS and offlined cpus
168 */ 167 */
169static ssize_t print_cpus_kernel_max(struct sysdev_class *class, 168static ssize_t print_cpus_kernel_max(struct device *dev,
170 struct sysdev_class_attribute *attr, char *buf) 169 struct device_attribute *attr, char *buf)
171{ 170{
172 int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); 171 int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1);
173 return n; 172 return n;
174} 173}
175static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); 174static DEVICE_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
176 175
177/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ 176/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
178unsigned int total_cpus; 177unsigned int total_cpus;
179 178
180static ssize_t print_cpus_offline(struct sysdev_class *class, 179static ssize_t print_cpus_offline(struct device *dev,
181 struct sysdev_class_attribute *attr, char *buf) 180 struct device_attribute *attr, char *buf)
182{ 181{
183 int n = 0, len = PAGE_SIZE-2; 182 int n = 0, len = PAGE_SIZE-2;
184 cpumask_var_t offline; 183 cpumask_var_t offline;
@@ -205,7 +204,7 @@ static ssize_t print_cpus_offline(struct sysdev_class *class,
205 n += snprintf(&buf[n], len - n, "\n"); 204 n += snprintf(&buf[n], len - n, "\n");
206 return n; 205 return n;
207} 206}
208static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); 207static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
209 208
210/* 209/*
211 * register_cpu - Setup a sysfs device for a CPU. 210 * register_cpu - Setup a sysfs device for a CPU.
@@ -218,57 +217,66 @@ static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
218int __cpuinit register_cpu(struct cpu *cpu, int num) 217int __cpuinit register_cpu(struct cpu *cpu, int num)
219{ 218{
220 int error; 219 int error;
221 cpu->node_id = cpu_to_node(num);
222 cpu->sysdev.id = num;
223 cpu->sysdev.cls = &cpu_sysdev_class;
224
225 error = sysdev_register(&cpu->sysdev);
226 220
221 cpu->node_id = cpu_to_node(num);
222 cpu->dev.id = num;
223 cpu->dev.bus = &cpu_subsys;
224 error = device_register(&cpu->dev);
227 if (!error && cpu->hotpluggable) 225 if (!error && cpu->hotpluggable)
228 register_cpu_control(cpu); 226 register_cpu_control(cpu);
229 if (!error) 227 if (!error)
230 per_cpu(cpu_sys_devices, num) = &cpu->sysdev; 228 per_cpu(cpu_sys_devices, num) = &cpu->dev;
231 if (!error) 229 if (!error)
232 register_cpu_under_node(num, cpu_to_node(num)); 230 register_cpu_under_node(num, cpu_to_node(num));
233 231
234#ifdef CONFIG_KEXEC 232#ifdef CONFIG_KEXEC
235 if (!error) 233 if (!error)
236 error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes); 234 error = device_create_file(&cpu->dev, &dev_attr_crash_notes);
237#endif 235#endif
238 return error; 236 return error;
239} 237}
240 238
241struct sys_device *get_cpu_sysdev(unsigned cpu) 239struct device *get_cpu_device(unsigned cpu)
242{ 240{
243 if (cpu < nr_cpu_ids && cpu_possible(cpu)) 241 if (cpu < nr_cpu_ids && cpu_possible(cpu))
244 return per_cpu(cpu_sys_devices, cpu); 242 return per_cpu(cpu_sys_devices, cpu);
245 else 243 else
246 return NULL; 244 return NULL;
247} 245}
248EXPORT_SYMBOL_GPL(get_cpu_sysdev); 246EXPORT_SYMBOL_GPL(get_cpu_device);
247
248static struct attribute *cpu_root_attrs[] = {
249#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
250 &dev_attr_probe.attr,
251 &dev_attr_release.attr,
252#endif
253 &cpu_attrs[0].attr.attr,
254 &cpu_attrs[1].attr.attr,
255 &cpu_attrs[2].attr.attr,
256 &dev_attr_kernel_max.attr,
257 &dev_attr_offline.attr,
258 NULL
259};
260
261static struct attribute_group cpu_root_attr_group = {
262 .attrs = cpu_root_attrs,
263};
264
265static const struct attribute_group *cpu_root_attr_groups[] = {
266 &cpu_root_attr_group,
267 NULL,
268};
249 269
250int __init cpu_dev_init(void) 270int __init cpu_dev_init(void)
251{ 271{
252 int err; 272 int err;
253 273
254 err = sysdev_class_register(&cpu_sysdev_class); 274 err = subsys_system_register(&cpu_subsys, cpu_root_attr_groups);
275 if (err)
276 return err;
277
255#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 278#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
256 if (!err) 279 err = sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
257 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
258#endif 280#endif
259
260 return err; 281 return err;
261} 282}
262
263static struct sysdev_class_attribute *cpu_sysdev_class_attrs[] = {
264#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
265 &attr_probe,
266 &attr_release,
267#endif
268 &cpu_attrs[0].attr,
269 &cpu_attrs[1].attr,
270 &cpu_attrs[2].attr,
271 &attr_kernel_max,
272 &attr_offline,
273 NULL
274};
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 793f796c4da3..6ce1501c7de5 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -315,12 +315,12 @@ struct node node_devices[MAX_NUMNODES];
315int register_cpu_under_node(unsigned int cpu, unsigned int nid) 315int register_cpu_under_node(unsigned int cpu, unsigned int nid)
316{ 316{
317 int ret; 317 int ret;
318 struct sys_device *obj; 318 struct device *obj;
319 319
320 if (!node_online(nid)) 320 if (!node_online(nid))
321 return 0; 321 return 0;
322 322
323 obj = get_cpu_sysdev(cpu); 323 obj = get_cpu_device(cpu);
324 if (!obj) 324 if (!obj)
325 return 0; 325 return 0;
326 326
@@ -337,12 +337,12 @@ int register_cpu_under_node(unsigned int cpu, unsigned int nid)
337 337
338int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) 338int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
339{ 339{
340 struct sys_device *obj; 340 struct device *obj;
341 341
342 if (!node_online(nid)) 342 if (!node_online(nid))
343 return 0; 343 return 0;
344 344
345 obj = get_cpu_sysdev(cpu); 345 obj = get_cpu_device(cpu);
346 if (!obj) 346 if (!obj)
347 return 0; 347 return 0;
348 348
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index f6f37a05a0c3..ae989c57cd5e 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -23,7 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * 24 *
25 */ 25 */
26#include <linux/sysdev.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/mm.h> 27#include <linux/mm.h>
29#include <linux/cpu.h> 28#include <linux/cpu.h>
@@ -32,14 +31,14 @@
32#include <linux/topology.h> 31#include <linux/topology.h>
33 32
34#define define_one_ro_named(_name, _func) \ 33#define define_one_ro_named(_name, _func) \
35static SYSDEV_ATTR(_name, 0444, _func, NULL) 34 static DEVICE_ATTR(_name, 0444, _func, NULL)
36 35
37#define define_one_ro(_name) \ 36#define define_one_ro(_name) \
38static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) 37 static DEVICE_ATTR(_name, 0444, show_##_name, NULL)
39 38
40#define define_id_show_func(name) \ 39#define define_id_show_func(name) \
41static ssize_t show_##name(struct sys_device *dev, \ 40static ssize_t show_##name(struct device *dev, \
42 struct sysdev_attribute *attr, char *buf) \ 41 struct device_attribute *attr, char *buf) \
43{ \ 42{ \
44 unsigned int cpu = dev->id; \ 43 unsigned int cpu = dev->id; \
45 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 44 return sprintf(buf, "%d\n", topology_##name(cpu)); \
@@ -65,16 +64,16 @@ static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf)
65 64
66#ifdef arch_provides_topology_pointers 65#ifdef arch_provides_topology_pointers
67#define define_siblings_show_map(name) \ 66#define define_siblings_show_map(name) \
68static ssize_t show_##name(struct sys_device *dev, \ 67static ssize_t show_##name(struct device *dev, \
69 struct sysdev_attribute *attr, char *buf) \ 68 struct device_attribute *attr, char *buf) \
70{ \ 69{ \
71 unsigned int cpu = dev->id; \ 70 unsigned int cpu = dev->id; \
72 return show_cpumap(0, topology_##name(cpu), buf); \ 71 return show_cpumap(0, topology_##name(cpu), buf); \
73} 72}
74 73
75#define define_siblings_show_list(name) \ 74#define define_siblings_show_list(name) \
76static ssize_t show_##name##_list(struct sys_device *dev, \ 75static ssize_t show_##name##_list(struct device *dev, \
77 struct sysdev_attribute *attr, \ 76 struct device_attribute *attr, \
78 char *buf) \ 77 char *buf) \
79{ \ 78{ \
80 unsigned int cpu = dev->id; \ 79 unsigned int cpu = dev->id; \
@@ -83,15 +82,15 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
83 82
84#else 83#else
85#define define_siblings_show_map(name) \ 84#define define_siblings_show_map(name) \
86static ssize_t show_##name(struct sys_device *dev, \ 85static ssize_t show_##name(struct device *dev, \
87 struct sysdev_attribute *attr, char *buf) \ 86 struct device_attribute *attr, char *buf) \
88{ \ 87{ \
89 return show_cpumap(0, topology_##name(dev->id), buf); \ 88 return show_cpumap(0, topology_##name(dev->id), buf); \
90} 89}
91 90
92#define define_siblings_show_list(name) \ 91#define define_siblings_show_list(name) \
93static ssize_t show_##name##_list(struct sys_device *dev, \ 92static ssize_t show_##name##_list(struct device *dev, \
94 struct sysdev_attribute *attr, \ 93 struct device_attribute *attr, \
95 char *buf) \ 94 char *buf) \
96{ \ 95{ \
97 return show_cpumap(1, topology_##name(dev->id), buf); \ 96 return show_cpumap(1, topology_##name(dev->id), buf); \
@@ -124,16 +123,16 @@ define_one_ro_named(book_siblings_list, show_book_cpumask_list);
124#endif 123#endif
125 124
126static struct attribute *default_attrs[] = { 125static struct attribute *default_attrs[] = {
127 &attr_physical_package_id.attr, 126 &dev_attr_physical_package_id.attr,
128 &attr_core_id.attr, 127 &dev_attr_core_id.attr,
129 &attr_thread_siblings.attr, 128 &dev_attr_thread_siblings.attr,
130 &attr_thread_siblings_list.attr, 129 &dev_attr_thread_siblings_list.attr,
131 &attr_core_siblings.attr, 130 &dev_attr_core_siblings.attr,
132 &attr_core_siblings_list.attr, 131 &dev_attr_core_siblings_list.attr,
133#ifdef CONFIG_SCHED_BOOK 132#ifdef CONFIG_SCHED_BOOK
134 &attr_book_id.attr, 133 &dev_attr_book_id.attr,
135 &attr_book_siblings.attr, 134 &dev_attr_book_siblings.attr,
136 &attr_book_siblings_list.attr, 135 &dev_attr_book_siblings_list.attr,
137#endif 136#endif
138 NULL 137 NULL
139}; 138};
@@ -146,16 +145,16 @@ static struct attribute_group topology_attr_group = {
146/* Add/Remove cpu_topology interface for CPU device */ 145/* Add/Remove cpu_topology interface for CPU device */
147static int __cpuinit topology_add_dev(unsigned int cpu) 146static int __cpuinit topology_add_dev(unsigned int cpu)
148{ 147{
149 struct sys_device *sys_dev = get_cpu_sysdev(cpu); 148 struct device *dev = get_cpu_device(cpu);
150 149
151 return sysfs_create_group(&sys_dev->kobj, &topology_attr_group); 150 return sysfs_create_group(&dev->kobj, &topology_attr_group);
152} 151}
153 152
154static void __cpuinit topology_remove_dev(unsigned int cpu) 153static void __cpuinit topology_remove_dev(unsigned int cpu)
155{ 154{
156 struct sys_device *sys_dev = get_cpu_sysdev(cpu); 155 struct device *dev = get_cpu_device(cpu);
157 156
158 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group); 157 sysfs_remove_group(&dev->kobj, &topology_attr_group);
159} 158}
160 159
161static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, 160static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 987a165ede26..8c2df3499da7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -679,7 +679,7 @@ static struct kobj_type ktype_cpufreq = {
679 */ 679 */
680static int cpufreq_add_dev_policy(unsigned int cpu, 680static int cpufreq_add_dev_policy(unsigned int cpu,
681 struct cpufreq_policy *policy, 681 struct cpufreq_policy *policy,
682 struct sys_device *sys_dev) 682 struct device *dev)
683{ 683{
684 int ret = 0; 684 int ret = 0;
685#ifdef CONFIG_SMP 685#ifdef CONFIG_SMP
@@ -728,7 +728,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu,
728 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 728 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
729 729
730 pr_debug("CPU already managed, adding link\n"); 730 pr_debug("CPU already managed, adding link\n");
731 ret = sysfs_create_link(&sys_dev->kobj, 731 ret = sysfs_create_link(&dev->kobj,
732 &managed_policy->kobj, 732 &managed_policy->kobj,
733 "cpufreq"); 733 "cpufreq");
734 if (ret) 734 if (ret)
@@ -761,7 +761,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
761 761
762 for_each_cpu(j, policy->cpus) { 762 for_each_cpu(j, policy->cpus) {
763 struct cpufreq_policy *managed_policy; 763 struct cpufreq_policy *managed_policy;
764 struct sys_device *cpu_sys_dev; 764 struct device *cpu_dev;
765 765
766 if (j == cpu) 766 if (j == cpu)
767 continue; 767 continue;
@@ -770,8 +770,8 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
770 770
771 pr_debug("CPU %u already managed, adding link\n", j); 771 pr_debug("CPU %u already managed, adding link\n", j);
772 managed_policy = cpufreq_cpu_get(cpu); 772 managed_policy = cpufreq_cpu_get(cpu);
773 cpu_sys_dev = get_cpu_sysdev(j); 773 cpu_dev = get_cpu_device(j);
774 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, 774 ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj,
775 "cpufreq"); 775 "cpufreq");
776 if (ret) { 776 if (ret) {
777 cpufreq_cpu_put(managed_policy); 777 cpufreq_cpu_put(managed_policy);
@@ -783,7 +783,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
783 783
784static int cpufreq_add_dev_interface(unsigned int cpu, 784static int cpufreq_add_dev_interface(unsigned int cpu,
785 struct cpufreq_policy *policy, 785 struct cpufreq_policy *policy,
786 struct sys_device *sys_dev) 786 struct device *dev)
787{ 787{
788 struct cpufreq_policy new_policy; 788 struct cpufreq_policy new_policy;
789 struct freq_attr **drv_attr; 789 struct freq_attr **drv_attr;
@@ -793,7 +793,7 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
793 793
794 /* prepare interface data */ 794 /* prepare interface data */
795 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, 795 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
796 &sys_dev->kobj, "cpufreq"); 796 &dev->kobj, "cpufreq");
797 if (ret) 797 if (ret)
798 return ret; 798 return ret;
799 799
@@ -866,9 +866,9 @@ err_out_kobj_put:
866 * with with cpu hotplugging and all hell will break loose. Tried to clean this 866 * with with cpu hotplugging and all hell will break loose. Tried to clean this
867 * mess up, but more thorough testing is needed. - Mathieu 867 * mess up, but more thorough testing is needed. - Mathieu
868 */ 868 */
869static int cpufreq_add_dev(struct sys_device *sys_dev) 869static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
870{ 870{
871 unsigned int cpu = sys_dev->id; 871 unsigned int cpu = dev->id;
872 int ret = 0, found = 0; 872 int ret = 0, found = 0;
873 struct cpufreq_policy *policy; 873 struct cpufreq_policy *policy;
874 unsigned long flags; 874 unsigned long flags;
@@ -947,7 +947,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
947 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 947 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
948 CPUFREQ_START, policy); 948 CPUFREQ_START, policy);
949 949
950 ret = cpufreq_add_dev_policy(cpu, policy, sys_dev); 950 ret = cpufreq_add_dev_policy(cpu, policy, dev);
951 if (ret) { 951 if (ret) {
952 if (ret > 0) 952 if (ret > 0)
953 /* This is a managed cpu, symlink created, 953 /* This is a managed cpu, symlink created,
@@ -956,7 +956,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
956 goto err_unlock_policy; 956 goto err_unlock_policy;
957 } 957 }
958 958
959 ret = cpufreq_add_dev_interface(cpu, policy, sys_dev); 959 ret = cpufreq_add_dev_interface(cpu, policy, dev);
960 if (ret) 960 if (ret)
961 goto err_out_unregister; 961 goto err_out_unregister;
962 962
@@ -999,15 +999,15 @@ module_out:
999 * Caller should already have policy_rwsem in write mode for this CPU. 999 * Caller should already have policy_rwsem in write mode for this CPU.
1000 * This routine frees the rwsem before returning. 1000 * This routine frees the rwsem before returning.
1001 */ 1001 */
1002static int __cpufreq_remove_dev(struct sys_device *sys_dev) 1002static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1003{ 1003{
1004 unsigned int cpu = sys_dev->id; 1004 unsigned int cpu = dev->id;
1005 unsigned long flags; 1005 unsigned long flags;
1006 struct cpufreq_policy *data; 1006 struct cpufreq_policy *data;
1007 struct kobject *kobj; 1007 struct kobject *kobj;
1008 struct completion *cmp; 1008 struct completion *cmp;
1009#ifdef CONFIG_SMP 1009#ifdef CONFIG_SMP
1010 struct sys_device *cpu_sys_dev; 1010 struct device *cpu_dev;
1011 unsigned int j; 1011 unsigned int j;
1012#endif 1012#endif
1013 1013
@@ -1032,7 +1032,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1032 pr_debug("removing link\n"); 1032 pr_debug("removing link\n");
1033 cpumask_clear_cpu(cpu, data->cpus); 1033 cpumask_clear_cpu(cpu, data->cpus);
1034 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1034 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1035 kobj = &sys_dev->kobj; 1035 kobj = &dev->kobj;
1036 cpufreq_cpu_put(data); 1036 cpufreq_cpu_put(data);
1037 unlock_policy_rwsem_write(cpu); 1037 unlock_policy_rwsem_write(cpu);
1038 sysfs_remove_link(kobj, "cpufreq"); 1038 sysfs_remove_link(kobj, "cpufreq");
@@ -1071,8 +1071,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1071 strncpy(per_cpu(cpufreq_cpu_governor, j), 1071 strncpy(per_cpu(cpufreq_cpu_governor, j),
1072 data->governor->name, CPUFREQ_NAME_LEN); 1072 data->governor->name, CPUFREQ_NAME_LEN);
1073#endif 1073#endif
1074 cpu_sys_dev = get_cpu_sysdev(j); 1074 cpu_dev = get_cpu_device(j);
1075 kobj = &cpu_sys_dev->kobj; 1075 kobj = &cpu_dev->kobj;
1076 unlock_policy_rwsem_write(cpu); 1076 unlock_policy_rwsem_write(cpu);
1077 sysfs_remove_link(kobj, "cpufreq"); 1077 sysfs_remove_link(kobj, "cpufreq");
1078 lock_policy_rwsem_write(cpu); 1078 lock_policy_rwsem_write(cpu);
@@ -1112,11 +1112,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1112 if (unlikely(cpumask_weight(data->cpus) > 1)) { 1112 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1113 /* first sibling now owns the new sysfs dir */ 1113 /* first sibling now owns the new sysfs dir */
1114 cpumask_clear_cpu(cpu, data->cpus); 1114 cpumask_clear_cpu(cpu, data->cpus);
1115 cpufreq_add_dev(get_cpu_sysdev(cpumask_first(data->cpus))); 1115 cpufreq_add_dev(get_cpu_device(cpumask_first(data->cpus)), NULL);
1116 1116
1117 /* finally remove our own symlink */ 1117 /* finally remove our own symlink */
1118 lock_policy_rwsem_write(cpu); 1118 lock_policy_rwsem_write(cpu);
1119 __cpufreq_remove_dev(sys_dev); 1119 __cpufreq_remove_dev(dev, sif);
1120 } 1120 }
1121#endif 1121#endif
1122 1122
@@ -1128,9 +1128,9 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1128} 1128}
1129 1129
1130 1130
1131static int cpufreq_remove_dev(struct sys_device *sys_dev) 1131static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1132{ 1132{
1133 unsigned int cpu = sys_dev->id; 1133 unsigned int cpu = dev->id;
1134 int retval; 1134 int retval;
1135 1135
1136 if (cpu_is_offline(cpu)) 1136 if (cpu_is_offline(cpu))
@@ -1139,7 +1139,7 @@ static int cpufreq_remove_dev(struct sys_device *sys_dev)
1139 if (unlikely(lock_policy_rwsem_write(cpu))) 1139 if (unlikely(lock_policy_rwsem_write(cpu)))
1140 BUG(); 1140 BUG();
1141 1141
1142 retval = __cpufreq_remove_dev(sys_dev); 1142 retval = __cpufreq_remove_dev(dev, sif);
1143 return retval; 1143 return retval;
1144} 1144}
1145 1145
@@ -1271,9 +1271,11 @@ out:
1271} 1271}
1272EXPORT_SYMBOL(cpufreq_get); 1272EXPORT_SYMBOL(cpufreq_get);
1273 1273
1274static struct sysdev_driver cpufreq_sysdev_driver = { 1274static struct subsys_interface cpufreq_interface = {
1275 .add = cpufreq_add_dev, 1275 .name = "cpufreq",
1276 .remove = cpufreq_remove_dev, 1276 .subsys = &cpu_subsys,
1277 .add_dev = cpufreq_add_dev,
1278 .remove_dev = cpufreq_remove_dev,
1277}; 1279};
1278 1280
1279 1281
@@ -1765,25 +1767,25 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
1765 unsigned long action, void *hcpu) 1767 unsigned long action, void *hcpu)
1766{ 1768{
1767 unsigned int cpu = (unsigned long)hcpu; 1769 unsigned int cpu = (unsigned long)hcpu;
1768 struct sys_device *sys_dev; 1770 struct device *dev;
1769 1771
1770 sys_dev = get_cpu_sysdev(cpu); 1772 dev = get_cpu_device(cpu);
1771 if (sys_dev) { 1773 if (dev) {
1772 switch (action) { 1774 switch (action) {
1773 case CPU_ONLINE: 1775 case CPU_ONLINE:
1774 case CPU_ONLINE_FROZEN: 1776 case CPU_ONLINE_FROZEN:
1775 cpufreq_add_dev(sys_dev); 1777 cpufreq_add_dev(dev, NULL);
1776 break; 1778 break;
1777 case CPU_DOWN_PREPARE: 1779 case CPU_DOWN_PREPARE:
1778 case CPU_DOWN_PREPARE_FROZEN: 1780 case CPU_DOWN_PREPARE_FROZEN:
1779 if (unlikely(lock_policy_rwsem_write(cpu))) 1781 if (unlikely(lock_policy_rwsem_write(cpu)))
1780 BUG(); 1782 BUG();
1781 1783
1782 __cpufreq_remove_dev(sys_dev); 1784 __cpufreq_remove_dev(dev, NULL);
1783 break; 1785 break;
1784 case CPU_DOWN_FAILED: 1786 case CPU_DOWN_FAILED:
1785 case CPU_DOWN_FAILED_FROZEN: 1787 case CPU_DOWN_FAILED_FROZEN:
1786 cpufreq_add_dev(sys_dev); 1788 cpufreq_add_dev(dev, NULL);
1787 break; 1789 break;
1788 } 1790 }
1789 } 1791 }
@@ -1830,8 +1832,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1830 cpufreq_driver = driver_data; 1832 cpufreq_driver = driver_data;
1831 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1833 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1832 1834
1833 ret = sysdev_driver_register(&cpu_sysdev_class, 1835 ret = subsys_interface_register(&cpufreq_interface);
1834 &cpufreq_sysdev_driver);
1835 if (ret) 1836 if (ret)
1836 goto err_null_driver; 1837 goto err_null_driver;
1837 1838
@@ -1850,7 +1851,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1850 if (ret) { 1851 if (ret) {
1851 pr_debug("no CPU initialized for driver %s\n", 1852 pr_debug("no CPU initialized for driver %s\n",
1852 driver_data->name); 1853 driver_data->name);
1853 goto err_sysdev_unreg; 1854 goto err_if_unreg;
1854 } 1855 }
1855 } 1856 }
1856 1857
@@ -1858,9 +1859,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1858 pr_debug("driver %s up and running\n", driver_data->name); 1859 pr_debug("driver %s up and running\n", driver_data->name);
1859 1860
1860 return 0; 1861 return 0;
1861err_sysdev_unreg: 1862err_if_unreg:
1862 sysdev_driver_unregister(&cpu_sysdev_class, 1863 subsys_interface_unregister(&cpufreq_interface);
1863 &cpufreq_sysdev_driver);
1864err_null_driver: 1864err_null_driver:
1865 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1865 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1866 cpufreq_driver = NULL; 1866 cpufreq_driver = NULL;
@@ -1887,7 +1887,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
1887 1887
1888 pr_debug("unregistering driver %s\n", driver->name); 1888 pr_debug("unregistering driver %s\n", driver->name);
1889 1889
1890 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); 1890 subsys_interface_unregister(&cpufreq_interface);
1891 unregister_hotcpu_notifier(&cpufreq_cpu_notifier); 1891 unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
1892 1892
1893 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1893 spin_lock_irqsave(&cpufreq_driver_lock, flags);
@@ -1907,8 +1907,7 @@ static int __init cpufreq_core_init(void)
1907 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); 1907 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
1908 } 1908 }
1909 1909
1910 cpufreq_global_kobject = kobject_create_and_add("cpufreq", 1910 cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
1911 &cpu_sysdev_class.kset.kobj);
1912 BUG_ON(!cpufreq_global_kobject); 1911 BUG_ON(!cpufreq_global_kobject);
1913 register_syscore_ops(&cpufreq_syscore_ops); 1912 register_syscore_ops(&cpufreq_syscore_ops);
1914 1913
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index c5072a91e848..390380a8cfc9 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/sysdev.h>
15#include <linux/cpu.h> 14#include <linux/cpu.h>
16#include <linux/sysfs.h> 15#include <linux/sysfs.h>
17#include <linux/cpufreq.h> 16#include <linux/cpufreq.h>
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);
291static int __cpuidle_register_device(struct cpuidle_device *dev) 291static 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 */
345void cpuidle_unregister_device(struct cpuidle_device *dev) 345void 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 */
11extern struct cpuidle_governor *cpuidle_curr_governor; 11extern struct cpuidle_governor *cpuidle_curr_governor;
@@ -23,11 +23,11 @@ extern void cpuidle_uninstall_idle_handler(void);
23extern int cpuidle_switch_governor(struct cpuidle_governor *gov); 23extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
24 24
25/* sysfs */ 25/* sysfs */
26extern int cpuidle_add_class_sysfs(struct sysdev_class *cls); 26extern int cpuidle_add_interface(struct device *dev);
27extern void cpuidle_remove_class_sysfs(struct sysdev_class *cls); 27extern void cpuidle_remove_interface(struct device *dev);
28extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); 28extern int cpuidle_add_state_sysfs(struct cpuidle_device *device);
29extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); 29extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
30extern int cpuidle_add_sysfs(struct sys_device *sysdev); 30extern int cpuidle_add_sysfs(struct device *dev);
31extern void cpuidle_remove_sysfs(struct sys_device *sysdev); 31extern 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
25static ssize_t show_available_governors(struct sysdev_class *class, 25static 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
45static ssize_t show_current_driver(struct sysdev_class *class, 45static 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
62static ssize_t show_current_governor(struct sysdev_class *class, 62static 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
78static ssize_t store_current_governor(struct sysdev_class *class, 78static 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
112static SYSDEV_CLASS_ATTR(current_driver, 0444, show_current_driver, NULL); 112static DEVICE_ATTR(current_driver, 0444, show_current_driver, NULL);
113static SYSDEV_CLASS_ATTR(current_governor_ro, 0444, show_current_governor, 113static DEVICE_ATTR(current_governor_ro, 0444, show_current_governor, NULL);
114 NULL);
115 114
116static struct attribute *cpuclass_default_attrs[] = { 115static 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
122static SYSDEV_CLASS_ATTR(available_governors, 0444, show_available_governors, 121static DEVICE_ATTR(available_governors, 0444, show_available_governors, NULL);
123 NULL); 122static DEVICE_ATTR(current_governor, 0644, show_current_governor,
124static SYSDEV_CLASS_ATTR(current_governor, 0644, show_current_governor, 123 store_current_governor);
125 store_current_governor);
126 124
127static struct attribute *cpuclass_switch_attrs[] = { 125static 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
134static struct attribute_group cpuclass_attr_group = { 132static 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 */
142int cpuidle_add_class_sysfs(struct sysdev_class *cls) 140int 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 */
153void cpuidle_remove_class_sysfs(struct sysdev_class *cls) 151void 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
158struct cpuidle_attr { 156struct 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 */
370int cpuidle_add_sysfs(struct sys_device *sysdev) 368int 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 */
388void cpuidle_remove_sysfs(struct sys_device *sysdev) 386void 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);
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c
index 95b909ac2b73..3c03c1060be6 100644
--- a/drivers/s390/char/sclp_config.c
+++ b/drivers/s390/char/sclp_config.c
@@ -11,7 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/cpu.h> 13#include <linux/cpu.h>
14#include <linux/sysdev.h> 14#include <linux/device.h>
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <asm/smp.h> 16#include <asm/smp.h>
17 17
@@ -31,14 +31,14 @@ static struct work_struct sclp_cpu_change_work;
31static void sclp_cpu_capability_notify(struct work_struct *work) 31static void sclp_cpu_capability_notify(struct work_struct *work)
32{ 32{
33 int cpu; 33 int cpu;
34 struct sys_device *sysdev; 34 struct device *dev;
35 35
36 s390_adjust_jiffies(); 36 s390_adjust_jiffies();
37 pr_warning("cpu capability changed.\n"); 37 pr_warning("cpu capability changed.\n");
38 get_online_cpus(); 38 get_online_cpus();
39 for_each_online_cpu(cpu) { 39 for_each_online_cpu(cpu) {
40 sysdev = get_cpu_sysdev(cpu); 40 dev = get_cpu_device(cpu);
41 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); 41 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
42 } 42 }
43 put_online_cpus(); 43 put_online_cpus();
44} 44}