aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/avr32/kernel/cpu.c74
-rw-r--r--arch/ia64/kernel/err_inject.c52
-rw-r--r--arch/ia64/kernel/topology.c10
-rw-r--r--arch/powerpc/include/asm/spu.h12
-rw-r--r--arch/powerpc/include/asm/topology.h10
-rw-r--r--arch/powerpc/kernel/cacheinfo.c10
-rw-r--r--arch/powerpc/kernel/smp.c2
-rw-r--r--arch/powerpc/kernel/sysfs.c257
-rw-r--r--arch/powerpc/mm/numa.c8
-rw-r--r--arch/powerpc/platforms/cell/cbe_thermal.c144
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c61
-rw-r--r--arch/powerpc/platforms/pseries/pseries_energy.c71
-rw-r--r--arch/powerpc/sysdev/ppc4xx_cpm.c6
-rw-r--r--arch/s390/kernel/smp.c76
-rw-r--r--arch/s390/kernel/topology.c6
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c24
-rw-r--r--arch/sparc/kernel/sysfs.c122
-rw-r--r--arch/tile/kernel/sysfs.c61
-rw-r--r--arch/x86/include/asm/mce.h2
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c25
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-internal.h4
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c128
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c11
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c63
-rw-r--r--arch/x86/kernel/microcode_core.c58
-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
-rw-r--r--include/linux/cpu.h18
-rw-r--r--kernel/sched.c40
38 files changed, 874 insertions, 877 deletions
diff --git a/arch/avr32/kernel/cpu.c b/arch/avr32/kernel/cpu.c
index e84faffbbec..2233be71e2e 100644
--- a/arch/avr32/kernel/cpu.c
+++ b/arch/avr32/kernel/cpu.c
@@ -6,7 +6,7 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/sysdev.h> 9#include <linux/device.h>
10#include <linux/seq_file.h> 10#include <linux/seq_file.h>
11#include <linux/cpu.h> 11#include <linux/cpu.h>
12#include <linux/module.h> 12#include <linux/module.h>
@@ -26,16 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
26 * XXX: If/when a SMP-capable implementation of AVR32 will ever be 26 * XXX: If/when a SMP-capable implementation of AVR32 will ever be
27 * made, we must make sure that the code executes on the correct CPU. 27 * made, we must make sure that the code executes on the correct CPU.
28 */ 28 */
29static ssize_t show_pc0event(struct sys_device *dev, 29static ssize_t show_pc0event(struct device *dev,
30 struct sysdev_attribute *attr, char *buf) 30 struct device_attribute *attr, char *buf)
31{ 31{
32 unsigned long pccr; 32 unsigned long pccr;
33 33
34 pccr = sysreg_read(PCCR); 34 pccr = sysreg_read(PCCR);
35 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f); 35 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
36} 36}
37static ssize_t store_pc0event(struct sys_device *dev, 37static ssize_t store_pc0event(struct device *dev,
38 struct sysdev_attribute *attr, const char *buf, 38 struct device_attribute *attr, const char *buf,
39 size_t count) 39 size_t count)
40{ 40{
41 unsigned long val; 41 unsigned long val;
@@ -48,16 +48,16 @@ static ssize_t store_pc0event(struct sys_device *dev,
48 sysreg_write(PCCR, val); 48 sysreg_write(PCCR, val);
49 return count; 49 return count;
50} 50}
51static ssize_t show_pc0count(struct sys_device *dev, 51static ssize_t show_pc0count(struct device *dev,
52 struct sysdev_attribute *attr, char *buf) 52 struct device_attribute *attr, char *buf)
53{ 53{
54 unsigned long pcnt0; 54 unsigned long pcnt0;
55 55
56 pcnt0 = sysreg_read(PCNT0); 56 pcnt0 = sysreg_read(PCNT0);
57 return sprintf(buf, "%lu\n", pcnt0); 57 return sprintf(buf, "%lu\n", pcnt0);
58} 58}
59static ssize_t store_pc0count(struct sys_device *dev, 59static ssize_t store_pc0count(struct device *dev,
60 struct sysdev_attribute *attr, 60 struct device_attribute *attr,
61 const char *buf, size_t count) 61 const char *buf, size_t count)
62{ 62{
63 unsigned long val; 63 unsigned long val;
@@ -71,16 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev,
71 return count; 71 return count;
72} 72}
73 73
74static ssize_t show_pc1event(struct sys_device *dev, 74static ssize_t show_pc1event(struct device *dev,
75 struct sysdev_attribute *attr, char *buf) 75 struct device_attribute *attr, char *buf)
76{ 76{
77 unsigned long pccr; 77 unsigned long pccr;
78 78
79 pccr = sysreg_read(PCCR); 79 pccr = sysreg_read(PCCR);
80 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f); 80 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
81} 81}
82static ssize_t store_pc1event(struct sys_device *dev, 82static ssize_t store_pc1event(struct device *dev,
83 struct sysdev_attribute *attr, const char *buf, 83 struct device_attribute *attr, const char *buf,
84 size_t count) 84 size_t count)
85{ 85{
86 unsigned long val; 86 unsigned long val;
@@ -93,16 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev,
93 sysreg_write(PCCR, val); 93 sysreg_write(PCCR, val);
94 return count; 94 return count;
95} 95}
96static ssize_t show_pc1count(struct sys_device *dev, 96static ssize_t show_pc1count(struct device *dev,
97 struct sysdev_attribute *attr, char *buf) 97 struct device_attribute *attr, char *buf)
98{ 98{
99 unsigned long pcnt1; 99 unsigned long pcnt1;
100 100
101 pcnt1 = sysreg_read(PCNT1); 101 pcnt1 = sysreg_read(PCNT1);
102 return sprintf(buf, "%lu\n", pcnt1); 102 return sprintf(buf, "%lu\n", pcnt1);
103} 103}
104static ssize_t store_pc1count(struct sys_device *dev, 104static ssize_t store_pc1count(struct device *dev,
105 struct sysdev_attribute *attr, const char *buf, 105 struct device_attribute *attr, const char *buf,
106 size_t count) 106 size_t count)
107{ 107{
108 unsigned long val; 108 unsigned long val;
@@ -116,16 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev,
116 return count; 116 return count;
117} 117}
118 118
119static ssize_t show_pccycles(struct sys_device *dev, 119static ssize_t show_pccycles(struct device *dev,
120 struct sysdev_attribute *attr, char *buf) 120 struct device_attribute *attr, char *buf)
121{ 121{
122 unsigned long pccnt; 122 unsigned long pccnt;
123 123
124 pccnt = sysreg_read(PCCNT); 124 pccnt = sysreg_read(PCCNT);
125 return sprintf(buf, "%lu\n", pccnt); 125 return sprintf(buf, "%lu\n", pccnt);
126} 126}
127static ssize_t store_pccycles(struct sys_device *dev, 127static ssize_t store_pccycles(struct device *dev,
128 struct sysdev_attribute *attr, const char *buf, 128 struct device_attribute *attr, const char *buf,
129 size_t count) 129 size_t count)
130{ 130{
131 unsigned long val; 131 unsigned long val;
@@ -139,16 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev,
139 return count; 139 return count;
140} 140}
141 141
142static ssize_t show_pcenable(struct sys_device *dev, 142static ssize_t show_pcenable(struct device *dev,
143 struct sysdev_attribute *attr, char *buf) 143 struct device_attribute *attr, char *buf)
144{ 144{
145 unsigned long pccr; 145 unsigned long pccr;
146 146
147 pccr = sysreg_read(PCCR); 147 pccr = sysreg_read(PCCR);
148 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0'); 148 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
149} 149}
150static ssize_t store_pcenable(struct sys_device *dev, 150static ssize_t store_pcenable(struct device *dev,
151 struct sysdev_attribute *attr, const char *buf, 151 struct device_attribute *attr, const char *buf,
152 size_t count) 152 size_t count)
153{ 153{
154 unsigned long pccr, val; 154 unsigned long pccr, val;
@@ -167,12 +167,12 @@ static ssize_t store_pcenable(struct sys_device *dev,
167 return count; 167 return count;
168} 168}
169 169
170static SYSDEV_ATTR(pc0event, 0600, show_pc0event, store_pc0event); 170static DEVICE_ATTR(pc0event, 0600, show_pc0event, store_pc0event);
171static SYSDEV_ATTR(pc0count, 0600, show_pc0count, store_pc0count); 171static DEVICE_ATTR(pc0count, 0600, show_pc0count, store_pc0count);
172static SYSDEV_ATTR(pc1event, 0600, show_pc1event, store_pc1event); 172static DEVICE_ATTR(pc1event, 0600, show_pc1event, store_pc1event);
173static SYSDEV_ATTR(pc1count, 0600, show_pc1count, store_pc1count); 173static DEVICE_ATTR(pc1count, 0600, show_pc1count, store_pc1count);
174static SYSDEV_ATTR(pccycles, 0600, show_pccycles, store_pccycles); 174static DEVICE_ATTR(pccycles, 0600, show_pccycles, store_pccycles);
175static SYSDEV_ATTR(pcenable, 0600, show_pcenable, store_pcenable); 175static DEVICE_ATTR(pcenable, 0600, show_pcenable, store_pcenable);
176 176
177#endif /* CONFIG_PERFORMANCE_COUNTERS */ 177#endif /* CONFIG_PERFORMANCE_COUNTERS */
178 178
@@ -186,12 +186,12 @@ static int __init topology_init(void)
186 register_cpu(c, cpu); 186 register_cpu(c, cpu);
187 187
188#ifdef CONFIG_PERFORMANCE_COUNTERS 188#ifdef CONFIG_PERFORMANCE_COUNTERS
189 sysdev_create_file(&c->sysdev, &attr_pc0event); 189 device_create_file(&c->dev, &dev_attr_pc0event);
190 sysdev_create_file(&c->sysdev, &attr_pc0count); 190 device_create_file(&c->dev, &dev_attr_pc0count);
191 sysdev_create_file(&c->sysdev, &attr_pc1event); 191 device_create_file(&c->dev, &dev_attr_pc1event);
192 sysdev_create_file(&c->sysdev, &attr_pc1count); 192 device_create_file(&c->dev, &dev_attr_pc1count);
193 sysdev_create_file(&c->sysdev, &attr_pccycles); 193 device_create_file(&c->dev, &dev_attr_pccycles);
194 sysdev_create_file(&c->sysdev, &attr_pcenable); 194 device_create_file(&c->dev, &dev_attr_pcenable);
195#endif 195#endif
196 } 196 }
197 197
diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index c539c689493..2d67317a1ec 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -24,7 +24,7 @@
24 * Copyright (C) 2006, Intel Corp. All rights reserved. 24 * Copyright (C) 2006, Intel Corp. All rights reserved.
25 * 25 *
26 */ 26 */
27#include <linux/sysdev.h> 27#include <linux/device.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/cpu.h> 30#include <linux/cpu.h>
@@ -35,10 +35,10 @@
35#define ERR_DATA_BUFFER_SIZE 3 // Three 8-byte; 35#define ERR_DATA_BUFFER_SIZE 3 // Three 8-byte;
36 36
37#define define_one_ro(name) \ 37#define define_one_ro(name) \
38static SYSDEV_ATTR(name, 0444, show_##name, NULL) 38static DEVICE_ATTR(name, 0444, show_##name, NULL)
39 39
40#define define_one_rw(name) \ 40#define define_one_rw(name) \
41static SYSDEV_ATTR(name, 0644, show_##name, store_##name) 41static DEVICE_ATTR(name, 0644, show_##name, store_##name)
42 42
43static u64 call_start[NR_CPUS]; 43static u64 call_start[NR_CPUS];
44static u64 phys_addr[NR_CPUS]; 44static u64 phys_addr[NR_CPUS];
@@ -55,7 +55,7 @@ static u64 resources[NR_CPUS];
55 55
56#define show(name) \ 56#define show(name) \
57static ssize_t \ 57static ssize_t \
58show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ 58show_##name(struct device *dev, struct device_attribute *attr, \
59 char *buf) \ 59 char *buf) \
60{ \ 60{ \
61 u32 cpu=dev->id; \ 61 u32 cpu=dev->id; \
@@ -64,7 +64,7 @@ show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
64 64
65#define store(name) \ 65#define store(name) \
66static ssize_t \ 66static ssize_t \
67store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ 67store_##name(struct device *dev, struct device_attribute *attr, \
68 const char *buf, size_t size) \ 68 const char *buf, size_t size) \
69{ \ 69{ \
70 unsigned int cpu=dev->id; \ 70 unsigned int cpu=dev->id; \
@@ -78,7 +78,7 @@ show(call_start)
78 * processor. The cpu number in driver is only used for storing data. 78 * processor. The cpu number in driver is only used for storing data.
79 */ 79 */
80static ssize_t 80static ssize_t
81store_call_start(struct sys_device *dev, struct sysdev_attribute *attr, 81store_call_start(struct device *dev, struct device_attribute *attr,
82 const char *buf, size_t size) 82 const char *buf, size_t size)
83{ 83{
84 unsigned int cpu=dev->id; 84 unsigned int cpu=dev->id;
@@ -127,7 +127,7 @@ show(err_type_info)
127store(err_type_info) 127store(err_type_info)
128 128
129static ssize_t 129static ssize_t
130show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, 130show_virtual_to_phys(struct device *dev, struct device_attribute *attr,
131 char *buf) 131 char *buf)
132{ 132{
133 unsigned int cpu=dev->id; 133 unsigned int cpu=dev->id;
@@ -135,7 +135,7 @@ show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
135} 135}
136 136
137static ssize_t 137static ssize_t
138store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, 138store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
139 const char *buf, size_t size) 139 const char *buf, size_t size)
140{ 140{
141 unsigned int cpu=dev->id; 141 unsigned int cpu=dev->id;
@@ -159,8 +159,8 @@ show(err_struct_info)
159store(err_struct_info) 159store(err_struct_info)
160 160
161static ssize_t 161static ssize_t
162show_err_data_buffer(struct sys_device *dev, 162show_err_data_buffer(struct device *dev,
163 struct sysdev_attribute *attr, char *buf) 163 struct device_attribute *attr, char *buf)
164{ 164{
165 unsigned int cpu=dev->id; 165 unsigned int cpu=dev->id;
166 166
@@ -171,8 +171,8 @@ show_err_data_buffer(struct sys_device *dev,
171} 171}
172 172
173static ssize_t 173static ssize_t
174store_err_data_buffer(struct sys_device *dev, 174store_err_data_buffer(struct device *dev,
175 struct sysdev_attribute *attr, 175 struct device_attribute *attr,
176 const char *buf, size_t size) 176 const char *buf, size_t size)
177{ 177{
178 unsigned int cpu=dev->id; 178 unsigned int cpu=dev->id;
@@ -209,14 +209,14 @@ define_one_ro(capabilities);
209define_one_ro(resources); 209define_one_ro(resources);
210 210
211static struct attribute *default_attrs[] = { 211static struct attribute *default_attrs[] = {
212 &attr_call_start.attr, 212 &dev_attr_call_start.attr,
213 &attr_virtual_to_phys.attr, 213 &dev_attr_virtual_to_phys.attr,
214 &attr_err_type_info.attr, 214 &dev_attr_err_type_info.attr,
215 &attr_err_struct_info.attr, 215 &dev_attr_err_struct_info.attr,
216 &attr_err_data_buffer.attr, 216 &dev_attr_err_data_buffer.attr,
217 &attr_status.attr, 217 &dev_attr_status.attr,
218 &attr_capabilities.attr, 218 &dev_attr_capabilities.attr,
219 &attr_resources.attr, 219 &dev_attr_resources.attr,
220 NULL 220 NULL
221}; 221};
222 222
@@ -225,12 +225,12 @@ static struct attribute_group err_inject_attr_group = {
225 .name = "err_inject" 225 .name = "err_inject"
226}; 226};
227/* Add/Remove err_inject interface for CPU device */ 227/* Add/Remove err_inject interface for CPU device */
228static int __cpuinit err_inject_add_dev(struct sys_device * sys_dev) 228static int __cpuinit err_inject_add_dev(struct device * sys_dev)
229{ 229{
230 return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group); 230 return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group);
231} 231}
232 232
233static int __cpuinit err_inject_remove_dev(struct sys_device * sys_dev) 233static int __cpuinit err_inject_remove_dev(struct device * sys_dev)
234{ 234{
235 sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); 235 sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
236 return 0; 236 return 0;
@@ -239,9 +239,9 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
239 unsigned long action, void *hcpu) 239 unsigned long action, void *hcpu)
240{ 240{
241 unsigned int cpu = (unsigned long)hcpu; 241 unsigned int cpu = (unsigned long)hcpu;
242 struct sys_device *sys_dev; 242 struct device *sys_dev;
243 243
244 sys_dev = get_cpu_sysdev(cpu); 244 sys_dev = get_cpu_device(cpu);
245 switch (action) { 245 switch (action) {
246 case CPU_ONLINE: 246 case CPU_ONLINE:
247 case CPU_ONLINE_FROZEN: 247 case CPU_ONLINE_FROZEN:
@@ -283,13 +283,13 @@ static void __exit
283err_inject_exit(void) 283err_inject_exit(void)
284{ 284{
285 int i; 285 int i;
286 struct sys_device *sys_dev; 286 struct device *sys_dev;
287 287
288#ifdef ERR_INJ_DEBUG 288#ifdef ERR_INJ_DEBUG
289 printk(KERN_INFO "Exit error injection driver.\n"); 289 printk(KERN_INFO "Exit error injection driver.\n");
290#endif 290#endif
291 for_each_online_cpu(i) { 291 for_each_online_cpu(i) {
292 sys_dev = get_cpu_sysdev(i); 292 sys_dev = get_cpu_device(i);
293 sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); 293 sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
294 } 294 }
295 unregister_hotcpu_notifier(&err_inject_cpu_notifier); 295 unregister_hotcpu_notifier(&err_inject_cpu_notifier);
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 9be1f11a01d..9deb21dbf62 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -350,7 +350,7 @@ static int __cpuinit cpu_cache_sysfs_init(unsigned int cpu)
350} 350}
351 351
352/* Add cache interface for CPU device */ 352/* Add cache interface for CPU device */
353static int __cpuinit cache_add_dev(struct sys_device * sys_dev) 353static int __cpuinit cache_add_dev(struct device * sys_dev)
354{ 354{
355 unsigned int cpu = sys_dev->id; 355 unsigned int cpu = sys_dev->id;
356 unsigned long i, j; 356 unsigned long i, j;
@@ -400,7 +400,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
400} 400}
401 401
402/* Remove cache interface for CPU device */ 402/* Remove cache interface for CPU device */
403static int __cpuinit cache_remove_dev(struct sys_device * sys_dev) 403static int __cpuinit cache_remove_dev(struct device * sys_dev)
404{ 404{
405 unsigned int cpu = sys_dev->id; 405 unsigned int cpu = sys_dev->id;
406 unsigned long i; 406 unsigned long i;
@@ -428,9 +428,9 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
428 unsigned long action, void *hcpu) 428 unsigned long action, void *hcpu)
429{ 429{
430 unsigned int cpu = (unsigned long)hcpu; 430 unsigned int cpu = (unsigned long)hcpu;
431 struct sys_device *sys_dev; 431 struct device *sys_dev;
432 432
433 sys_dev = get_cpu_sysdev(cpu); 433 sys_dev = get_cpu_device(cpu);
434 switch (action) { 434 switch (action) {
435 case CPU_ONLINE: 435 case CPU_ONLINE:
436 case CPU_ONLINE_FROZEN: 436 case CPU_ONLINE_FROZEN:
@@ -454,7 +454,7 @@ static int __init cache_sysfs_init(void)
454 int i; 454 int i;
455 455
456 for_each_online_cpu(i) { 456 for_each_online_cpu(i) {
457 struct sys_device *sys_dev = get_cpu_sysdev((unsigned int)i); 457 struct device *sys_dev = get_cpu_device((unsigned int)i);
458 cache_add_dev(sys_dev); 458 cache_add_dev(sys_dev);
459 } 459 }
460 460
diff --git a/arch/powerpc/include/asm/spu.h b/arch/powerpc/include/asm/spu.h
index 4e360bd4a35..fff921345dd 100644
--- a/arch/powerpc/include/asm/spu.h
+++ b/arch/powerpc/include/asm/spu.h
@@ -25,7 +25,7 @@
25#ifdef __KERNEL__ 25#ifdef __KERNEL__
26 26
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/sysdev.h> 28#include <linux/device.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30 30
31#define LS_SIZE (256 * 1024) 31#define LS_SIZE (256 * 1024)
@@ -166,7 +166,7 @@ struct spu {
166 /* beat only */ 166 /* beat only */
167 u64 shadow_int_mask_RW[3]; 167 u64 shadow_int_mask_RW[3];
168 168
169 struct sys_device sysdev; 169 struct device dev;
170 170
171 int has_mem_affinity; 171 int has_mem_affinity;
172 struct list_head aff_list; 172 struct list_head aff_list;
@@ -270,11 +270,11 @@ struct spufs_calls {
270int register_spu_syscalls(struct spufs_calls *calls); 270int register_spu_syscalls(struct spufs_calls *calls);
271void unregister_spu_syscalls(struct spufs_calls *calls); 271void unregister_spu_syscalls(struct spufs_calls *calls);
272 272
273int spu_add_sysdev_attr(struct sysdev_attribute *attr); 273int spu_add_dev_attr(struct device_attribute *attr);
274void spu_remove_sysdev_attr(struct sysdev_attribute *attr); 274void spu_remove_dev_attr(struct device_attribute *attr);
275 275
276int spu_add_sysdev_attr_group(struct attribute_group *attrs); 276int spu_add_dev_attr_group(struct attribute_group *attrs);
277void spu_remove_sysdev_attr_group(struct attribute_group *attrs); 277void spu_remove_dev_attr_group(struct attribute_group *attrs);
278 278
279int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, 279int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
280 unsigned long dsisr, unsigned *flt); 280 unsigned long dsisr, unsigned *flt);
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 1e104af0848..c97185885c6 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -3,7 +3,7 @@
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5 5
6struct sys_device; 6struct device;
7struct device_node; 7struct device_node;
8 8
9#ifdef CONFIG_NUMA 9#ifdef CONFIG_NUMA
@@ -86,19 +86,19 @@ extern int __node_distance(int, int);
86 86
87extern void __init dump_numa_cpu_topology(void); 87extern void __init dump_numa_cpu_topology(void);
88 88
89extern int sysfs_add_device_to_node(struct sys_device *dev, int nid); 89extern int sysfs_add_device_to_node(struct device *dev, int nid);
90extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid); 90extern void sysfs_remove_device_from_node(struct device *dev, int nid);
91 91
92#else 92#else
93 93
94static inline void dump_numa_cpu_topology(void) {} 94static inline void dump_numa_cpu_topology(void) {}
95 95
96static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid) 96static inline int sysfs_add_device_to_node(struct device *dev, int nid)
97{ 97{
98 return 0; 98 return 0;
99} 99}
100 100
101static inline void sysfs_remove_device_from_node(struct sys_device *dev, 101static inline void sysfs_remove_device_from_node(struct device *dev,
102 int nid) 102 int nid)
103{ 103{
104} 104}
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index a3c684b4c86..92c6b008dd2 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -451,15 +451,15 @@ out:
451static struct cache_dir *__cpuinit cacheinfo_create_cache_dir(unsigned int cpu_id) 451static struct cache_dir *__cpuinit cacheinfo_create_cache_dir(unsigned int cpu_id)
452{ 452{
453 struct cache_dir *cache_dir; 453 struct cache_dir *cache_dir;
454 struct sys_device *sysdev; 454 struct device *dev;
455 struct kobject *kobj = NULL; 455 struct kobject *kobj = NULL;
456 456
457 sysdev = get_cpu_sysdev(cpu_id); 457 dev = get_cpu_device(cpu_id);
458 WARN_ONCE(!sysdev, "no sysdev for CPU %i\n", cpu_id); 458 WARN_ONCE(!dev, "no dev for CPU %i\n", cpu_id);
459 if (!sysdev) 459 if (!dev)
460 goto err; 460 goto err;
461 461
462 kobj = kobject_create_and_add("cache", &sysdev->kobj); 462 kobj = kobject_create_and_add("cache", &dev->kobj);
463 if (!kobj) 463 if (!kobj)
464 goto err; 464 goto err;
465 465
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 25ddbfc7dd3..da08240353f 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -27,7 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/cache.h> 28#include <linux/cache.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/sysdev.h> 30#include <linux/device.h>
31#include <linux/cpu.h> 31#include <linux/cpu.h>
32#include <linux/notifier.h> 32#include <linux/notifier.h>
33#include <linux/topology.h> 33#include <linux/topology.h>
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index ce035c1905f..f396ef27916 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -1,4 +1,4 @@
1#include <linux/sysdev.h> 1#include <linux/device.h>
2#include <linux/cpu.h> 2#include <linux/cpu.h>
3#include <linux/smp.h> 3#include <linux/smp.h>
4#include <linux/percpu.h> 4#include <linux/percpu.h>
@@ -37,12 +37,12 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
37/* Time in microseconds we delay before sleeping in the idle loop */ 37/* Time in microseconds we delay before sleeping in the idle loop */
38DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 }; 38DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 };
39 39
40static ssize_t store_smt_snooze_delay(struct sys_device *dev, 40static ssize_t store_smt_snooze_delay(struct device *dev,
41 struct sysdev_attribute *attr, 41 struct device_attribute *attr,
42 const char *buf, 42 const char *buf,
43 size_t count) 43 size_t count)
44{ 44{
45 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 45 struct cpu *cpu = container_of(dev, struct cpu, dev);
46 ssize_t ret; 46 ssize_t ret;
47 long snooze; 47 long snooze;
48 48
@@ -50,21 +50,21 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev,
50 if (ret != 1) 50 if (ret != 1)
51 return -EINVAL; 51 return -EINVAL;
52 52
53 per_cpu(smt_snooze_delay, cpu->sysdev.id) = snooze; 53 per_cpu(smt_snooze_delay, cpu->dev.id) = snooze;
54 54
55 return count; 55 return count;
56} 56}
57 57
58static ssize_t show_smt_snooze_delay(struct sys_device *dev, 58static ssize_t show_smt_snooze_delay(struct device *dev,
59 struct sysdev_attribute *attr, 59 struct device_attribute *attr,
60 char *buf) 60 char *buf)
61{ 61{
62 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 62 struct cpu *cpu = container_of(dev, struct cpu, dev);
63 63
64 return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->sysdev.id)); 64 return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->dev.id));
65} 65}
66 66
67static SYSDEV_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay, 67static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
68 store_smt_snooze_delay); 68 store_smt_snooze_delay);
69 69
70static int __init setup_smt_snooze_delay(char *str) 70static int __init setup_smt_snooze_delay(char *str)
@@ -117,25 +117,25 @@ static void write_##NAME(void *val) \
117 ppc_enable_pmcs(); \ 117 ppc_enable_pmcs(); \
118 mtspr(ADDRESS, *(unsigned long *)val); \ 118 mtspr(ADDRESS, *(unsigned long *)val); \
119} \ 119} \
120static ssize_t show_##NAME(struct sys_device *dev, \ 120static ssize_t show_##NAME(struct device *dev, \
121 struct sysdev_attribute *attr, \ 121 struct device_attribute *attr, \
122 char *buf) \ 122 char *buf) \
123{ \ 123{ \
124 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 124 struct cpu *cpu = container_of(dev, struct cpu, dev); \
125 unsigned long val; \ 125 unsigned long val; \
126 smp_call_function_single(cpu->sysdev.id, read_##NAME, &val, 1); \ 126 smp_call_function_single(cpu->dev.id, read_##NAME, &val, 1); \
127 return sprintf(buf, "%lx\n", val); \ 127 return sprintf(buf, "%lx\n", val); \
128} \ 128} \
129static ssize_t __used \ 129static ssize_t __used \
130 store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \ 130 store_##NAME(struct device *dev, struct device_attribute *attr, \
131 const char *buf, size_t count) \ 131 const char *buf, size_t count) \
132{ \ 132{ \
133 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 133 struct cpu *cpu = container_of(dev, struct cpu, dev); \
134 unsigned long val; \ 134 unsigned long val; \
135 int ret = sscanf(buf, "%lx", &val); \ 135 int ret = sscanf(buf, "%lx", &val); \
136 if (ret != 1) \ 136 if (ret != 1) \
137 return -EINVAL; \ 137 return -EINVAL; \
138 smp_call_function_single(cpu->sysdev.id, write_##NAME, &val, 1); \ 138 smp_call_function_single(cpu->dev.id, write_##NAME, &val, 1); \
139 return count; \ 139 return count; \
140} 140}
141 141
@@ -178,22 +178,22 @@ SYSFS_PMCSETUP(purr, SPRN_PURR);
178SYSFS_PMCSETUP(spurr, SPRN_SPURR); 178SYSFS_PMCSETUP(spurr, SPRN_SPURR);
179SYSFS_PMCSETUP(dscr, SPRN_DSCR); 179SYSFS_PMCSETUP(dscr, SPRN_DSCR);
180 180
181static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra); 181static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
182static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL); 182static DEVICE_ATTR(spurr, 0600, show_spurr, NULL);
183static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr); 183static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr);
184static SYSDEV_ATTR(purr, 0600, show_purr, store_purr); 184static DEVICE_ATTR(purr, 0600, show_purr, store_purr);
185 185
186unsigned long dscr_default = 0; 186unsigned long dscr_default = 0;
187EXPORT_SYMBOL(dscr_default); 187EXPORT_SYMBOL(dscr_default);
188 188
189static ssize_t show_dscr_default(struct sysdev_class *class, 189static ssize_t show_dscr_default(struct device *dev,
190 struct sysdev_class_attribute *attr, char *buf) 190 struct device_attribute *attr, char *buf)
191{ 191{
192 return sprintf(buf, "%lx\n", dscr_default); 192 return sprintf(buf, "%lx\n", dscr_default);
193} 193}
194 194
195static ssize_t __used store_dscr_default(struct sysdev_class *class, 195static ssize_t __used store_dscr_default(struct device *dev,
196 struct sysdev_class_attribute *attr, const char *buf, 196 struct device_attribute *attr, const char *buf,
197 size_t count) 197 size_t count)
198{ 198{
199 unsigned long val; 199 unsigned long val;
@@ -207,15 +207,14 @@ static ssize_t __used store_dscr_default(struct sysdev_class *class,
207 return count; 207 return count;
208} 208}
209 209
210static SYSDEV_CLASS_ATTR(dscr_default, 0600, 210static DEVICE_ATTR(dscr_default, 0600,
211 show_dscr_default, store_dscr_default); 211 show_dscr_default, store_dscr_default);
212 212
213static void sysfs_create_dscr_default(void) 213static void sysfs_create_dscr_default(void)
214{ 214{
215 int err = 0; 215 int err = 0;
216 if (cpu_has_feature(CPU_FTR_DSCR)) 216 if (cpu_has_feature(CPU_FTR_DSCR))
217 err = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 217 err = device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
218 &attr_dscr_default.attr);
219} 218}
220#endif /* CONFIG_PPC64 */ 219#endif /* CONFIG_PPC64 */
221 220
@@ -259,72 +258,72 @@ SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
259#endif /* HAS_PPC_PMC_PA6T */ 258#endif /* HAS_PPC_PMC_PA6T */
260 259
261#ifdef HAS_PPC_PMC_IBM 260#ifdef HAS_PPC_PMC_IBM
262static struct sysdev_attribute ibm_common_attrs[] = { 261static struct device_attribute ibm_common_attrs[] = {
263 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 262 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
264 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 263 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
265}; 264};
266#endif /* HAS_PPC_PMC_G4 */ 265#endif /* HAS_PPC_PMC_G4 */
267 266
268#ifdef HAS_PPC_PMC_G4 267#ifdef HAS_PPC_PMC_G4
269static struct sysdev_attribute g4_common_attrs[] = { 268static struct device_attribute g4_common_attrs[] = {
270 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 269 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
271 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 270 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
272 _SYSDEV_ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2), 271 __ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2),
273}; 272};
274#endif /* HAS_PPC_PMC_G4 */ 273#endif /* HAS_PPC_PMC_G4 */
275 274
276static struct sysdev_attribute classic_pmc_attrs[] = { 275static struct device_attribute classic_pmc_attrs[] = {
277 _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1), 276 __ATTR(pmc1, 0600, show_pmc1, store_pmc1),
278 _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2), 277 __ATTR(pmc2, 0600, show_pmc2, store_pmc2),
279 _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3), 278 __ATTR(pmc3, 0600, show_pmc3, store_pmc3),
280 _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4), 279 __ATTR(pmc4, 0600, show_pmc4, store_pmc4),
281 _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5), 280 __ATTR(pmc5, 0600, show_pmc5, store_pmc5),
282 _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6), 281 __ATTR(pmc6, 0600, show_pmc6, store_pmc6),
283#ifdef CONFIG_PPC64 282#ifdef CONFIG_PPC64
284 _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7), 283 __ATTR(pmc7, 0600, show_pmc7, store_pmc7),
285 _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8), 284 __ATTR(pmc8, 0600, show_pmc8, store_pmc8),
286#endif 285#endif
287}; 286};
288 287
289#ifdef HAS_PPC_PMC_PA6T 288#ifdef HAS_PPC_PMC_PA6T
290static struct sysdev_attribute pa6t_attrs[] = { 289static struct device_attribute pa6t_attrs[] = {
291 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 290 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
292 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 291 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
293 _SYSDEV_ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0), 292 __ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
294 _SYSDEV_ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1), 293 __ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
295 _SYSDEV_ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2), 294 __ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
296 _SYSDEV_ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3), 295 __ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
297 _SYSDEV_ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4), 296 __ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
298 _SYSDEV_ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5), 297 __ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
299#ifdef CONFIG_DEBUG_KERNEL 298#ifdef CONFIG_DEBUG_KERNEL
300 _SYSDEV_ATTR(hid0, 0600, show_hid0, store_hid0), 299 __ATTR(hid0, 0600, show_hid0, store_hid0),
301 _SYSDEV_ATTR(hid1, 0600, show_hid1, store_hid1), 300 __ATTR(hid1, 0600, show_hid1, store_hid1),
302 _SYSDEV_ATTR(hid4, 0600, show_hid4, store_hid4), 301 __ATTR(hid4, 0600, show_hid4, store_hid4),
303 _SYSDEV_ATTR(hid5, 0600, show_hid5, store_hid5), 302 __ATTR(hid5, 0600, show_hid5, store_hid5),
304 _SYSDEV_ATTR(ima0, 0600, show_ima0, store_ima0), 303 __ATTR(ima0, 0600, show_ima0, store_ima0),
305 _SYSDEV_ATTR(ima1, 0600, show_ima1, store_ima1), 304 __ATTR(ima1, 0600, show_ima1, store_ima1),
306 _SYSDEV_ATTR(ima2, 0600, show_ima2, store_ima2), 305 __ATTR(ima2, 0600, show_ima2, store_ima2),
307 _SYSDEV_ATTR(ima3, 0600, show_ima3, store_ima3), 306 __ATTR(ima3, 0600, show_ima3, store_ima3),
308 _SYSDEV_ATTR(ima4, 0600, show_ima4, store_ima4), 307 __ATTR(ima4, 0600, show_ima4, store_ima4),
309 _SYSDEV_ATTR(ima5, 0600, show_ima5, store_ima5), 308 __ATTR(ima5, 0600, show_ima5, store_ima5),
310 _SYSDEV_ATTR(ima6, 0600, show_ima6, store_ima6), 309 __ATTR(ima6, 0600, show_ima6, store_ima6),
311 _SYSDEV_ATTR(ima7, 0600, show_ima7, store_ima7), 310 __ATTR(ima7, 0600, show_ima7, store_ima7),
312 _SYSDEV_ATTR(ima8, 0600, show_ima8, store_ima8), 311 __ATTR(ima8, 0600, show_ima8, store_ima8),
313 _SYSDEV_ATTR(ima9, 0600, show_ima9, store_ima9), 312 __ATTR(ima9, 0600, show_ima9, store_ima9),
314 _SYSDEV_ATTR(imaat, 0600, show_imaat, store_imaat), 313 __ATTR(imaat, 0600, show_imaat, store_imaat),
315 _SYSDEV_ATTR(btcr, 0600, show_btcr, store_btcr), 314 __ATTR(btcr, 0600, show_btcr, store_btcr),
316 _SYSDEV_ATTR(pccr, 0600, show_pccr, store_pccr), 315 __ATTR(pccr, 0600, show_pccr, store_pccr),
317 _SYSDEV_ATTR(rpccr, 0600, show_rpccr, store_rpccr), 316 __ATTR(rpccr, 0600, show_rpccr, store_rpccr),
318 _SYSDEV_ATTR(der, 0600, show_der, store_der), 317 __ATTR(der, 0600, show_der, store_der),
319 _SYSDEV_ATTR(mer, 0600, show_mer, store_mer), 318 __ATTR(mer, 0600, show_mer, store_mer),
320 _SYSDEV_ATTR(ber, 0600, show_ber, store_ber), 319 __ATTR(ber, 0600, show_ber, store_ber),
321 _SYSDEV_ATTR(ier, 0600, show_ier, store_ier), 320 __ATTR(ier, 0600, show_ier, store_ier),
322 _SYSDEV_ATTR(sier, 0600, show_sier, store_sier), 321 __ATTR(sier, 0600, show_sier, store_sier),
323 _SYSDEV_ATTR(siar, 0600, show_siar, store_siar), 322 __ATTR(siar, 0600, show_siar, store_siar),
324 _SYSDEV_ATTR(tsr0, 0600, show_tsr0, store_tsr0), 323 __ATTR(tsr0, 0600, show_tsr0, store_tsr0),
325 _SYSDEV_ATTR(tsr1, 0600, show_tsr1, store_tsr1), 324 __ATTR(tsr1, 0600, show_tsr1, store_tsr1),
326 _SYSDEV_ATTR(tsr2, 0600, show_tsr2, store_tsr2), 325 __ATTR(tsr2, 0600, show_tsr2, store_tsr2),
327 _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3), 326 __ATTR(tsr3, 0600, show_tsr3, store_tsr3),
328#endif /* CONFIG_DEBUG_KERNEL */ 327#endif /* CONFIG_DEBUG_KERNEL */
329}; 328};
330#endif /* HAS_PPC_PMC_PA6T */ 329#endif /* HAS_PPC_PMC_PA6T */
@@ -333,14 +332,14 @@ static struct sysdev_attribute pa6t_attrs[] = {
333static void __cpuinit register_cpu_online(unsigned int cpu) 332static void __cpuinit register_cpu_online(unsigned int cpu)
334{ 333{
335 struct cpu *c = &per_cpu(cpu_devices, cpu); 334 struct cpu *c = &per_cpu(cpu_devices, cpu);
336 struct sys_device *s = &c->sysdev; 335 struct device *s = &c->dev;
337 struct sysdev_attribute *attrs, *pmc_attrs; 336 struct device_attribute *attrs, *pmc_attrs;
338 int i, nattrs; 337 int i, nattrs;
339 338
340#ifdef CONFIG_PPC64 339#ifdef CONFIG_PPC64
341 if (!firmware_has_feature(FW_FEATURE_ISERIES) && 340 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
342 cpu_has_feature(CPU_FTR_SMT)) 341 cpu_has_feature(CPU_FTR_SMT))
343 sysdev_create_file(s, &attr_smt_snooze_delay); 342 device_create_file(s, &dev_attr_smt_snooze_delay);
344#endif 343#endif
345 344
346 /* PMC stuff */ 345 /* PMC stuff */
@@ -348,14 +347,14 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
348#ifdef HAS_PPC_PMC_IBM 347#ifdef HAS_PPC_PMC_IBM
349 case PPC_PMC_IBM: 348 case PPC_PMC_IBM:
350 attrs = ibm_common_attrs; 349 attrs = ibm_common_attrs;
351 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 350 nattrs = sizeof(ibm_common_attrs) / sizeof(struct device_attribute);
352 pmc_attrs = classic_pmc_attrs; 351 pmc_attrs = classic_pmc_attrs;
353 break; 352 break;
354#endif /* HAS_PPC_PMC_IBM */ 353#endif /* HAS_PPC_PMC_IBM */
355#ifdef HAS_PPC_PMC_G4 354#ifdef HAS_PPC_PMC_G4
356 case PPC_PMC_G4: 355 case PPC_PMC_G4:
357 attrs = g4_common_attrs; 356 attrs = g4_common_attrs;
358 nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute); 357 nattrs = sizeof(g4_common_attrs) / sizeof(struct device_attribute);
359 pmc_attrs = classic_pmc_attrs; 358 pmc_attrs = classic_pmc_attrs;
360 break; 359 break;
361#endif /* HAS_PPC_PMC_G4 */ 360#endif /* HAS_PPC_PMC_G4 */
@@ -363,7 +362,7 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
363 case PPC_PMC_PA6T: 362 case PPC_PMC_PA6T:
364 /* PA Semi starts counting at PMC0 */ 363 /* PA Semi starts counting at PMC0 */
365 attrs = pa6t_attrs; 364 attrs = pa6t_attrs;
366 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 365 nattrs = sizeof(pa6t_attrs) / sizeof(struct device_attribute);
367 pmc_attrs = NULL; 366 pmc_attrs = NULL;
368 break; 367 break;
369#endif /* HAS_PPC_PMC_PA6T */ 368#endif /* HAS_PPC_PMC_PA6T */
@@ -374,24 +373,24 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
374 } 373 }
375 374
376 for (i = 0; i < nattrs; i++) 375 for (i = 0; i < nattrs; i++)
377 sysdev_create_file(s, &attrs[i]); 376 device_create_file(s, &attrs[i]);
378 377
379 if (pmc_attrs) 378 if (pmc_attrs)
380 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 379 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
381 sysdev_create_file(s, &pmc_attrs[i]); 380 device_create_file(s, &pmc_attrs[i]);
382 381
383#ifdef CONFIG_PPC64 382#ifdef CONFIG_PPC64
384 if (cpu_has_feature(CPU_FTR_MMCRA)) 383 if (cpu_has_feature(CPU_FTR_MMCRA))
385 sysdev_create_file(s, &attr_mmcra); 384 device_create_file(s, &dev_attr_mmcra);
386 385
387 if (cpu_has_feature(CPU_FTR_PURR)) 386 if (cpu_has_feature(CPU_FTR_PURR))
388 sysdev_create_file(s, &attr_purr); 387 device_create_file(s, &dev_attr_purr);
389 388
390 if (cpu_has_feature(CPU_FTR_SPURR)) 389 if (cpu_has_feature(CPU_FTR_SPURR))
391 sysdev_create_file(s, &attr_spurr); 390 device_create_file(s, &dev_attr_spurr);
392 391
393 if (cpu_has_feature(CPU_FTR_DSCR)) 392 if (cpu_has_feature(CPU_FTR_DSCR))
394 sysdev_create_file(s, &attr_dscr); 393 device_create_file(s, &dev_attr_dscr);
395#endif /* CONFIG_PPC64 */ 394#endif /* CONFIG_PPC64 */
396 395
397 cacheinfo_cpu_online(cpu); 396 cacheinfo_cpu_online(cpu);
@@ -401,8 +400,8 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
401static void unregister_cpu_online(unsigned int cpu) 400static void unregister_cpu_online(unsigned int cpu)
402{ 401{
403 struct cpu *c = &per_cpu(cpu_devices, cpu); 402 struct cpu *c = &per_cpu(cpu_devices, cpu);
404 struct sys_device *s = &c->sysdev; 403 struct device *s = &c->dev;
405 struct sysdev_attribute *attrs, *pmc_attrs; 404 struct device_attribute *attrs, *pmc_attrs;
406 int i, nattrs; 405 int i, nattrs;
407 406
408 BUG_ON(!c->hotpluggable); 407 BUG_ON(!c->hotpluggable);
@@ -410,7 +409,7 @@ static void unregister_cpu_online(unsigned int cpu)
410#ifdef CONFIG_PPC64 409#ifdef CONFIG_PPC64
411 if (!firmware_has_feature(FW_FEATURE_ISERIES) && 410 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
412 cpu_has_feature(CPU_FTR_SMT)) 411 cpu_has_feature(CPU_FTR_SMT))
413 sysdev_remove_file(s, &attr_smt_snooze_delay); 412 device_remove_file(s, &dev_attr_smt_snooze_delay);
414#endif 413#endif
415 414
416 /* PMC stuff */ 415 /* PMC stuff */
@@ -418,14 +417,14 @@ static void unregister_cpu_online(unsigned int cpu)
418#ifdef HAS_PPC_PMC_IBM 417#ifdef HAS_PPC_PMC_IBM
419 case PPC_PMC_IBM: 418 case PPC_PMC_IBM:
420 attrs = ibm_common_attrs; 419 attrs = ibm_common_attrs;
421 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 420 nattrs = sizeof(ibm_common_attrs) / sizeof(struct device_attribute);
422 pmc_attrs = classic_pmc_attrs; 421 pmc_attrs = classic_pmc_attrs;
423 break; 422 break;
424#endif /* HAS_PPC_PMC_IBM */ 423#endif /* HAS_PPC_PMC_IBM */
425#ifdef HAS_PPC_PMC_G4 424#ifdef HAS_PPC_PMC_G4
426 case PPC_PMC_G4: 425 case PPC_PMC_G4:
427 attrs = g4_common_attrs; 426 attrs = g4_common_attrs;
428 nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute); 427 nattrs = sizeof(g4_common_attrs) / sizeof(struct device_attribute);
429 pmc_attrs = classic_pmc_attrs; 428 pmc_attrs = classic_pmc_attrs;
430 break; 429 break;
431#endif /* HAS_PPC_PMC_G4 */ 430#endif /* HAS_PPC_PMC_G4 */
@@ -433,7 +432,7 @@ static void unregister_cpu_online(unsigned int cpu)
433 case PPC_PMC_PA6T: 432 case PPC_PMC_PA6T:
434 /* PA Semi starts counting at PMC0 */ 433 /* PA Semi starts counting at PMC0 */
435 attrs = pa6t_attrs; 434 attrs = pa6t_attrs;
436 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 435 nattrs = sizeof(pa6t_attrs) / sizeof(struct device_attribute);
437 pmc_attrs = NULL; 436 pmc_attrs = NULL;
438 break; 437 break;
439#endif /* HAS_PPC_PMC_PA6T */ 438#endif /* HAS_PPC_PMC_PA6T */
@@ -444,24 +443,24 @@ static void unregister_cpu_online(unsigned int cpu)
444 } 443 }
445 444
446 for (i = 0; i < nattrs; i++) 445 for (i = 0; i < nattrs; i++)
447 sysdev_remove_file(s, &attrs[i]); 446 device_remove_file(s, &attrs[i]);
448 447
449 if (pmc_attrs) 448 if (pmc_attrs)
450 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 449 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
451 sysdev_remove_file(s, &pmc_attrs[i]); 450 device_remove_file(s, &pmc_attrs[i]);
452 451
453#ifdef CONFIG_PPC64 452#ifdef CONFIG_PPC64
454 if (cpu_has_feature(CPU_FTR_MMCRA)) 453 if (cpu_has_feature(CPU_FTR_MMCRA))
455 sysdev_remove_file(s, &attr_mmcra); 454 device_remove_file(s, &dev_attr_mmcra);
456 455
457 if (cpu_has_feature(CPU_FTR_PURR)) 456 if (cpu_has_feature(CPU_FTR_PURR))
458 sysdev_remove_file(s, &attr_purr); 457 device_remove_file(s, &dev_attr_purr);
459 458
460 if (cpu_has_feature(CPU_FTR_SPURR)) 459 if (cpu_has_feature(CPU_FTR_SPURR))
461 sysdev_remove_file(s, &attr_spurr); 460 device_remove_file(s, &dev_attr_spurr);
462 461
463 if (cpu_has_feature(CPU_FTR_DSCR)) 462 if (cpu_has_feature(CPU_FTR_DSCR))
464 sysdev_remove_file(s, &attr_dscr); 463 device_remove_file(s, &dev_attr_dscr);
465#endif /* CONFIG_PPC64 */ 464#endif /* CONFIG_PPC64 */
466 465
467 cacheinfo_cpu_offline(cpu); 466 cacheinfo_cpu_offline(cpu);
@@ -513,70 +512,70 @@ static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
513 512
514static DEFINE_MUTEX(cpu_mutex); 513static DEFINE_MUTEX(cpu_mutex);
515 514
516int cpu_add_sysdev_attr(struct sysdev_attribute *attr) 515int cpu_add_dev_attr(struct device_attribute *attr)
517{ 516{
518 int cpu; 517 int cpu;
519 518
520 mutex_lock(&cpu_mutex); 519 mutex_lock(&cpu_mutex);
521 520
522 for_each_possible_cpu(cpu) { 521 for_each_possible_cpu(cpu) {
523 sysdev_create_file(get_cpu_sysdev(cpu), attr); 522 device_create_file(get_cpu_device(cpu), attr);
524 } 523 }
525 524
526 mutex_unlock(&cpu_mutex); 525 mutex_unlock(&cpu_mutex);
527 return 0; 526 return 0;
528} 527}
529EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr); 528EXPORT_SYMBOL_GPL(cpu_add_dev_attr);
530 529
531int cpu_add_sysdev_attr_group(struct attribute_group *attrs) 530int cpu_add_dev_attr_group(struct attribute_group *attrs)
532{ 531{
533 int cpu; 532 int cpu;
534 struct sys_device *sysdev; 533 struct device *dev;
535 int ret; 534 int ret;
536 535
537 mutex_lock(&cpu_mutex); 536 mutex_lock(&cpu_mutex);
538 537
539 for_each_possible_cpu(cpu) { 538 for_each_possible_cpu(cpu) {
540 sysdev = get_cpu_sysdev(cpu); 539 dev = get_cpu_device(cpu);
541 ret = sysfs_create_group(&sysdev->kobj, attrs); 540 ret = sysfs_create_group(&dev->kobj, attrs);
542 WARN_ON(ret != 0); 541 WARN_ON(ret != 0);
543 } 542 }
544 543
545 mutex_unlock(&cpu_mutex); 544 mutex_unlock(&cpu_mutex);
546 return 0; 545 return 0;
547} 546}
548EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group); 547EXPORT_SYMBOL_GPL(cpu_add_dev_attr_group);
549 548
550 549
551void cpu_remove_sysdev_attr(struct sysdev_attribute *attr) 550void cpu_remove_dev_attr(struct device_attribute *attr)
552{ 551{
553 int cpu; 552 int cpu;
554 553
555 mutex_lock(&cpu_mutex); 554 mutex_lock(&cpu_mutex);
556 555
557 for_each_possible_cpu(cpu) { 556 for_each_possible_cpu(cpu) {
558 sysdev_remove_file(get_cpu_sysdev(cpu), attr); 557 device_remove_file(get_cpu_device(cpu), attr);
559 } 558 }
560 559
561 mutex_unlock(&cpu_mutex); 560 mutex_unlock(&cpu_mutex);
562} 561}
563EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr); 562EXPORT_SYMBOL_GPL(cpu_remove_dev_attr);
564 563
565void cpu_remove_sysdev_attr_group(struct attribute_group *attrs) 564void cpu_remove_dev_attr_group(struct attribute_group *attrs)
566{ 565{
567 int cpu; 566 int cpu;
568 struct sys_device *sysdev; 567 struct device *dev;
569 568
570 mutex_lock(&cpu_mutex); 569 mutex_lock(&cpu_mutex);
571 570
572 for_each_possible_cpu(cpu) { 571 for_each_possible_cpu(cpu) {
573 sysdev = get_cpu_sysdev(cpu); 572 dev = get_cpu_device(cpu);
574 sysfs_remove_group(&sysdev->kobj, attrs); 573 sysfs_remove_group(&dev->kobj, attrs);
575 } 574 }
576 575
577 mutex_unlock(&cpu_mutex); 576 mutex_unlock(&cpu_mutex);
578} 577}
579EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group); 578EXPORT_SYMBOL_GPL(cpu_remove_dev_attr_group);
580 579
581 580
582/* NUMA stuff */ 581/* NUMA stuff */
@@ -590,7 +589,7 @@ static void register_nodes(void)
590 register_one_node(i); 589 register_one_node(i);
591} 590}
592 591
593int sysfs_add_device_to_node(struct sys_device *dev, int nid) 592int sysfs_add_device_to_node(struct device *dev, int nid)
594{ 593{
595 struct node *node = &node_devices[nid]; 594 struct node *node = &node_devices[nid];
596 return sysfs_create_link(&node->sysdev.kobj, &dev->kobj, 595 return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
@@ -598,7 +597,7 @@ int sysfs_add_device_to_node(struct sys_device *dev, int nid)
598} 597}
599EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); 598EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
600 599
601void sysfs_remove_device_from_node(struct sys_device *dev, int nid) 600void sysfs_remove_device_from_node(struct device *dev, int nid)
602{ 601{
603 struct node *node = &node_devices[nid]; 602 struct node *node = &node_devices[nid];
604 sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj)); 603 sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
@@ -614,14 +613,14 @@ static void register_nodes(void)
614#endif 613#endif
615 614
616/* Only valid if CPU is present. */ 615/* Only valid if CPU is present. */
617static ssize_t show_physical_id(struct sys_device *dev, 616static ssize_t show_physical_id(struct device *dev,
618 struct sysdev_attribute *attr, char *buf) 617 struct device_attribute *attr, char *buf)
619{ 618{
620 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 619 struct cpu *cpu = container_of(dev, struct cpu, dev);
621 620
622 return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->sysdev.id)); 621 return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id));
623} 622}
624static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL); 623static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL);
625 624
626static int __init topology_init(void) 625static int __init topology_init(void)
627{ 626{
@@ -646,7 +645,7 @@ static int __init topology_init(void)
646 if (cpu_online(cpu) || c->hotpluggable) { 645 if (cpu_online(cpu) || c->hotpluggable) {
647 register_cpu(c, cpu); 646 register_cpu(c, cpu);
648 647
649 sysdev_create_file(&c->sysdev, &attr_physical_id); 648 device_create_file(&c->dev, &dev_attr_physical_id);
650 } 649 }
651 650
652 if (cpu_online(cpu)) 651 if (cpu_online(cpu))
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index c7dd4dec4df..f2b03a86343 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1452,7 +1452,7 @@ int arch_update_cpu_topology(void)
1452{ 1452{
1453 int cpu, nid, old_nid; 1453 int cpu, nid, old_nid;
1454 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0}; 1454 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0};
1455 struct sys_device *sysdev; 1455 struct device *dev;
1456 1456
1457 for_each_cpu(cpu,&cpu_associativity_changes_mask) { 1457 for_each_cpu(cpu,&cpu_associativity_changes_mask) {
1458 vphn_get_associativity(cpu, associativity); 1458 vphn_get_associativity(cpu, associativity);
@@ -1473,9 +1473,9 @@ int arch_update_cpu_topology(void)
1473 register_cpu_under_node(cpu, nid); 1473 register_cpu_under_node(cpu, nid);
1474 put_online_cpus(); 1474 put_online_cpus();
1475 1475
1476 sysdev = get_cpu_sysdev(cpu); 1476 dev = get_cpu_device(cpu);
1477 if (sysdev) 1477 if (dev)
1478 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); 1478 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
1479 } 1479 }
1480 1480
1481 return 1; 1481 return 1;
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
index 4d4c8c16912..94560db788b 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -46,7 +46,7 @@
46 */ 46 */
47 47
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/sysdev.h> 49#include <linux/device.h>
50#include <linux/kernel.h> 50#include <linux/kernel.h>
51#include <linux/cpu.h> 51#include <linux/cpu.h>
52#include <asm/spu.h> 52#include <asm/spu.h>
@@ -59,8 +59,8 @@
59#define TEMP_MIN 65 59#define TEMP_MIN 65
60#define TEMP_MAX 125 60#define TEMP_MAX 125
61 61
62#define SYSDEV_PREFIX_ATTR(_prefix,_name,_mode) \ 62#define DEVICE_PREFIX_ATTR(_prefix,_name,_mode) \
63struct sysdev_attribute attr_ ## _prefix ## _ ## _name = { \ 63struct device_attribute attr_ ## _prefix ## _ ## _name = { \
64 .attr = { .name = __stringify(_name), .mode = _mode }, \ 64 .attr = { .name = __stringify(_name), .mode = _mode }, \
65 .show = _prefix ## _show_ ## _name, \ 65 .show = _prefix ## _show_ ## _name, \
66 .store = _prefix ## _store_ ## _name, \ 66 .store = _prefix ## _store_ ## _name, \
@@ -76,36 +76,36 @@ static inline u8 temp_to_reg(u8 temp)
76 return ((temp - TEMP_MIN) >> 1) & 0x3f; 76 return ((temp - TEMP_MIN) >> 1) & 0x3f;
77} 77}
78 78
79static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev) 79static struct cbe_pmd_regs __iomem *get_pmd_regs(struct device *dev)
80{ 80{
81 struct spu *spu; 81 struct spu *spu;
82 82
83 spu = container_of(sysdev, struct spu, sysdev); 83 spu = container_of(dev, struct spu, dev);
84 84
85 return cbe_get_pmd_regs(spu_devnode(spu)); 85 return cbe_get_pmd_regs(spu_devnode(spu));
86} 86}
87 87
88/* returns the value for a given spu in a given register */ 88/* returns the value for a given spu in a given register */
89static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iomem *reg) 89static u8 spu_read_register_value(struct device *dev, union spe_reg __iomem *reg)
90{ 90{
91 union spe_reg value; 91 union spe_reg value;
92 struct spu *spu; 92 struct spu *spu;
93 93
94 spu = container_of(sysdev, struct spu, sysdev); 94 spu = container_of(dev, struct spu, dev);
95 value.val = in_be64(&reg->val); 95 value.val = in_be64(&reg->val);
96 96
97 return value.spe[spu->spe_id]; 97 return value.spe[spu->spe_id];
98} 98}
99 99
100static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr, 100static ssize_t spu_show_temp(struct device *dev, struct device_attribute *attr,
101 char *buf) 101 char *buf)
102{ 102{
103 u8 value; 103 u8 value;
104 struct cbe_pmd_regs __iomem *pmd_regs; 104 struct cbe_pmd_regs __iomem *pmd_regs;
105 105
106 pmd_regs = get_pmd_regs(sysdev); 106 pmd_regs = get_pmd_regs(dev);
107 107
108 value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1); 108 value = spu_read_register_value(dev, &pmd_regs->ts_ctsr1);
109 109
110 return sprintf(buf, "%d\n", reg_to_temp(value)); 110 return sprintf(buf, "%d\n", reg_to_temp(value));
111} 111}
@@ -147,48 +147,48 @@ static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char
147 return size; 147 return size;
148} 148}
149 149
150static ssize_t spu_show_throttle_end(struct sys_device *sysdev, 150static ssize_t spu_show_throttle_end(struct device *dev,
151 struct sysdev_attribute *attr, char *buf) 151 struct device_attribute *attr, char *buf)
152{ 152{
153 return show_throttle(get_pmd_regs(sysdev), buf, 0); 153 return show_throttle(get_pmd_regs(dev), buf, 0);
154} 154}
155 155
156static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, 156static ssize_t spu_show_throttle_begin(struct device *dev,
157 struct sysdev_attribute *attr, char *buf) 157 struct device_attribute *attr, char *buf)
158{ 158{
159 return show_throttle(get_pmd_regs(sysdev), buf, 8); 159 return show_throttle(get_pmd_regs(dev), buf, 8);
160} 160}
161 161
162static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, 162static ssize_t spu_show_throttle_full_stop(struct device *dev,
163 struct sysdev_attribute *attr, char *buf) 163 struct device_attribute *attr, char *buf)
164{ 164{
165 return show_throttle(get_pmd_regs(sysdev), buf, 16); 165 return show_throttle(get_pmd_regs(dev), buf, 16);
166} 166}
167 167
168static ssize_t spu_store_throttle_end(struct sys_device *sysdev, 168static ssize_t spu_store_throttle_end(struct device *dev,
169 struct sysdev_attribute *attr, const char *buf, size_t size) 169 struct device_attribute *attr, const char *buf, size_t size)
170{ 170{
171 return store_throttle(get_pmd_regs(sysdev), buf, size, 0); 171 return store_throttle(get_pmd_regs(dev), buf, size, 0);
172} 172}
173 173
174static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, 174static ssize_t spu_store_throttle_begin(struct device *dev,
175 struct sysdev_attribute *attr, const char *buf, size_t size) 175 struct device_attribute *attr, const char *buf, size_t size)
176{ 176{
177 return store_throttle(get_pmd_regs(sysdev), buf, size, 8); 177 return store_throttle(get_pmd_regs(dev), buf, size, 8);
178} 178}
179 179
180static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, 180static ssize_t spu_store_throttle_full_stop(struct device *dev,
181 struct sysdev_attribute *attr, const char *buf, size_t size) 181 struct device_attribute *attr, const char *buf, size_t size)
182{ 182{
183 return store_throttle(get_pmd_regs(sysdev), buf, size, 16); 183 return store_throttle(get_pmd_regs(dev), buf, size, 16);
184} 184}
185 185
186static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) 186static ssize_t ppe_show_temp(struct device *dev, char *buf, int pos)
187{ 187{
188 struct cbe_pmd_regs __iomem *pmd_regs; 188 struct cbe_pmd_regs __iomem *pmd_regs;
189 u64 value; 189 u64 value;
190 190
191 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); 191 pmd_regs = cbe_get_cpu_pmd_regs(dev->id);
192 value = in_be64(&pmd_regs->ts_ctsr2); 192 value = in_be64(&pmd_regs->ts_ctsr2);
193 193
194 value = (value >> pos) & 0x3f; 194 value = (value >> pos) & 0x3f;
@@ -199,64 +199,64 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
199 199
200/* shows the temperature of the DTS on the PPE, 200/* shows the temperature of the DTS on the PPE,
201 * located near the linear thermal sensor */ 201 * located near the linear thermal sensor */
202static ssize_t ppe_show_temp0(struct sys_device *sysdev, 202static ssize_t ppe_show_temp0(struct device *dev,
203 struct sysdev_attribute *attr, char *buf) 203 struct device_attribute *attr, char *buf)
204{ 204{
205 return ppe_show_temp(sysdev, buf, 32); 205 return ppe_show_temp(dev, buf, 32);
206} 206}
207 207
208/* shows the temperature of the second DTS on the PPE */ 208/* shows the temperature of the second DTS on the PPE */
209static ssize_t ppe_show_temp1(struct sys_device *sysdev, 209static ssize_t ppe_show_temp1(struct device *dev,
210 struct sysdev_attribute *attr, char *buf) 210 struct device_attribute *attr, char *buf)
211{ 211{
212 return ppe_show_temp(sysdev, buf, 0); 212 return ppe_show_temp(dev, buf, 0);
213} 213}
214 214
215static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, 215static ssize_t ppe_show_throttle_end(struct device *dev,
216 struct sysdev_attribute *attr, char *buf) 216 struct device_attribute *attr, char *buf)
217{ 217{
218 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32); 218 return show_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, 32);
219} 219}
220 220
221static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, 221static ssize_t ppe_show_throttle_begin(struct device *dev,
222 struct sysdev_attribute *attr, char *buf) 222 struct device_attribute *attr, char *buf)
223{ 223{
224 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40); 224 return show_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, 40);
225} 225}
226 226
227static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, 227static ssize_t ppe_show_throttle_full_stop(struct device *dev,
228 struct sysdev_attribute *attr, char *buf) 228 struct device_attribute *attr, char *buf)
229{ 229{
230 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48); 230 return show_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, 48);
231} 231}
232 232
233static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, 233static ssize_t ppe_store_throttle_end(struct device *dev,
234 struct sysdev_attribute *attr, const char *buf, size_t size) 234 struct device_attribute *attr, const char *buf, size_t size)
235{ 235{
236 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32); 236 return store_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, size, 32);
237} 237}
238 238
239static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, 239static ssize_t ppe_store_throttle_begin(struct device *dev,
240 struct sysdev_attribute *attr, const char *buf, size_t size) 240 struct device_attribute *attr, const char *buf, size_t size)
241{ 241{
242 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40); 242 return store_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, size, 40);
243} 243}
244 244
245static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, 245static ssize_t ppe_store_throttle_full_stop(struct device *dev,
246 struct sysdev_attribute *attr, const char *buf, size_t size) 246 struct device_attribute *attr, const char *buf, size_t size)
247{ 247{
248 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48); 248 return store_throttle(cbe_get_cpu_pmd_regs(dev->id), buf, size, 48);
249} 249}
250 250
251 251
252static struct sysdev_attribute attr_spu_temperature = { 252static struct device_attribute attr_spu_temperature = {
253 .attr = {.name = "temperature", .mode = 0400 }, 253 .attr = {.name = "temperature", .mode = 0400 },
254 .show = spu_show_temp, 254 .show = spu_show_temp,
255}; 255};
256 256
257static SYSDEV_PREFIX_ATTR(spu, throttle_end, 0600); 257static DEVICE_PREFIX_ATTR(spu, throttle_end, 0600);
258static SYSDEV_PREFIX_ATTR(spu, throttle_begin, 0600); 258static DEVICE_PREFIX_ATTR(spu, throttle_begin, 0600);
259static SYSDEV_PREFIX_ATTR(spu, throttle_full_stop, 0600); 259static DEVICE_PREFIX_ATTR(spu, throttle_full_stop, 0600);
260 260
261 261
262static struct attribute *spu_attributes[] = { 262static struct attribute *spu_attributes[] = {
@@ -272,19 +272,19 @@ static struct attribute_group spu_attribute_group = {
272 .attrs = spu_attributes, 272 .attrs = spu_attributes,
273}; 273};
274 274
275static struct sysdev_attribute attr_ppe_temperature0 = { 275static struct device_attribute attr_ppe_temperature0 = {
276 .attr = {.name = "temperature0", .mode = 0400 }, 276 .attr = {.name = "temperature0", .mode = 0400 },
277 .show = ppe_show_temp0, 277 .show = ppe_show_temp0,
278}; 278};
279 279
280static struct sysdev_attribute attr_ppe_temperature1 = { 280static struct device_attribute attr_ppe_temperature1 = {
281 .attr = {.name = "temperature1", .mode = 0400 }, 281 .attr = {.name = "temperature1", .mode = 0400 },
282 .show = ppe_show_temp1, 282 .show = ppe_show_temp1,
283}; 283};
284 284
285static SYSDEV_PREFIX_ATTR(ppe, throttle_end, 0600); 285static DEVICE_PREFIX_ATTR(ppe, throttle_end, 0600);
286static SYSDEV_PREFIX_ATTR(ppe, throttle_begin, 0600); 286static DEVICE_PREFIX_ATTR(ppe, throttle_begin, 0600);
287static SYSDEV_PREFIX_ATTR(ppe, throttle_full_stop, 0600); 287static DEVICE_PREFIX_ATTR(ppe, throttle_full_stop, 0600);
288 288
289static struct attribute *ppe_attributes[] = { 289static struct attribute *ppe_attributes[] = {
290 &attr_ppe_temperature0.attr, 290 &attr_ppe_temperature0.attr,
@@ -307,7 +307,7 @@ static int __init init_default_values(void)
307{ 307{
308 int cpu; 308 int cpu;
309 struct cbe_pmd_regs __iomem *pmd_regs; 309 struct cbe_pmd_regs __iomem *pmd_regs;
310 struct sys_device *sysdev; 310 struct device *dev;
311 union ppe_spe_reg tpr; 311 union ppe_spe_reg tpr;
312 union spe_reg str1; 312 union spe_reg str1;
313 u64 str2; 313 u64 str2;
@@ -349,14 +349,14 @@ static int __init init_default_values(void)
349 349
350 for_each_possible_cpu (cpu) { 350 for_each_possible_cpu (cpu) {
351 pr_debug("processing cpu %d\n", cpu); 351 pr_debug("processing cpu %d\n", cpu);
352 sysdev = get_cpu_sysdev(cpu); 352 dev = get_cpu_device(cpu);
353 353
354 if (!sysdev) { 354 if (!dev) {
355 pr_info("invalid sysdev pointer for cbe_thermal\n"); 355 pr_info("invalid dev pointer for cbe_thermal\n");
356 return -EINVAL; 356 return -EINVAL;
357 } 357 }
358 358
359 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); 359 pmd_regs = cbe_get_cpu_pmd_regs(dev->id);
360 360
361 if (!pmd_regs) { 361 if (!pmd_regs) {
362 pr_info("invalid CBE regs pointer for cbe_thermal\n"); 362 pr_info("invalid CBE regs pointer for cbe_thermal\n");
@@ -379,8 +379,8 @@ static int __init thermal_init(void)
379 int rc = init_default_values(); 379 int rc = init_default_values();
380 380
381 if (rc == 0) { 381 if (rc == 0) {
382 spu_add_sysdev_attr_group(&spu_attribute_group); 382 spu_add_dev_attr_group(&spu_attribute_group);
383 cpu_add_sysdev_attr_group(&ppe_attribute_group); 383 cpu_add_dev_attr_group(&ppe_attribute_group);
384 } 384 }
385 385
386 return rc; 386 return rc;
@@ -389,8 +389,8 @@ module_init(thermal_init);
389 389
390static void __exit thermal_exit(void) 390static void __exit thermal_exit(void)
391{ 391{
392 spu_remove_sysdev_attr_group(&spu_attribute_group); 392 spu_remove_dev_attr_group(&spu_attribute_group);
393 cpu_remove_sysdev_attr_group(&ppe_attribute_group); 393 cpu_remove_dev_attr_group(&ppe_attribute_group);
394} 394}
395module_exit(thermal_exit); 395module_exit(thermal_exit);
396 396
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 3675da73623..1708fb7aba3 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -522,31 +522,32 @@ void spu_init_channels(struct spu *spu)
522} 522}
523EXPORT_SYMBOL_GPL(spu_init_channels); 523EXPORT_SYMBOL_GPL(spu_init_channels);
524 524
525static struct sysdev_class spu_sysdev_class = { 525static struct bus_type spu_subsys = {
526 .name = "spu", 526 .name = "spu",
527 .dev_name = "spu",
527}; 528};
528 529
529int spu_add_sysdev_attr(struct sysdev_attribute *attr) 530int spu_add_dev_attr(struct device_attribute *attr)
530{ 531{
531 struct spu *spu; 532 struct spu *spu;
532 533
533 mutex_lock(&spu_full_list_mutex); 534 mutex_lock(&spu_full_list_mutex);
534 list_for_each_entry(spu, &spu_full_list, full_list) 535 list_for_each_entry(spu, &spu_full_list, full_list)
535 sysdev_create_file(&spu->sysdev, attr); 536 device_create_file(&spu->dev, attr);
536 mutex_unlock(&spu_full_list_mutex); 537 mutex_unlock(&spu_full_list_mutex);
537 538
538 return 0; 539 return 0;
539} 540}
540EXPORT_SYMBOL_GPL(spu_add_sysdev_attr); 541EXPORT_SYMBOL_GPL(spu_add_dev_attr);
541 542
542int spu_add_sysdev_attr_group(struct attribute_group *attrs) 543int spu_add_dev_attr_group(struct attribute_group *attrs)
543{ 544{
544 struct spu *spu; 545 struct spu *spu;
545 int rc = 0; 546 int rc = 0;
546 547
547 mutex_lock(&spu_full_list_mutex); 548 mutex_lock(&spu_full_list_mutex);
548 list_for_each_entry(spu, &spu_full_list, full_list) { 549 list_for_each_entry(spu, &spu_full_list, full_list) {
549 rc = sysfs_create_group(&spu->sysdev.kobj, attrs); 550 rc = sysfs_create_group(&spu->dev.kobj, attrs);
550 551
551 /* we're in trouble here, but try unwinding anyway */ 552 /* we're in trouble here, but try unwinding anyway */
552 if (rc) { 553 if (rc) {
@@ -555,7 +556,7 @@ int spu_add_sysdev_attr_group(struct attribute_group *attrs)
555 556
556 list_for_each_entry_continue_reverse(spu, 557 list_for_each_entry_continue_reverse(spu,
557 &spu_full_list, full_list) 558 &spu_full_list, full_list)
558 sysfs_remove_group(&spu->sysdev.kobj, attrs); 559 sysfs_remove_group(&spu->dev.kobj, attrs);
559 break; 560 break;
560 } 561 }
561 } 562 }
@@ -564,45 +565,45 @@ int spu_add_sysdev_attr_group(struct attribute_group *attrs)
564 565
565 return rc; 566 return rc;
566} 567}
567EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group); 568EXPORT_SYMBOL_GPL(spu_add_dev_attr_group);
568 569
569 570
570void spu_remove_sysdev_attr(struct sysdev_attribute *attr) 571void spu_remove_dev_attr(struct device_attribute *attr)
571{ 572{
572 struct spu *spu; 573 struct spu *spu;
573 574
574 mutex_lock(&spu_full_list_mutex); 575 mutex_lock(&spu_full_list_mutex);
575 list_for_each_entry(spu, &spu_full_list, full_list) 576 list_for_each_entry(spu, &spu_full_list, full_list)
576 sysdev_remove_file(&spu->sysdev, attr); 577 device_remove_file(&spu->dev, attr);
577 mutex_unlock(&spu_full_list_mutex); 578 mutex_unlock(&spu_full_list_mutex);
578} 579}
579EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr); 580EXPORT_SYMBOL_GPL(spu_remove_dev_attr);
580 581
581void spu_remove_sysdev_attr_group(struct attribute_group *attrs) 582void spu_remove_dev_attr_group(struct attribute_group *attrs)
582{ 583{
583 struct spu *spu; 584 struct spu *spu;
584 585
585 mutex_lock(&spu_full_list_mutex); 586 mutex_lock(&spu_full_list_mutex);
586 list_for_each_entry(spu, &spu_full_list, full_list) 587 list_for_each_entry(spu, &spu_full_list, full_list)
587 sysfs_remove_group(&spu->sysdev.kobj, attrs); 588 sysfs_remove_group(&spu->dev.kobj, attrs);
588 mutex_unlock(&spu_full_list_mutex); 589 mutex_unlock(&spu_full_list_mutex);
589} 590}
590EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr_group); 591EXPORT_SYMBOL_GPL(spu_remove_dev_attr_group);
591 592
592static int spu_create_sysdev(struct spu *spu) 593static int spu_create_dev(struct spu *spu)
593{ 594{
594 int ret; 595 int ret;
595 596
596 spu->sysdev.id = spu->number; 597 spu->dev.id = spu->number;
597 spu->sysdev.cls = &spu_sysdev_class; 598 spu->dev.bus = &spu_subsys;
598 ret = sysdev_register(&spu->sysdev); 599 ret = device_register(&spu->dev);
599 if (ret) { 600 if (ret) {
600 printk(KERN_ERR "Can't register SPU %d with sysfs\n", 601 printk(KERN_ERR "Can't register SPU %d with sysfs\n",
601 spu->number); 602 spu->number);
602 return ret; 603 return ret;
603 } 604 }
604 605
605 sysfs_add_device_to_node(&spu->sysdev, spu->node); 606 sysfs_add_device_to_node(&spu->dev, spu->node);
606 607
607 return 0; 608 return 0;
608} 609}
@@ -638,7 +639,7 @@ static int __init create_spu(void *data)
638 if (ret) 639 if (ret)
639 goto out_destroy; 640 goto out_destroy;
640 641
641 ret = spu_create_sysdev(spu); 642 ret = spu_create_dev(spu);
642 if (ret) 643 if (ret)
643 goto out_free_irqs; 644 goto out_free_irqs;
644 645
@@ -695,10 +696,10 @@ static unsigned long long spu_acct_time(struct spu *spu,
695} 696}
696 697
697 698
698static ssize_t spu_stat_show(struct sys_device *sysdev, 699static ssize_t spu_stat_show(struct device *dev,
699 struct sysdev_attribute *attr, char *buf) 700 struct device_attribute *attr, char *buf)
700{ 701{
701 struct spu *spu = container_of(sysdev, struct spu, sysdev); 702 struct spu *spu = container_of(dev, struct spu, dev);
702 703
703 return sprintf(buf, "%s %llu %llu %llu %llu " 704 return sprintf(buf, "%s %llu %llu %llu %llu "
704 "%llu %llu %llu %llu %llu %llu %llu %llu\n", 705 "%llu %llu %llu %llu %llu %llu %llu %llu\n",
@@ -717,7 +718,7 @@ static ssize_t spu_stat_show(struct sys_device *sysdev,
717 spu->stats.libassist); 718 spu->stats.libassist);
718} 719}
719 720
720static SYSDEV_ATTR(stat, 0644, spu_stat_show, NULL); 721static DEVICE_ATTR(stat, 0644, spu_stat_show, NULL);
721 722
722#ifdef CONFIG_KEXEC 723#ifdef CONFIG_KEXEC
723 724
@@ -816,8 +817,8 @@ static int __init init_spu_base(void)
816 if (!spu_management_ops) 817 if (!spu_management_ops)
817 goto out; 818 goto out;
818 819
819 /* create sysdev class for spus */ 820 /* create system subsystem for spus */
820 ret = sysdev_class_register(&spu_sysdev_class); 821 ret = subsys_system_register(&spu_subsys, NULL);
821 if (ret) 822 if (ret)
822 goto out; 823 goto out;
823 824
@@ -826,7 +827,7 @@ static int __init init_spu_base(void)
826 if (ret < 0) { 827 if (ret < 0) {
827 printk(KERN_WARNING "%s: Error initializing spus\n", 828 printk(KERN_WARNING "%s: Error initializing spus\n",
828 __func__); 829 __func__);
829 goto out_unregister_sysdev_class; 830 goto out_unregister_subsys;
830 } 831 }
831 832
832 if (ret > 0) 833 if (ret > 0)
@@ -836,15 +837,15 @@ static int __init init_spu_base(void)
836 xmon_register_spus(&spu_full_list); 837 xmon_register_spus(&spu_full_list);
837 crash_register_spus(&spu_full_list); 838 crash_register_spus(&spu_full_list);
838 mutex_unlock(&spu_full_list_mutex); 839 mutex_unlock(&spu_full_list_mutex);
839 spu_add_sysdev_attr(&attr_stat); 840 spu_add_dev_attr(&dev_attr_stat);
840 register_syscore_ops(&spu_syscore_ops); 841 register_syscore_ops(&spu_syscore_ops);
841 842
842 spu_init_affinity(); 843 spu_init_affinity();
843 844
844 return 0; 845 return 0;
845 846
846 out_unregister_sysdev_class: 847 out_unregister_subsys:
847 sysdev_class_unregister(&spu_sysdev_class); 848 bus_unregister(&spu_subsys);
848 out: 849 out:
849 return ret; 850 return ret;
850} 851}
diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
index c8b3c69fe89..af281dce510 100644
--- a/arch/powerpc/platforms/pseries/pseries_energy.c
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -15,7 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/sysdev.h> 18#include <linux/device.h>
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <asm/cputhreads.h> 21#include <asm/cputhreads.h>
@@ -184,7 +184,7 @@ static ssize_t get_best_energy_list(char *page, int activate)
184 return s-page; 184 return s-page;
185} 185}
186 186
187static ssize_t get_best_energy_data(struct sys_device *dev, 187static ssize_t get_best_energy_data(struct device *dev,
188 char *page, int activate) 188 char *page, int activate)
189{ 189{
190 int rc; 190 int rc;
@@ -207,26 +207,26 @@ static ssize_t get_best_energy_data(struct sys_device *dev,
207 207
208/* Wrapper functions */ 208/* Wrapper functions */
209 209
210static ssize_t cpu_activate_hint_list_show(struct sysdev_class *class, 210static ssize_t cpu_activate_hint_list_show(struct device *dev,
211 struct sysdev_class_attribute *attr, char *page) 211 struct device_attribute *attr, char *page)
212{ 212{
213 return get_best_energy_list(page, 1); 213 return get_best_energy_list(page, 1);
214} 214}
215 215
216static ssize_t cpu_deactivate_hint_list_show(struct sysdev_class *class, 216static ssize_t cpu_deactivate_hint_list_show(struct device *dev,
217 struct sysdev_class_attribute *attr, char *page) 217 struct device_attribute *attr, char *page)
218{ 218{
219 return get_best_energy_list(page, 0); 219 return get_best_energy_list(page, 0);
220} 220}
221 221
222static ssize_t percpu_activate_hint_show(struct sys_device *dev, 222static ssize_t percpu_activate_hint_show(struct device *dev,
223 struct sysdev_attribute *attr, char *page) 223 struct device_attribute *attr, char *page)
224{ 224{
225 return get_best_energy_data(dev, page, 1); 225 return get_best_energy_data(dev, page, 1);
226} 226}
227 227
228static ssize_t percpu_deactivate_hint_show(struct sys_device *dev, 228static ssize_t percpu_deactivate_hint_show(struct device *dev,
229 struct sysdev_attribute *attr, char *page) 229 struct device_attribute *attr, char *page)
230{ 230{
231 return get_best_energy_data(dev, page, 0); 231 return get_best_energy_data(dev, page, 0);
232} 232}
@@ -241,48 +241,48 @@ static ssize_t percpu_deactivate_hint_show(struct sys_device *dev,
241 * Per-cpu value of the hint 241 * Per-cpu value of the hint
242 */ 242 */
243 243
244struct sysdev_class_attribute attr_cpu_activate_hint_list = 244struct device_attribute attr_cpu_activate_hint_list =
245 _SYSDEV_CLASS_ATTR(pseries_activate_hint_list, 0444, 245 __ATTR(pseries_activate_hint_list, 0444,
246 cpu_activate_hint_list_show, NULL); 246 cpu_activate_hint_list_show, NULL);
247 247
248struct sysdev_class_attribute attr_cpu_deactivate_hint_list = 248struct device_attribute attr_cpu_deactivate_hint_list =
249 _SYSDEV_CLASS_ATTR(pseries_deactivate_hint_list, 0444, 249 __ATTR(pseries_deactivate_hint_list, 0444,
250 cpu_deactivate_hint_list_show, NULL); 250 cpu_deactivate_hint_list_show, NULL);
251 251
252struct sysdev_attribute attr_percpu_activate_hint = 252struct device_attribute attr_percpu_activate_hint =
253 _SYSDEV_ATTR(pseries_activate_hint, 0444, 253 __ATTR(pseries_activate_hint, 0444,
254 percpu_activate_hint_show, NULL); 254 percpu_activate_hint_show, NULL);
255 255
256struct sysdev_attribute attr_percpu_deactivate_hint = 256struct device_attribute attr_percpu_deactivate_hint =
257 _SYSDEV_ATTR(pseries_deactivate_hint, 0444, 257 __ATTR(pseries_deactivate_hint, 0444,
258 percpu_deactivate_hint_show, NULL); 258 percpu_deactivate_hint_show, NULL);
259 259
260static int __init pseries_energy_init(void) 260static int __init pseries_energy_init(void)
261{ 261{
262 int cpu, err; 262 int cpu, err;
263 struct sys_device *cpu_sys_dev; 263 struct device *cpu_dev;
264 264
265 if (!check_for_h_best_energy()) { 265 if (!check_for_h_best_energy()) {
266 printk(KERN_INFO "Hypercall H_BEST_ENERGY not supported\n"); 266 printk(KERN_INFO "Hypercall H_BEST_ENERGY not supported\n");
267 return 0; 267 return 0;
268 } 268 }
269 /* Create the sysfs files */ 269 /* Create the sysfs files */
270 err = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 270 err = device_create_file(cpu_subsys.dev_root,
271 &attr_cpu_activate_hint_list.attr); 271 &attr_cpu_activate_hint_list);
272 if (!err) 272 if (!err)
273 err = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 273 err = device_create_file(cpu_subsys.dev_root,
274 &attr_cpu_deactivate_hint_list.attr); 274 &attr_cpu_deactivate_hint_list);
275 275
276 if (err) 276 if (err)
277 return err; 277 return err;
278 for_each_possible_cpu(cpu) { 278 for_each_possible_cpu(cpu) {
279 cpu_sys_dev = get_cpu_sysdev(cpu); 279 cpu_dev = get_cpu_device(cpu);
280 err = sysfs_create_file(&cpu_sys_dev->kobj, 280 err = device_create_file(cpu_dev,
281 &attr_percpu_activate_hint.attr); 281 &attr_percpu_activate_hint);
282 if (err) 282 if (err)
283 break; 283 break;
284 err = sysfs_create_file(&cpu_sys_dev->kobj, 284 err = device_create_file(cpu_dev,
285 &attr_percpu_deactivate_hint.attr); 285 &attr_percpu_deactivate_hint);
286 if (err) 286 if (err)
287 break; 287 break;
288 } 288 }
@@ -298,23 +298,20 @@ static int __init pseries_energy_init(void)
298static void __exit pseries_energy_cleanup(void) 298static void __exit pseries_energy_cleanup(void)
299{ 299{
300 int cpu; 300 int cpu;
301 struct sys_device *cpu_sys_dev; 301 struct device *cpu_dev;
302 302
303 if (!sysfs_entries) 303 if (!sysfs_entries)
304 return; 304 return;
305 305
306 /* Remove the sysfs files */ 306 /* Remove the sysfs files */
307 sysfs_remove_file(&cpu_sysdev_class.kset.kobj, 307 device_remove_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list);
308 &attr_cpu_activate_hint_list.attr); 308 device_remove_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list);
309
310 sysfs_remove_file(&cpu_sysdev_class.kset.kobj,
311 &attr_cpu_deactivate_hint_list.attr);
312 309
313 for_each_possible_cpu(cpu) { 310 for_each_possible_cpu(cpu) {
314 cpu_sys_dev = get_cpu_sysdev(cpu); 311 cpu_dev = get_cpu_device(cpu);
315 sysfs_remove_file(&cpu_sys_dev->kobj, 312 sysfs_remove_file(&cpu_dev->kobj,
316 &attr_percpu_activate_hint.attr); 313 &attr_percpu_activate_hint.attr);
317 sysfs_remove_file(&cpu_sys_dev->kobj, 314 sysfs_remove_file(&cpu_dev->kobj,
318 &attr_percpu_deactivate_hint.attr); 315 &attr_percpu_deactivate_hint.attr);
319 } 316 }
320} 317}
diff --git a/arch/powerpc/sysdev/ppc4xx_cpm.c b/arch/powerpc/sysdev/ppc4xx_cpm.c
index 73b86cc5ea7..82e2cfe35c6 100644
--- a/arch/powerpc/sysdev/ppc4xx_cpm.c
+++ b/arch/powerpc/sysdev/ppc4xx_cpm.c
@@ -179,12 +179,12 @@ static struct kobj_attribute cpm_idle_attr =
179 179
180static void cpm_idle_config_sysfs(void) 180static void cpm_idle_config_sysfs(void)
181{ 181{
182 struct sys_device *sys_dev; 182 struct device *dev;
183 unsigned long ret; 183 unsigned long ret;
184 184
185 sys_dev = get_cpu_sysdev(0); 185 dev = get_cpu_device(0);
186 186
187 ret = sysfs_create_file(&sys_dev->kobj, 187 ret = sysfs_create_file(&dev->kobj,
188 &cpm_idle_attr.attr); 188 &cpm_idle_attr.attr);
189 if (ret) 189 if (ret)
190 printk(KERN_WARNING 190 printk(KERN_WARNING
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 3ea872890da..66cca03c028 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -831,8 +831,8 @@ int setup_profiling_timer(unsigned int multiplier)
831} 831}
832 832
833#ifdef CONFIG_HOTPLUG_CPU 833#ifdef CONFIG_HOTPLUG_CPU
834static ssize_t cpu_configure_show(struct sys_device *dev, 834static ssize_t cpu_configure_show(struct device *dev,
835 struct sysdev_attribute *attr, char *buf) 835 struct device_attribute *attr, char *buf)
836{ 836{
837 ssize_t count; 837 ssize_t count;
838 838
@@ -842,8 +842,8 @@ static ssize_t cpu_configure_show(struct sys_device *dev,
842 return count; 842 return count;
843} 843}
844 844
845static ssize_t cpu_configure_store(struct sys_device *dev, 845static ssize_t cpu_configure_store(struct device *dev,
846 struct sysdev_attribute *attr, 846 struct device_attribute *attr,
847 const char *buf, size_t count) 847 const char *buf, size_t count)
848{ 848{
849 int cpu = dev->id; 849 int cpu = dev->id;
@@ -889,11 +889,11 @@ out:
889 put_online_cpus(); 889 put_online_cpus();
890 return rc ? rc : count; 890 return rc ? rc : count;
891} 891}
892static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store); 892static DEVICE_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
893#endif /* CONFIG_HOTPLUG_CPU */ 893#endif /* CONFIG_HOTPLUG_CPU */
894 894
895static ssize_t cpu_polarization_show(struct sys_device *dev, 895static ssize_t cpu_polarization_show(struct device *dev,
896 struct sysdev_attribute *attr, char *buf) 896 struct device_attribute *attr, char *buf)
897{ 897{
898 int cpu = dev->id; 898 int cpu = dev->id;
899 ssize_t count; 899 ssize_t count;
@@ -919,22 +919,22 @@ static ssize_t cpu_polarization_show(struct sys_device *dev,
919 mutex_unlock(&smp_cpu_state_mutex); 919 mutex_unlock(&smp_cpu_state_mutex);
920 return count; 920 return count;
921} 921}
922static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL); 922static DEVICE_ATTR(polarization, 0444, cpu_polarization_show, NULL);
923 923
924static ssize_t show_cpu_address(struct sys_device *dev, 924static ssize_t show_cpu_address(struct device *dev,
925 struct sysdev_attribute *attr, char *buf) 925 struct device_attribute *attr, char *buf)
926{ 926{
927 return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]); 927 return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]);
928} 928}
929static SYSDEV_ATTR(address, 0444, show_cpu_address, NULL); 929static DEVICE_ATTR(address, 0444, show_cpu_address, NULL);
930 930
931 931
932static struct attribute *cpu_common_attrs[] = { 932static struct attribute *cpu_common_attrs[] = {
933#ifdef CONFIG_HOTPLUG_CPU 933#ifdef CONFIG_HOTPLUG_CPU
934 &attr_configure.attr, 934 &dev_attr_configure.attr,
935#endif 935#endif
936 &attr_address.attr, 936 &dev_attr_address.attr,
937 &attr_polarization.attr, 937 &dev_attr_polarization.attr,
938 NULL, 938 NULL,
939}; 939};
940 940
@@ -942,8 +942,8 @@ static struct attribute_group cpu_common_attr_group = {
942 .attrs = cpu_common_attrs, 942 .attrs = cpu_common_attrs,
943}; 943};
944 944
945static ssize_t show_capability(struct sys_device *dev, 945static ssize_t show_capability(struct device *dev,
946 struct sysdev_attribute *attr, char *buf) 946 struct device_attribute *attr, char *buf)
947{ 947{
948 unsigned int capability; 948 unsigned int capability;
949 int rc; 949 int rc;
@@ -953,10 +953,10 @@ static ssize_t show_capability(struct sys_device *dev,
953 return rc; 953 return rc;
954 return sprintf(buf, "%u\n", capability); 954 return sprintf(buf, "%u\n", capability);
955} 955}
956static SYSDEV_ATTR(capability, 0444, show_capability, NULL); 956static DEVICE_ATTR(capability, 0444, show_capability, NULL);
957 957
958static ssize_t show_idle_count(struct sys_device *dev, 958static ssize_t show_idle_count(struct device *dev,
959 struct sysdev_attribute *attr, char *buf) 959 struct device_attribute *attr, char *buf)
960{ 960{
961 struct s390_idle_data *idle; 961 struct s390_idle_data *idle;
962 unsigned long long idle_count; 962 unsigned long long idle_count;
@@ -976,10 +976,10 @@ repeat:
976 goto repeat; 976 goto repeat;
977 return sprintf(buf, "%llu\n", idle_count); 977 return sprintf(buf, "%llu\n", idle_count);
978} 978}
979static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL); 979static DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
980 980
981static ssize_t show_idle_time(struct sys_device *dev, 981static ssize_t show_idle_time(struct device *dev,
982 struct sysdev_attribute *attr, char *buf) 982 struct device_attribute *attr, char *buf)
983{ 983{
984 struct s390_idle_data *idle; 984 struct s390_idle_data *idle;
985 unsigned long long now, idle_time, idle_enter; 985 unsigned long long now, idle_time, idle_enter;
@@ -1001,12 +1001,12 @@ repeat:
1001 goto repeat; 1001 goto repeat;
1002 return sprintf(buf, "%llu\n", idle_time >> 12); 1002 return sprintf(buf, "%llu\n", idle_time >> 12);
1003} 1003}
1004static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL); 1004static DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
1005 1005
1006static struct attribute *cpu_online_attrs[] = { 1006static struct attribute *cpu_online_attrs[] = {
1007 &attr_capability.attr, 1007 &dev_attr_capability.attr,
1008 &attr_idle_count.attr, 1008 &dev_attr_idle_count.attr,
1009 &attr_idle_time_us.attr, 1009 &dev_attr_idle_time_us.attr,
1010 NULL, 1010 NULL,
1011}; 1011};
1012 1012
@@ -1019,7 +1019,7 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
1019{ 1019{
1020 unsigned int cpu = (unsigned int)(long)hcpu; 1020 unsigned int cpu = (unsigned int)(long)hcpu;
1021 struct cpu *c = &per_cpu(cpu_devices, cpu); 1021 struct cpu *c = &per_cpu(cpu_devices, cpu);
1022 struct sys_device *s = &c->sysdev; 1022 struct device *s = &c->dev;
1023 struct s390_idle_data *idle; 1023 struct s390_idle_data *idle;
1024 int err = 0; 1024 int err = 0;
1025 1025
@@ -1045,7 +1045,7 @@ static struct notifier_block __cpuinitdata smp_cpu_nb = {
1045static int __devinit smp_add_present_cpu(int cpu) 1045static int __devinit smp_add_present_cpu(int cpu)
1046{ 1046{
1047 struct cpu *c = &per_cpu(cpu_devices, cpu); 1047 struct cpu *c = &per_cpu(cpu_devices, cpu);
1048 struct sys_device *s = &c->sysdev; 1048 struct device *s = &c->dev;
1049 int rc; 1049 int rc;
1050 1050
1051 c->hotpluggable = 1; 1051 c->hotpluggable = 1;
@@ -1098,8 +1098,8 @@ out:
1098 return rc; 1098 return rc;
1099} 1099}
1100 1100
1101static ssize_t __ref rescan_store(struct sysdev_class *class, 1101static ssize_t __ref rescan_store(struct device *dev,
1102 struct sysdev_class_attribute *attr, 1102 struct device_attribute *attr,
1103 const char *buf, 1103 const char *buf,
1104 size_t count) 1104 size_t count)
1105{ 1105{
@@ -1108,11 +1108,11 @@ static ssize_t __ref rescan_store(struct sysdev_class *class,
1108 rc = smp_rescan_cpus(); 1108 rc = smp_rescan_cpus();
1109 return rc ? rc : count; 1109 return rc ? rc : count;
1110} 1110}
1111static SYSDEV_CLASS_ATTR(rescan, 0200, NULL, rescan_store); 1111static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
1112#endif /* CONFIG_HOTPLUG_CPU */ 1112#endif /* CONFIG_HOTPLUG_CPU */
1113 1113
1114static ssize_t dispatching_show(struct sysdev_class *class, 1114static ssize_t dispatching_show(struct device *dev,
1115 struct sysdev_class_attribute *attr, 1115 struct device_attribute *attr,
1116 char *buf) 1116 char *buf)
1117{ 1117{
1118 ssize_t count; 1118 ssize_t count;
@@ -1123,8 +1123,8 @@ static ssize_t dispatching_show(struct sysdev_class *class,
1123 return count; 1123 return count;
1124} 1124}
1125 1125
1126static ssize_t dispatching_store(struct sysdev_class *dev, 1126static ssize_t dispatching_store(struct device *dev,
1127 struct sysdev_class_attribute *attr, 1127 struct device_attribute *attr,
1128 const char *buf, 1128 const char *buf,
1129 size_t count) 1129 size_t count)
1130{ 1130{
@@ -1148,7 +1148,7 @@ out:
1148 put_online_cpus(); 1148 put_online_cpus();
1149 return rc ? rc : count; 1149 return rc ? rc : count;
1150} 1150}
1151static SYSDEV_CLASS_ATTR(dispatching, 0644, dispatching_show, 1151static DEVICE_ATTR(dispatching, 0644, dispatching_show,
1152 dispatching_store); 1152 dispatching_store);
1153 1153
1154static int __init topology_init(void) 1154static int __init topology_init(void)
@@ -1159,11 +1159,11 @@ static int __init topology_init(void)
1159 register_cpu_notifier(&smp_cpu_nb); 1159 register_cpu_notifier(&smp_cpu_nb);
1160 1160
1161#ifdef CONFIG_HOTPLUG_CPU 1161#ifdef CONFIG_HOTPLUG_CPU
1162 rc = sysdev_class_create_file(&cpu_sysdev_class, &attr_rescan); 1162 rc = device_create_file(cpu_subsys.dev_root, &dev_attr_rescan);
1163 if (rc) 1163 if (rc)
1164 return rc; 1164 return rc;
1165#endif 1165#endif
1166 rc = sysdev_class_create_file(&cpu_sysdev_class, &attr_dispatching); 1166 rc = device_create_file(cpu_subsys.dev_root, &dev_attr_dispatching);
1167 if (rc) 1167 if (rc)
1168 return rc; 1168 return rc;
1169 for_each_present_cpu(cpu) { 1169 for_each_present_cpu(cpu) {
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 77b8942b9a1..6dfc524c31a 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -230,7 +230,7 @@ void store_topology(struct sysinfo_15_1_x *info)
230int arch_update_cpu_topology(void) 230int arch_update_cpu_topology(void)
231{ 231{
232 struct sysinfo_15_1_x *info = tl_info; 232 struct sysinfo_15_1_x *info = tl_info;
233 struct sys_device *sysdev; 233 struct device *dev;
234 int cpu; 234 int cpu;
235 235
236 if (!MACHINE_HAS_TOPOLOGY) { 236 if (!MACHINE_HAS_TOPOLOGY) {
@@ -242,8 +242,8 @@ int arch_update_cpu_topology(void)
242 tl_to_cores(info); 242 tl_to_cores(info);
243 update_cpu_core_map(); 243 update_cpu_core_map();
244 for_each_online_cpu(cpu) { 244 for_each_online_cpu(cpu) {
245 sysdev = get_cpu_sysdev(cpu); 245 dev = get_cpu_device(cpu);
246 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); 246 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
247 } 247 }
248 return 1; 248 return 1;
249} 249}
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index f0907995b4c..a8140f0bbf6 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/cpu.h> 14#include <linux/cpu.h>
15#include <linux/bitmap.h> 15#include <linux/bitmap.h>
16#include <linux/sysdev.h> 16#include <linux/device.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
@@ -337,9 +337,9 @@ static struct kobj_type ktype_percpu_entry = {
337 .default_attrs = sq_sysfs_attrs, 337 .default_attrs = sq_sysfs_attrs,
338}; 338};
339 339
340static int __devinit sq_sysdev_add(struct sys_device *sysdev) 340static int __devinit sq_dev_add(struct device *dev)
341{ 341{
342 unsigned int cpu = sysdev->id; 342 unsigned int cpu = dev->id;
343 struct kobject *kobj; 343 struct kobject *kobj;
344 int error; 344 int error;
345 345
@@ -348,25 +348,27 @@ static int __devinit sq_sysdev_add(struct sys_device *sysdev)
348 return -ENOMEM; 348 return -ENOMEM;
349 349
350 kobj = sq_kobject[cpu]; 350 kobj = sq_kobject[cpu];
351 error = kobject_init_and_add(kobj, &ktype_percpu_entry, &sysdev->kobj, 351 error = kobject_init_and_add(kobj, &ktype_percpu_entry, &dev->kobj,
352 "%s", "sq"); 352 "%s", "sq");
353 if (!error) 353 if (!error)
354 kobject_uevent(kobj, KOBJ_ADD); 354 kobject_uevent(kobj, KOBJ_ADD);
355 return error; 355 return error;
356} 356}
357 357
358static int __devexit sq_sysdev_remove(struct sys_device *sysdev) 358static int __devexit sq_dev_remove(struct device *dev)
359{ 359{
360 unsigned int cpu = sysdev->id; 360 unsigned int cpu = dev->id;
361 struct kobject *kobj = sq_kobject[cpu]; 361 struct kobject *kobj = sq_kobject[cpu];
362 362
363 kobject_put(kobj); 363 kobject_put(kobj);
364 return 0; 364 return 0;
365} 365}
366 366
367static struct sysdev_driver sq_sysdev_driver = { 367static struct subsys_interface sq_interface = {
368 .add = sq_sysdev_add, 368 .name = "sq"
369 .remove = __devexit_p(sq_sysdev_remove), 369 .subsys = &cpu_subsys,
370 .add_dev = sq_dev_add,
371 .remove_dev = __devexit_p(sq_dev_remove),
370}; 372};
371 373
372static int __init sq_api_init(void) 374static int __init sq_api_init(void)
@@ -386,7 +388,7 @@ static int __init sq_api_init(void)
386 if (unlikely(!sq_bitmap)) 388 if (unlikely(!sq_bitmap))
387 goto out; 389 goto out;
388 390
389 ret = sysdev_driver_register(&cpu_sysdev_class, &sq_sysdev_driver); 391 ret = subsys_interface_register(&sq_interface);
390 if (unlikely(ret != 0)) 392 if (unlikely(ret != 0))
391 goto out; 393 goto out;
392 394
@@ -401,7 +403,7 @@ out:
401 403
402static void __exit sq_api_exit(void) 404static void __exit sq_api_exit(void)
403{ 405{
404 sysdev_driver_unregister(&cpu_sysdev_class, &sq_sysdev_driver); 406 subsys_interface_unregister(&sq_interface);
405 kfree(sq_bitmap); 407 kfree(sq_bitmap);
406 kmem_cache_destroy(sq_cache); 408 kmem_cache_destroy(sq_cache);
407} 409}
diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
index 7408201d7ef..654e8aad3bb 100644
--- a/arch/sparc/kernel/sysfs.c
+++ b/arch/sparc/kernel/sysfs.c
@@ -3,7 +3,7 @@
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */ 4 */
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/sysdev.h> 6#include <linux/device.h>
7#include <linux/cpu.h> 7#include <linux/cpu.h>
8#include <linux/smp.h> 8#include <linux/smp.h>
9#include <linux/percpu.h> 9#include <linux/percpu.h>
@@ -16,13 +16,13 @@
16static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64))); 16static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64)));
17 17
18#define SHOW_MMUSTAT_ULONG(NAME) \ 18#define SHOW_MMUSTAT_ULONG(NAME) \
19static ssize_t show_##NAME(struct sys_device *dev, \ 19static ssize_t show_##NAME(struct device *dev, \
20 struct sysdev_attribute *attr, char *buf) \ 20 struct device_attribute *attr, char *buf) \
21{ \ 21{ \
22 struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \ 22 struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \
23 return sprintf(buf, "%lu\n", p->NAME); \ 23 return sprintf(buf, "%lu\n", p->NAME); \
24} \ 24} \
25static SYSDEV_ATTR(NAME, 0444, show_##NAME, NULL) 25static DEVICE_ATTR(NAME, 0444, show_##NAME, NULL)
26 26
27SHOW_MMUSTAT_ULONG(immu_tsb_hits_ctx0_8k_tte); 27SHOW_MMUSTAT_ULONG(immu_tsb_hits_ctx0_8k_tte);
28SHOW_MMUSTAT_ULONG(immu_tsb_ticks_ctx0_8k_tte); 28SHOW_MMUSTAT_ULONG(immu_tsb_ticks_ctx0_8k_tte);
@@ -58,38 +58,38 @@ SHOW_MMUSTAT_ULONG(dmmu_tsb_hits_ctxnon0_256mb_tte);
58SHOW_MMUSTAT_ULONG(dmmu_tsb_ticks_ctxnon0_256mb_tte); 58SHOW_MMUSTAT_ULONG(dmmu_tsb_ticks_ctxnon0_256mb_tte);
59 59
60static struct attribute *mmu_stat_attrs[] = { 60static struct attribute *mmu_stat_attrs[] = {
61 &attr_immu_tsb_hits_ctx0_8k_tte.attr, 61 &dev_attr_immu_tsb_hits_ctx0_8k_tte.attr,
62 &attr_immu_tsb_ticks_ctx0_8k_tte.attr, 62 &dev_attr_immu_tsb_ticks_ctx0_8k_tte.attr,
63 &attr_immu_tsb_hits_ctx0_64k_tte.attr, 63 &dev_attr_immu_tsb_hits_ctx0_64k_tte.attr,
64 &attr_immu_tsb_ticks_ctx0_64k_tte.attr, 64 &dev_attr_immu_tsb_ticks_ctx0_64k_tte.attr,
65 &attr_immu_tsb_hits_ctx0_4mb_tte.attr, 65 &dev_attr_immu_tsb_hits_ctx0_4mb_tte.attr,
66 &attr_immu_tsb_ticks_ctx0_4mb_tte.attr, 66 &dev_attr_immu_tsb_ticks_ctx0_4mb_tte.attr,
67 &attr_immu_tsb_hits_ctx0_256mb_tte.attr, 67 &dev_attr_immu_tsb_hits_ctx0_256mb_tte.attr,
68 &attr_immu_tsb_ticks_ctx0_256mb_tte.attr, 68 &dev_attr_immu_tsb_ticks_ctx0_256mb_tte.attr,
69 &attr_immu_tsb_hits_ctxnon0_8k_tte.attr, 69 &dev_attr_immu_tsb_hits_ctxnon0_8k_tte.attr,
70 &attr_immu_tsb_ticks_ctxnon0_8k_tte.attr, 70 &dev_attr_immu_tsb_ticks_ctxnon0_8k_tte.attr,
71 &attr_immu_tsb_hits_ctxnon0_64k_tte.attr, 71 &dev_attr_immu_tsb_hits_ctxnon0_64k_tte.attr,
72 &attr_immu_tsb_ticks_ctxnon0_64k_tte.attr, 72 &dev_attr_immu_tsb_ticks_ctxnon0_64k_tte.attr,
73 &attr_immu_tsb_hits_ctxnon0_4mb_tte.attr, 73 &dev_attr_immu_tsb_hits_ctxnon0_4mb_tte.attr,
74 &attr_immu_tsb_ticks_ctxnon0_4mb_tte.attr, 74 &dev_attr_immu_tsb_ticks_ctxnon0_4mb_tte.attr,
75 &attr_immu_tsb_hits_ctxnon0_256mb_tte.attr, 75 &dev_attr_immu_tsb_hits_ctxnon0_256mb_tte.attr,
76 &attr_immu_tsb_ticks_ctxnon0_256mb_tte.attr, 76 &dev_attr_immu_tsb_ticks_ctxnon0_256mb_tte.attr,
77 &attr_dmmu_tsb_hits_ctx0_8k_tte.attr, 77 &dev_attr_dmmu_tsb_hits_ctx0_8k_tte.attr,
78 &attr_dmmu_tsb_ticks_ctx0_8k_tte.attr, 78 &dev_attr_dmmu_tsb_ticks_ctx0_8k_tte.attr,
79 &attr_dmmu_tsb_hits_ctx0_64k_tte.attr, 79 &dev_attr_dmmu_tsb_hits_ctx0_64k_tte.attr,
80 &attr_dmmu_tsb_ticks_ctx0_64k_tte.attr, 80 &dev_attr_dmmu_tsb_ticks_ctx0_64k_tte.attr,
81 &attr_dmmu_tsb_hits_ctx0_4mb_tte.attr, 81 &dev_attr_dmmu_tsb_hits_ctx0_4mb_tte.attr,
82 &attr_dmmu_tsb_ticks_ctx0_4mb_tte.attr, 82 &dev_attr_dmmu_tsb_ticks_ctx0_4mb_tte.attr,
83 &attr_dmmu_tsb_hits_ctx0_256mb_tte.attr, 83 &dev_attr_dmmu_tsb_hits_ctx0_256mb_tte.attr,
84 &attr_dmmu_tsb_ticks_ctx0_256mb_tte.attr, 84 &dev_attr_dmmu_tsb_ticks_ctx0_256mb_tte.attr,
85 &attr_dmmu_tsb_hits_ctxnon0_8k_tte.attr, 85 &dev_attr_dmmu_tsb_hits_ctxnon0_8k_tte.attr,
86 &attr_dmmu_tsb_ticks_ctxnon0_8k_tte.attr, 86 &dev_attr_dmmu_tsb_ticks_ctxnon0_8k_tte.attr,
87 &attr_dmmu_tsb_hits_ctxnon0_64k_tte.attr, 87 &dev_attr_dmmu_tsb_hits_ctxnon0_64k_tte.attr,
88 &attr_dmmu_tsb_ticks_ctxnon0_64k_tte.attr, 88 &dev_attr_dmmu_tsb_ticks_ctxnon0_64k_tte.attr,
89 &attr_dmmu_tsb_hits_ctxnon0_4mb_tte.attr, 89 &dev_attr_dmmu_tsb_hits_ctxnon0_4mb_tte.attr,
90 &attr_dmmu_tsb_ticks_ctxnon0_4mb_tte.attr, 90 &dev_attr_dmmu_tsb_ticks_ctxnon0_4mb_tte.attr,
91 &attr_dmmu_tsb_hits_ctxnon0_256mb_tte.attr, 91 &dev_attr_dmmu_tsb_hits_ctxnon0_256mb_tte.attr,
92 &attr_dmmu_tsb_ticks_ctxnon0_256mb_tte.attr, 92 &dev_attr_dmmu_tsb_ticks_ctxnon0_256mb_tte.attr,
93 NULL, 93 NULL,
94}; 94};
95 95
@@ -139,15 +139,15 @@ static unsigned long write_mmustat_enable(unsigned long val)
139 return sun4v_mmustat_conf(ra, &orig_ra); 139 return sun4v_mmustat_conf(ra, &orig_ra);
140} 140}
141 141
142static ssize_t show_mmustat_enable(struct sys_device *s, 142static ssize_t show_mmustat_enable(struct device *s,
143 struct sysdev_attribute *attr, char *buf) 143 struct device_attribute *attr, char *buf)
144{ 144{
145 unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0); 145 unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0);
146 return sprintf(buf, "%lx\n", val); 146 return sprintf(buf, "%lx\n", val);
147} 147}
148 148
149static ssize_t store_mmustat_enable(struct sys_device *s, 149static ssize_t store_mmustat_enable(struct device *s,
150 struct sysdev_attribute *attr, const char *buf, 150 struct device_attribute *attr, const char *buf,
151 size_t count) 151 size_t count)
152{ 152{
153 unsigned long val, err; 153 unsigned long val, err;
@@ -163,39 +163,39 @@ static ssize_t store_mmustat_enable(struct sys_device *s,
163 return count; 163 return count;
164} 164}
165 165
166static SYSDEV_ATTR(mmustat_enable, 0644, show_mmustat_enable, store_mmustat_enable); 166static DEVICE_ATTR(mmustat_enable, 0644, show_mmustat_enable, store_mmustat_enable);
167 167
168static int mmu_stats_supported; 168static int mmu_stats_supported;
169 169
170static int register_mmu_stats(struct sys_device *s) 170static int register_mmu_stats(struct device *s)
171{ 171{
172 if (!mmu_stats_supported) 172 if (!mmu_stats_supported)
173 return 0; 173 return 0;
174 sysdev_create_file(s, &attr_mmustat_enable); 174 device_create_file(s, &dev_attr_mmustat_enable);
175 return sysfs_create_group(&s->kobj, &mmu_stat_group); 175 return sysfs_create_group(&s->kobj, &mmu_stat_group);
176} 176}
177 177
178#ifdef CONFIG_HOTPLUG_CPU 178#ifdef CONFIG_HOTPLUG_CPU
179static void unregister_mmu_stats(struct sys_device *s) 179static void unregister_mmu_stats(struct device *s)
180{ 180{
181 if (!mmu_stats_supported) 181 if (!mmu_stats_supported)
182 return; 182 return;
183 sysfs_remove_group(&s->kobj, &mmu_stat_group); 183 sysfs_remove_group(&s->kobj, &mmu_stat_group);
184 sysdev_remove_file(s, &attr_mmustat_enable); 184 device_remove_file(s, &dev_attr_mmustat_enable);
185} 185}
186#endif 186#endif
187 187
188#define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \ 188#define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \
189static ssize_t show_##NAME(struct sys_device *dev, \ 189static ssize_t show_##NAME(struct device *dev, \
190 struct sysdev_attribute *attr, char *buf) \ 190 struct device_attribute *attr, char *buf) \
191{ \ 191{ \
192 cpuinfo_sparc *c = &cpu_data(dev->id); \ 192 cpuinfo_sparc *c = &cpu_data(dev->id); \
193 return sprintf(buf, "%lu\n", c->MEMBER); \ 193 return sprintf(buf, "%lu\n", c->MEMBER); \
194} 194}
195 195
196#define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \ 196#define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \
197static ssize_t show_##NAME(struct sys_device *dev, \ 197static ssize_t show_##NAME(struct device *dev, \
198 struct sysdev_attribute *attr, char *buf) \ 198 struct device_attribute *attr, char *buf) \
199{ \ 199{ \
200 cpuinfo_sparc *c = &cpu_data(dev->id); \ 200 cpuinfo_sparc *c = &cpu_data(dev->id); \
201 return sprintf(buf, "%u\n", c->MEMBER); \ 201 return sprintf(buf, "%u\n", c->MEMBER); \
@@ -209,14 +209,14 @@ SHOW_CPUDATA_UINT_NAME(l1_icache_line_size, icache_line_size);
209SHOW_CPUDATA_UINT_NAME(l2_cache_size, ecache_size); 209SHOW_CPUDATA_UINT_NAME(l2_cache_size, ecache_size);
210SHOW_CPUDATA_UINT_NAME(l2_cache_line_size, ecache_line_size); 210SHOW_CPUDATA_UINT_NAME(l2_cache_line_size, ecache_line_size);
211 211
212static struct sysdev_attribute cpu_core_attrs[] = { 212static struct device_attribute cpu_core_attrs[] = {
213 _SYSDEV_ATTR(clock_tick, 0444, show_clock_tick, NULL), 213 __ATTR(clock_tick, 0444, show_clock_tick, NULL),
214 _SYSDEV_ATTR(l1_dcache_size, 0444, show_l1_dcache_size, NULL), 214 __ATTR(l1_dcache_size, 0444, show_l1_dcache_size, NULL),
215 _SYSDEV_ATTR(l1_dcache_line_size, 0444, show_l1_dcache_line_size, NULL), 215 __ATTR(l1_dcache_line_size, 0444, show_l1_dcache_line_size, NULL),
216 _SYSDEV_ATTR(l1_icache_size, 0444, show_l1_icache_size, NULL), 216 __ATTR(l1_icache_size, 0444, show_l1_icache_size, NULL),
217 _SYSDEV_ATTR(l1_icache_line_size, 0444, show_l1_icache_line_size, NULL), 217 __ATTR(l1_icache_line_size, 0444, show_l1_icache_line_size, NULL),
218 _SYSDEV_ATTR(l2_cache_size, 0444, show_l2_cache_size, NULL), 218 __ATTR(l2_cache_size, 0444, show_l2_cache_size, NULL),
219 _SYSDEV_ATTR(l2_cache_line_size, 0444, show_l2_cache_line_size, NULL), 219 __ATTR(l2_cache_line_size, 0444, show_l2_cache_line_size, NULL),
220}; 220};
221 221
222static DEFINE_PER_CPU(struct cpu, cpu_devices); 222static DEFINE_PER_CPU(struct cpu, cpu_devices);
@@ -224,11 +224,11 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
224static void register_cpu_online(unsigned int cpu) 224static void register_cpu_online(unsigned int cpu)
225{ 225{
226 struct cpu *c = &per_cpu(cpu_devices, cpu); 226 struct cpu *c = &per_cpu(cpu_devices, cpu);
227 struct sys_device *s = &c->sysdev; 227 struct device *s = &c->dev;
228 int i; 228 int i;
229 229
230 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++) 230 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++)
231 sysdev_create_file(s, &cpu_core_attrs[i]); 231 device_create_file(s, &cpu_core_attrs[i]);
232 232
233 register_mmu_stats(s); 233 register_mmu_stats(s);
234} 234}
@@ -237,12 +237,12 @@ static void register_cpu_online(unsigned int cpu)
237static void unregister_cpu_online(unsigned int cpu) 237static void unregister_cpu_online(unsigned int cpu)
238{ 238{
239 struct cpu *c = &per_cpu(cpu_devices, cpu); 239 struct cpu *c = &per_cpu(cpu_devices, cpu);
240 struct sys_device *s = &c->sysdev; 240 struct device *s = &c->dev;
241 int i; 241 int i;
242 242
243 unregister_mmu_stats(s); 243 unregister_mmu_stats(s);
244 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++) 244 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++)
245 sysdev_remove_file(s, &cpu_core_attrs[i]); 245 device_remove_file(s, &cpu_core_attrs[i]);
246} 246}
247#endif 247#endif
248 248
diff --git a/arch/tile/kernel/sysfs.c b/arch/tile/kernel/sysfs.c
index b671a86f451..e7ce2a5161b 100644
--- a/arch/tile/kernel/sysfs.c
+++ b/arch/tile/kernel/sysfs.c
@@ -14,7 +14,7 @@
14 * /sys entry support. 14 * /sys entry support.
15 */ 15 */
16 16
17#include <linux/sysdev.h> 17#include <linux/device.h>
18#include <linux/cpu.h> 18#include <linux/cpu.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/smp.h> 20#include <linux/smp.h>
@@ -31,55 +31,55 @@ static ssize_t get_hv_confstr(char *page, int query)
31 return n; 31 return n;
32} 32}
33 33
34static ssize_t chip_width_show(struct sysdev_class *dev, 34static ssize_t chip_width_show(struct device *dev,
35 struct sysdev_class_attribute *attr, 35 struct device_attribute *attr,
36 char *page) 36 char *page)
37{ 37{
38 return sprintf(page, "%u\n", smp_width); 38 return sprintf(page, "%u\n", smp_width);
39} 39}
40static SYSDEV_CLASS_ATTR(chip_width, 0444, chip_width_show, NULL); 40static DEVICE_ATTR(chip_width, 0444, chip_width_show, NULL);
41 41
42static ssize_t chip_height_show(struct sysdev_class *dev, 42static ssize_t chip_height_show(struct device *dev,
43 struct sysdev_class_attribute *attr, 43 struct device_attribute *attr,
44 char *page) 44 char *page)
45{ 45{
46 return sprintf(page, "%u\n", smp_height); 46 return sprintf(page, "%u\n", smp_height);
47} 47}
48static SYSDEV_CLASS_ATTR(chip_height, 0444, chip_height_show, NULL); 48static DEVICE_ATTR(chip_height, 0444, chip_height_show, NULL);
49 49
50static ssize_t chip_serial_show(struct sysdev_class *dev, 50static ssize_t chip_serial_show(struct device *dev,
51 struct sysdev_class_attribute *attr, 51 struct device_attribute *attr,
52 char *page) 52 char *page)
53{ 53{
54 return get_hv_confstr(page, HV_CONFSTR_CHIP_SERIAL_NUM); 54 return get_hv_confstr(page, HV_CONFSTR_CHIP_SERIAL_NUM);
55} 55}
56static SYSDEV_CLASS_ATTR(chip_serial, 0444, chip_serial_show, NULL); 56static DEVICE_ATTR(chip_serial, 0444, chip_serial_show, NULL);
57 57
58static ssize_t chip_revision_show(struct sysdev_class *dev, 58static ssize_t chip_revision_show(struct device *dev,
59 struct sysdev_class_attribute *attr, 59 struct device_attribute *attr,
60 char *page) 60 char *page)
61{ 61{
62 return get_hv_confstr(page, HV_CONFSTR_CHIP_REV); 62 return get_hv_confstr(page, HV_CONFSTR_CHIP_REV);
63} 63}
64static SYSDEV_CLASS_ATTR(chip_revision, 0444, chip_revision_show, NULL); 64static DEVICE_ATTR(chip_revision, 0444, chip_revision_show, NULL);
65 65
66 66
67static ssize_t type_show(struct sysdev_class *dev, 67static ssize_t type_show(struct device *dev,
68 struct sysdev_class_attribute *attr, 68 struct device_attribute *attr,
69 char *page) 69 char *page)
70{ 70{
71 return sprintf(page, "tilera\n"); 71 return sprintf(page, "tilera\n");
72} 72}
73static SYSDEV_CLASS_ATTR(type, 0444, type_show, NULL); 73static DEVICE_ATTR(type, 0444, type_show, NULL);
74 74
75#define HV_CONF_ATTR(name, conf) \ 75#define HV_CONF_ATTR(name, conf) \
76 static ssize_t name ## _show(struct sysdev_class *dev, \ 76 static ssize_t name ## _show(struct device *dev, \
77 struct sysdev_class_attribute *attr, \ 77 struct device_attribute *attr, \
78 char *page) \ 78 char *page) \
79 { \ 79 { \
80 return get_hv_confstr(page, conf); \ 80 return get_hv_confstr(page, conf); \
81 } \ 81 } \
82 static SYSDEV_CLASS_ATTR(name, 0444, name ## _show, NULL); 82 static DEVICE_ATTR(name, 0444, name ## _show, NULL);
83 83
84HV_CONF_ATTR(version, HV_CONFSTR_HV_SW_VER) 84HV_CONF_ATTR(version, HV_CONFSTR_HV_SW_VER)
85HV_CONF_ATTR(config_version, HV_CONFSTR_HV_CONFIG_VER) 85HV_CONF_ATTR(config_version, HV_CONFSTR_HV_CONFIG_VER)
@@ -95,15 +95,15 @@ HV_CONF_ATTR(mezz_description, HV_CONFSTR_MEZZ_DESC)
95HV_CONF_ATTR(switch_control, HV_CONFSTR_SWITCH_CONTROL) 95HV_CONF_ATTR(switch_control, HV_CONFSTR_SWITCH_CONTROL)
96 96
97static struct attribute *board_attrs[] = { 97static struct attribute *board_attrs[] = {
98 &attr_board_part.attr, 98 &dev_attr_board_part.attr,
99 &attr_board_serial.attr, 99 &dev_attr_board_serial.attr,
100 &attr_board_revision.attr, 100 &dev_attr_board_revision.attr,
101 &attr_board_description.attr, 101 &dev_attr_board_description.attr,
102 &attr_mezz_part.attr, 102 &dev_attr_mezz_part.attr,
103 &attr_mezz_serial.attr, 103 &dev_attr_mezz_serial.attr,
104 &attr_mezz_revision.attr, 104 &dev_attr_mezz_revision.attr,
105 &attr_mezz_description.attr, 105 &dev_attr_mezz_description.attr,
106 &attr_switch_control.attr, 106 &dev_attr_switch_control.attr,
107 NULL 107 NULL
108}; 108};
109 109
@@ -150,12 +150,11 @@ hvconfig_bin_read(struct file *filp, struct kobject *kobj,
150 150
151static int __init create_sysfs_entries(void) 151static int __init create_sysfs_entries(void)
152{ 152{
153 struct sysdev_class *cls = &cpu_sysdev_class;
154 int err = 0; 153 int err = 0;
155 154
156#define create_cpu_attr(name) \ 155#define create_cpu_attr(name) \
157 if (!err) \ 156 if (!err) \
158 err = sysfs_create_file(&cls->kset.kobj, &attr_##name.attr); 157 err = device_create_file(cpu_subsys.dev_root, &dev_attr_##name);
159 create_cpu_attr(chip_width); 158 create_cpu_attr(chip_width);
160 create_cpu_attr(chip_height); 159 create_cpu_attr(chip_height);
161 create_cpu_attr(chip_serial); 160 create_cpu_attr(chip_serial);
@@ -163,7 +162,7 @@ static int __init create_sysfs_entries(void)
163 162
164#define create_hv_attr(name) \ 163#define create_hv_attr(name) \
165 if (!err) \ 164 if (!err) \
166 err = sysfs_create_file(hypervisor_kobj, &attr_##name.attr); 165 err = sysfs_create_file(hypervisor_kobj, &dev_attr_##name);
167 create_hv_attr(type); 166 create_hv_attr(type);
168 create_hv_attr(version); 167 create_hv_attr(version);
169 create_hv_attr(config_version); 168 create_hv_attr(config_version);
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index c9321f34e55..0b05fb49c56 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -149,7 +149,7 @@ static inline void enable_p5_mce(void) {}
149 149
150void mce_setup(struct mce *m); 150void mce_setup(struct mce *m);
151void mce_log(struct mce *m); 151void mce_log(struct mce *m);
152DECLARE_PER_CPU(struct sys_device, mce_sysdev); 152DECLARE_PER_CPU(struct device, mce_device);
153 153
154/* 154/*
155 * Maximum banks number. 155 * Maximum banks number.
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index a3b0811693c..6b45e5e7a90 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -844,8 +844,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
844 844
845#include <linux/kobject.h> 845#include <linux/kobject.h>
846#include <linux/sysfs.h> 846#include <linux/sysfs.h>
847 847#include <linux/cpu.h>
848extern struct sysdev_class cpu_sysdev_class; /* from drivers/base/cpu.c */
849 848
850/* pointer to kobject for cpuX/cache */ 849/* pointer to kobject for cpuX/cache */
851static DEFINE_PER_CPU(struct kobject *, ici_cache_kobject); 850static DEFINE_PER_CPU(struct kobject *, ici_cache_kobject);
@@ -1073,9 +1072,9 @@ err_out:
1073static DECLARE_BITMAP(cache_dev_map, NR_CPUS); 1072static DECLARE_BITMAP(cache_dev_map, NR_CPUS);
1074 1073
1075/* Add/Remove cache interface for CPU device */ 1074/* Add/Remove cache interface for CPU device */
1076static int __cpuinit cache_add_dev(struct sys_device * sys_dev) 1075static int __cpuinit cache_add_dev(struct device *dev)
1077{ 1076{
1078 unsigned int cpu = sys_dev->id; 1077 unsigned int cpu = dev->id;
1079 unsigned long i, j; 1078 unsigned long i, j;
1080 struct _index_kobject *this_object; 1079 struct _index_kobject *this_object;
1081 struct _cpuid4_info *this_leaf; 1080 struct _cpuid4_info *this_leaf;
@@ -1087,7 +1086,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
1087 1086
1088 retval = kobject_init_and_add(per_cpu(ici_cache_kobject, cpu), 1087 retval = kobject_init_and_add(per_cpu(ici_cache_kobject, cpu),
1089 &ktype_percpu_entry, 1088 &ktype_percpu_entry,
1090 &sys_dev->kobj, "%s", "cache"); 1089 &dev->kobj, "%s", "cache");
1091 if (retval < 0) { 1090 if (retval < 0) {
1092 cpuid4_cache_sysfs_exit(cpu); 1091 cpuid4_cache_sysfs_exit(cpu);
1093 return retval; 1092 return retval;
@@ -1124,9 +1123,9 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
1124 return 0; 1123 return 0;
1125} 1124}
1126 1125
1127static void __cpuinit cache_remove_dev(struct sys_device * sys_dev) 1126static void __cpuinit cache_remove_dev(struct device *dev)
1128{ 1127{
1129 unsigned int cpu = sys_dev->id; 1128 unsigned int cpu = dev->id;
1130 unsigned long i; 1129 unsigned long i;
1131 1130
1132 if (per_cpu(ici_cpuid4_info, cpu) == NULL) 1131 if (per_cpu(ici_cpuid4_info, cpu) == NULL)
@@ -1145,17 +1144,17 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
1145 unsigned long action, void *hcpu) 1144 unsigned long action, void *hcpu)
1146{ 1145{
1147 unsigned int cpu = (unsigned long)hcpu; 1146 unsigned int cpu = (unsigned long)hcpu;
1148 struct sys_device *sys_dev; 1147 struct device *dev;
1149 1148
1150 sys_dev = get_cpu_sysdev(cpu); 1149 dev = get_cpu_device(cpu);
1151 switch (action) { 1150 switch (action) {
1152 case CPU_ONLINE: 1151 case CPU_ONLINE:
1153 case CPU_ONLINE_FROZEN: 1152 case CPU_ONLINE_FROZEN:
1154 cache_add_dev(sys_dev); 1153 cache_add_dev(dev);
1155 break; 1154 break;
1156 case CPU_DEAD: 1155 case CPU_DEAD:
1157 case CPU_DEAD_FROZEN: 1156 case CPU_DEAD_FROZEN:
1158 cache_remove_dev(sys_dev); 1157 cache_remove_dev(dev);
1159 break; 1158 break;
1160 } 1159 }
1161 return NOTIFY_OK; 1160 return NOTIFY_OK;
@@ -1174,9 +1173,9 @@ static int __cpuinit cache_sysfs_init(void)
1174 1173
1175 for_each_online_cpu(i) { 1174 for_each_online_cpu(i) {
1176 int err; 1175 int err;
1177 struct sys_device *sys_dev = get_cpu_sysdev(i); 1176 struct device *dev = get_cpu_device(i);
1178 1177
1179 err = cache_add_dev(sys_dev); 1178 err = cache_add_dev(dev);
1180 if (err) 1179 if (err)
1181 return err; 1180 return err;
1182 } 1181 }
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h
index fefcc69ee8b..ed44c8a6585 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-internal.h
+++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h
@@ -1,4 +1,4 @@
1#include <linux/sysdev.h> 1#include <linux/device.h>
2#include <asm/mce.h> 2#include <asm/mce.h>
3 3
4enum severity_level { 4enum severity_level {
@@ -17,7 +17,7 @@ enum severity_level {
17struct mce_bank { 17struct mce_bank {
18 u64 ctl; /* subevents to enable */ 18 u64 ctl; /* subevents to enable */
19 unsigned char init; /* initialise bank? */ 19 unsigned char init; /* initialise bank? */
20 struct sysdev_attribute attr; /* sysdev attribute */ 20 struct device_attribute attr; /* device attribute */
21 char attrname[ATTR_LEN]; /* attribute name */ 21 char attrname[ATTR_LEN]; /* attribute name */
22}; 22};
23 23
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 362056aefeb..0156c6f85d7 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -19,7 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/percpu.h> 20#include <linux/percpu.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/sysdev.h> 22#include <linux/device.h>
23#include <linux/syscore_ops.h> 23#include <linux/syscore_ops.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/ctype.h> 25#include <linux/ctype.h>
@@ -1751,7 +1751,7 @@ static struct syscore_ops mce_syscore_ops = {
1751}; 1751};
1752 1752
1753/* 1753/*
1754 * mce_sysdev: Sysfs support 1754 * mce_device: Sysfs support
1755 */ 1755 */
1756 1756
1757static void mce_cpu_restart(void *data) 1757static void mce_cpu_restart(void *data)
@@ -1787,27 +1787,28 @@ static void mce_enable_ce(void *all)
1787 __mcheck_cpu_init_timer(); 1787 __mcheck_cpu_init_timer();
1788} 1788}
1789 1789
1790static struct sysdev_class mce_sysdev_class = { 1790static struct bus_type mce_subsys = {
1791 .name = "machinecheck", 1791 .name = "machinecheck",
1792 .dev_name = "machinecheck",
1792}; 1793};
1793 1794
1794DEFINE_PER_CPU(struct sys_device, mce_sysdev); 1795DEFINE_PER_CPU(struct device, mce_device);
1795 1796
1796__cpuinitdata 1797__cpuinitdata
1797void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); 1798void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
1798 1799
1799static inline struct mce_bank *attr_to_bank(struct sysdev_attribute *attr) 1800static inline struct mce_bank *attr_to_bank(struct device_attribute *attr)
1800{ 1801{
1801 return container_of(attr, struct mce_bank, attr); 1802 return container_of(attr, struct mce_bank, attr);
1802} 1803}
1803 1804
1804static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr, 1805static ssize_t show_bank(struct device *s, struct device_attribute *attr,
1805 char *buf) 1806 char *buf)
1806{ 1807{
1807 return sprintf(buf, "%llx\n", attr_to_bank(attr)->ctl); 1808 return sprintf(buf, "%llx\n", attr_to_bank(attr)->ctl);
1808} 1809}
1809 1810
1810static ssize_t set_bank(struct sys_device *s, struct sysdev_attribute *attr, 1811static ssize_t set_bank(struct device *s, struct device_attribute *attr,
1811 const char *buf, size_t size) 1812 const char *buf, size_t size)
1812{ 1813{
1813 u64 new; 1814 u64 new;
@@ -1822,14 +1823,14 @@ static ssize_t set_bank(struct sys_device *s, struct sysdev_attribute *attr,
1822} 1823}
1823 1824
1824static ssize_t 1825static ssize_t
1825show_trigger(struct sys_device *s, struct sysdev_attribute *attr, char *buf) 1826show_trigger(struct device *s, struct device_attribute *attr, char *buf)
1826{ 1827{
1827 strcpy(buf, mce_helper); 1828 strcpy(buf, mce_helper);
1828 strcat(buf, "\n"); 1829 strcat(buf, "\n");
1829 return strlen(mce_helper) + 1; 1830 return strlen(mce_helper) + 1;
1830} 1831}
1831 1832
1832static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr, 1833static ssize_t set_trigger(struct device *s, struct device_attribute *attr,
1833 const char *buf, size_t siz) 1834 const char *buf, size_t siz)
1834{ 1835{
1835 char *p; 1836 char *p;
@@ -1844,8 +1845,8 @@ static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
1844 return strlen(mce_helper) + !!p; 1845 return strlen(mce_helper) + !!p;
1845} 1846}
1846 1847
1847static ssize_t set_ignore_ce(struct sys_device *s, 1848static ssize_t set_ignore_ce(struct device *s,
1848 struct sysdev_attribute *attr, 1849 struct device_attribute *attr,
1849 const char *buf, size_t size) 1850 const char *buf, size_t size)
1850{ 1851{
1851 u64 new; 1852 u64 new;
@@ -1868,8 +1869,8 @@ static ssize_t set_ignore_ce(struct sys_device *s,
1868 return size; 1869 return size;
1869} 1870}
1870 1871
1871static ssize_t set_cmci_disabled(struct sys_device *s, 1872static ssize_t set_cmci_disabled(struct device *s,
1872 struct sysdev_attribute *attr, 1873 struct device_attribute *attr,
1873 const char *buf, size_t size) 1874 const char *buf, size_t size)
1874{ 1875{
1875 u64 new; 1876 u64 new;
@@ -1891,108 +1892,107 @@ static ssize_t set_cmci_disabled(struct sys_device *s,
1891 return size; 1892 return size;
1892} 1893}
1893 1894
1894static ssize_t store_int_with_restart(struct sys_device *s, 1895static ssize_t store_int_with_restart(struct device *s,
1895 struct sysdev_attribute *attr, 1896 struct device_attribute *attr,
1896 const char *buf, size_t size) 1897 const char *buf, size_t size)
1897{ 1898{
1898 ssize_t ret = sysdev_store_int(s, attr, buf, size); 1899 ssize_t ret = device_store_int(s, attr, buf, size);
1899 mce_restart(); 1900 mce_restart();
1900 return ret; 1901 return ret;
1901} 1902}
1902 1903
1903static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger); 1904static DEVICE_ATTR(trigger, 0644, show_trigger, set_trigger);
1904static SYSDEV_INT_ATTR(tolerant, 0644, tolerant); 1905static DEVICE_INT_ATTR(tolerant, 0644, tolerant);
1905static SYSDEV_INT_ATTR(monarch_timeout, 0644, monarch_timeout); 1906static DEVICE_INT_ATTR(monarch_timeout, 0644, monarch_timeout);
1906static SYSDEV_INT_ATTR(dont_log_ce, 0644, mce_dont_log_ce); 1907static DEVICE_INT_ATTR(dont_log_ce, 0644, mce_dont_log_ce);
1907 1908
1908static struct sysdev_ext_attribute attr_check_interval = { 1909static struct dev_ext_attribute dev_attr_check_interval = {
1909 _SYSDEV_ATTR(check_interval, 0644, sysdev_show_int, 1910 __ATTR(check_interval, 0644, device_show_int, store_int_with_restart),
1910 store_int_with_restart),
1911 &check_interval 1911 &check_interval
1912}; 1912};
1913 1913
1914static struct sysdev_ext_attribute attr_ignore_ce = { 1914static struct dev_ext_attribute dev_attr_ignore_ce = {
1915 _SYSDEV_ATTR(ignore_ce, 0644, sysdev_show_int, set_ignore_ce), 1915 __ATTR(ignore_ce, 0644, device_show_int, set_ignore_ce),
1916 &mce_ignore_ce 1916 &mce_ignore_ce
1917}; 1917};
1918 1918
1919static struct sysdev_ext_attribute attr_cmci_disabled = { 1919static struct dev_ext_attribute dev_attr_cmci_disabled = {
1920 _SYSDEV_ATTR(cmci_disabled, 0644, sysdev_show_int, set_cmci_disabled), 1920 __ATTR(cmci_disabled, 0644, device_show_int, set_cmci_disabled),
1921 &mce_cmci_disabled 1921 &mce_cmci_disabled
1922}; 1922};
1923 1923
1924static struct sysdev_attribute *mce_sysdev_attrs[] = { 1924static struct device_attribute *mce_device_attrs[] = {
1925 &attr_tolerant.attr, 1925 &dev_attr_tolerant.attr,
1926 &attr_check_interval.attr, 1926 &dev_attr_check_interval.attr,
1927 &attr_trigger, 1927 &dev_attr_trigger,
1928 &attr_monarch_timeout.attr, 1928 &dev_attr_monarch_timeout.attr,
1929 &attr_dont_log_ce.attr, 1929 &dev_attr_dont_log_ce.attr,
1930 &attr_ignore_ce.attr, 1930 &dev_attr_ignore_ce.attr,
1931 &attr_cmci_disabled.attr, 1931 &dev_attr_cmci_disabled.attr,
1932 NULL 1932 NULL
1933}; 1933};
1934 1934
1935static cpumask_var_t mce_sysdev_initialized; 1935static cpumask_var_t mce_device_initialized;
1936 1936
1937/* Per cpu sysdev init. All of the cpus still share the same ctrl bank: */ 1937/* Per cpu device init. All of the cpus still share the same ctrl bank: */
1938static __cpuinit int mce_sysdev_create(unsigned int cpu) 1938static __cpuinit int mce_device_create(unsigned int cpu)
1939{ 1939{
1940 struct sys_device *sysdev = &per_cpu(mce_sysdev, cpu); 1940 struct device *dev = &per_cpu(mce_device, cpu);
1941 int err; 1941 int err;
1942 int i, j; 1942 int i, j;
1943 1943
1944 if (!mce_available(&boot_cpu_data)) 1944 if (!mce_available(&boot_cpu_data))
1945 return -EIO; 1945 return -EIO;
1946 1946
1947 memset(&sysdev->kobj, 0, sizeof(struct kobject)); 1947 memset(&dev->kobj, 0, sizeof(struct kobject));
1948 sysdev->id = cpu; 1948 dev->id = cpu;
1949 sysdev->cls = &mce_sysdev_class; 1949 dev->bus = &mce_subsys;
1950 1950
1951 err = sysdev_register(sysdev); 1951 err = device_register(dev);
1952 if (err) 1952 if (err)
1953 return err; 1953 return err;
1954 1954
1955 for (i = 0; mce_sysdev_attrs[i]; i++) { 1955 for (i = 0; mce_device_attrs[i]; i++) {
1956 err = sysdev_create_file(sysdev, mce_sysdev_attrs[i]); 1956 err = device_create_file(dev, mce_device_attrs[i]);
1957 if (err) 1957 if (err)
1958 goto error; 1958 goto error;
1959 } 1959 }
1960 for (j = 0; j < banks; j++) { 1960 for (j = 0; j < banks; j++) {
1961 err = sysdev_create_file(sysdev, &mce_banks[j].attr); 1961 err = device_create_file(dev, &mce_banks[j].attr);
1962 if (err) 1962 if (err)
1963 goto error2; 1963 goto error2;
1964 } 1964 }
1965 cpumask_set_cpu(cpu, mce_sysdev_initialized); 1965 cpumask_set_cpu(cpu, mce_device_initialized);
1966 1966
1967 return 0; 1967 return 0;
1968error2: 1968error2:
1969 while (--j >= 0) 1969 while (--j >= 0)
1970 sysdev_remove_file(sysdev, &mce_banks[j].attr); 1970 device_remove_file(dev, &mce_banks[j].attr);
1971error: 1971error:
1972 while (--i >= 0) 1972 while (--i >= 0)
1973 sysdev_remove_file(sysdev, mce_sysdev_attrs[i]); 1973 device_remove_file(dev, mce_device_attrs[i]);
1974 1974
1975 sysdev_unregister(sysdev); 1975 device_unregister(dev);
1976 1976
1977 return err; 1977 return err;
1978} 1978}
1979 1979
1980static __cpuinit void mce_sysdev_remove(unsigned int cpu) 1980static __cpuinit void mce_device_remove(unsigned int cpu)
1981{ 1981{
1982 struct sys_device *sysdev = &per_cpu(mce_sysdev, cpu); 1982 struct device *dev = &per_cpu(mce_device, cpu);
1983 int i; 1983 int i;
1984 1984
1985 if (!cpumask_test_cpu(cpu, mce_sysdev_initialized)) 1985 if (!cpumask_test_cpu(cpu, mce_device_initialized))
1986 return; 1986 return;
1987 1987
1988 for (i = 0; mce_sysdev_attrs[i]; i++) 1988 for (i = 0; mce_device_attrs[i]; i++)
1989 sysdev_remove_file(sysdev, mce_sysdev_attrs[i]); 1989 device_remove_file(dev, mce_device_attrs[i]);
1990 1990
1991 for (i = 0; i < banks; i++) 1991 for (i = 0; i < banks; i++)
1992 sysdev_remove_file(sysdev, &mce_banks[i].attr); 1992 device_remove_file(dev, &mce_banks[i].attr);
1993 1993
1994 sysdev_unregister(sysdev); 1994 device_unregister(dev);
1995 cpumask_clear_cpu(cpu, mce_sysdev_initialized); 1995 cpumask_clear_cpu(cpu, mce_device_initialized);
1996} 1996}
1997 1997
1998/* Make sure there are no machine checks on offlined CPUs. */ 1998/* Make sure there are no machine checks on offlined CPUs. */
@@ -2042,7 +2042,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
2042 switch (action) { 2042 switch (action) {
2043 case CPU_ONLINE: 2043 case CPU_ONLINE:
2044 case CPU_ONLINE_FROZEN: 2044 case CPU_ONLINE_FROZEN:
2045 mce_sysdev_create(cpu); 2045 mce_device_create(cpu);
2046 if (threshold_cpu_callback) 2046 if (threshold_cpu_callback)
2047 threshold_cpu_callback(action, cpu); 2047 threshold_cpu_callback(action, cpu);
2048 break; 2048 break;
@@ -2050,7 +2050,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
2050 case CPU_DEAD_FROZEN: 2050 case CPU_DEAD_FROZEN:
2051 if (threshold_cpu_callback) 2051 if (threshold_cpu_callback)
2052 threshold_cpu_callback(action, cpu); 2052 threshold_cpu_callback(action, cpu);
2053 mce_sysdev_remove(cpu); 2053 mce_device_remove(cpu);
2054 break; 2054 break;
2055 case CPU_DOWN_PREPARE: 2055 case CPU_DOWN_PREPARE:
2056 case CPU_DOWN_PREPARE_FROZEN: 2056 case CPU_DOWN_PREPARE_FROZEN:
@@ -2084,7 +2084,7 @@ static __init void mce_init_banks(void)
2084 2084
2085 for (i = 0; i < banks; i++) { 2085 for (i = 0; i < banks; i++) {
2086 struct mce_bank *b = &mce_banks[i]; 2086 struct mce_bank *b = &mce_banks[i];
2087 struct sysdev_attribute *a = &b->attr; 2087 struct device_attribute *a = &b->attr;
2088 2088
2089 sysfs_attr_init(&a->attr); 2089 sysfs_attr_init(&a->attr);
2090 a->attr.name = b->attrname; 2090 a->attr.name = b->attrname;
@@ -2104,16 +2104,16 @@ static __init int mcheck_init_device(void)
2104 if (!mce_available(&boot_cpu_data)) 2104 if (!mce_available(&boot_cpu_data))
2105 return -EIO; 2105 return -EIO;
2106 2106
2107 zalloc_cpumask_var(&mce_sysdev_initialized, GFP_KERNEL); 2107 zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL);
2108 2108
2109 mce_init_banks(); 2109 mce_init_banks();
2110 2110
2111 err = sysdev_class_register(&mce_sysdev_class); 2111 err = subsys_system_register(&mce_subsys, NULL);
2112 if (err) 2112 if (err)
2113 return err; 2113 return err;
2114 2114
2115 for_each_online_cpu(i) { 2115 for_each_online_cpu(i) {
2116 err = mce_sysdev_create(i); 2116 err = mce_device_create(i);
2117 if (err) 2117 if (err)
2118 return err; 2118 return err;
2119 } 2119 }
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index f5474218cff..56d2aa1acd5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -17,7 +17,6 @@
17#include <linux/notifier.h> 17#include <linux/notifier.h>
18#include <linux/kobject.h> 18#include <linux/kobject.h>
19#include <linux/percpu.h> 19#include <linux/percpu.h>
20#include <linux/sysdev.h>
21#include <linux/errno.h> 20#include <linux/errno.h>
22#include <linux/sched.h> 21#include <linux/sched.h>
23#include <linux/sysfs.h> 22#include <linux/sysfs.h>
@@ -548,7 +547,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
548 if (!b) 547 if (!b)
549 goto out; 548 goto out;
550 549
551 err = sysfs_create_link(&per_cpu(mce_sysdev, cpu).kobj, 550 err = sysfs_create_link(&per_cpu(mce_device, cpu).kobj,
552 b->kobj, name); 551 b->kobj, name);
553 if (err) 552 if (err)
554 goto out; 553 goto out;
@@ -571,7 +570,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
571 goto out; 570 goto out;
572 } 571 }
573 572
574 b->kobj = kobject_create_and_add(name, &per_cpu(mce_sysdev, cpu).kobj); 573 b->kobj = kobject_create_and_add(name, &per_cpu(mce_device, cpu).kobj);
575 if (!b->kobj) 574 if (!b->kobj)
576 goto out_free; 575 goto out_free;
577 576
@@ -591,7 +590,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
591 if (i == cpu) 590 if (i == cpu)
592 continue; 591 continue;
593 592
594 err = sysfs_create_link(&per_cpu(mce_sysdev, i).kobj, 593 err = sysfs_create_link(&per_cpu(mce_device, i).kobj,
595 b->kobj, name); 594 b->kobj, name);
596 if (err) 595 if (err)
597 goto out; 596 goto out;
@@ -669,7 +668,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
669#ifdef CONFIG_SMP 668#ifdef CONFIG_SMP
670 /* sibling symlink */ 669 /* sibling symlink */
671 if (shared_bank[bank] && b->blocks->cpu != cpu) { 670 if (shared_bank[bank] && b->blocks->cpu != cpu) {
672 sysfs_remove_link(&per_cpu(mce_sysdev, cpu).kobj, name); 671 sysfs_remove_link(&per_cpu(mce_device, cpu).kobj, name);
673 per_cpu(threshold_banks, cpu)[bank] = NULL; 672 per_cpu(threshold_banks, cpu)[bank] = NULL;
674 673
675 return; 674 return;
@@ -681,7 +680,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
681 if (i == cpu) 680 if (i == cpu)
682 continue; 681 continue;
683 682
684 sysfs_remove_link(&per_cpu(mce_sysdev, i).kobj, name); 683 sysfs_remove_link(&per_cpu(mce_device, i).kobj, name);
685 per_cpu(threshold_banks, i)[bank] = NULL; 684 per_cpu(threshold_banks, i)[bank] = NULL;
686 } 685 }
687 686
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 787e06c84ea..59e3f6ed265 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/percpu.h> 20#include <linux/percpu.h>
21#include <linux/export.h> 21#include <linux/export.h>
22#include <linux/sysdev.h>
23#include <linux/types.h> 22#include <linux/types.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/smp.h> 24#include <linux/smp.h>
@@ -69,16 +68,16 @@ static atomic_t therm_throt_en = ATOMIC_INIT(0);
69static u32 lvtthmr_init __read_mostly; 68static u32 lvtthmr_init __read_mostly;
70 69
71#ifdef CONFIG_SYSFS 70#ifdef CONFIG_SYSFS
72#define define_therm_throt_sysdev_one_ro(_name) \ 71#define define_therm_throt_device_one_ro(_name) \
73 static SYSDEV_ATTR(_name, 0444, \ 72 static DEVICE_ATTR(_name, 0444, \
74 therm_throt_sysdev_show_##_name, \ 73 therm_throt_device_show_##_name, \
75 NULL) \ 74 NULL) \
76 75
77#define define_therm_throt_sysdev_show_func(event, name) \ 76#define define_therm_throt_device_show_func(event, name) \
78 \ 77 \
79static ssize_t therm_throt_sysdev_show_##event##_##name( \ 78static ssize_t therm_throt_device_show_##event##_##name( \
80 struct sys_device *dev, \ 79 struct device *dev, \
81 struct sysdev_attribute *attr, \ 80 struct device_attribute *attr, \
82 char *buf) \ 81 char *buf) \
83{ \ 82{ \
84 unsigned int cpu = dev->id; \ 83 unsigned int cpu = dev->id; \
@@ -95,20 +94,20 @@ static ssize_t therm_throt_sysdev_show_##event##_##name( \
95 return ret; \ 94 return ret; \
96} 95}
97 96
98define_therm_throt_sysdev_show_func(core_throttle, count); 97define_therm_throt_device_show_func(core_throttle, count);
99define_therm_throt_sysdev_one_ro(core_throttle_count); 98define_therm_throt_device_one_ro(core_throttle_count);
100 99
101define_therm_throt_sysdev_show_func(core_power_limit, count); 100define_therm_throt_device_show_func(core_power_limit, count);
102define_therm_throt_sysdev_one_ro(core_power_limit_count); 101define_therm_throt_device_one_ro(core_power_limit_count);
103 102
104define_therm_throt_sysdev_show_func(package_throttle, count); 103define_therm_throt_device_show_func(package_throttle, count);
105define_therm_throt_sysdev_one_ro(package_throttle_count); 104define_therm_throt_device_one_ro(package_throttle_count);
106 105
107define_therm_throt_sysdev_show_func(package_power_limit, count); 106define_therm_throt_device_show_func(package_power_limit, count);
108define_therm_throt_sysdev_one_ro(package_power_limit_count); 107define_therm_throt_device_one_ro(package_power_limit_count);
109 108
110static struct attribute *thermal_throttle_attrs[] = { 109static struct attribute *thermal_throttle_attrs[] = {
111 &attr_core_throttle_count.attr, 110 &dev_attr_core_throttle_count.attr,
112 NULL 111 NULL
113}; 112};
114 113
@@ -223,36 +222,36 @@ static int thresh_event_valid(int event)
223 222
224#ifdef CONFIG_SYSFS 223#ifdef CONFIG_SYSFS
225/* Add/Remove thermal_throttle interface for CPU device: */ 224/* Add/Remove thermal_throttle interface for CPU device: */
226static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev, 225static __cpuinit int thermal_throttle_add_dev(struct device *dev,
227 unsigned int cpu) 226 unsigned int cpu)
228{ 227{
229 int err; 228 int err;
230 struct cpuinfo_x86 *c = &cpu_data(cpu); 229 struct cpuinfo_x86 *c = &cpu_data(cpu);
231 230
232 err = sysfs_create_group(&sys_dev->kobj, &thermal_attr_group); 231 err = sysfs_create_group(&dev->kobj, &thermal_attr_group);
233 if (err) 232 if (err)
234 return err; 233 return err;
235 234
236 if (cpu_has(c, X86_FEATURE_PLN)) 235 if (cpu_has(c, X86_FEATURE_PLN))
237 err = sysfs_add_file_to_group(&sys_dev->kobj, 236 err = sysfs_add_file_to_group(&dev->kobj,
238 &attr_core_power_limit_count.attr, 237 &dev_attr_core_power_limit_count.attr,
239 thermal_attr_group.name); 238 thermal_attr_group.name);
240 if (cpu_has(c, X86_FEATURE_PTS)) { 239 if (cpu_has(c, X86_FEATURE_PTS)) {
241 err = sysfs_add_file_to_group(&sys_dev->kobj, 240 err = sysfs_add_file_to_group(&dev->kobj,
242 &attr_package_throttle_count.attr, 241 &dev_attr_package_throttle_count.attr,
243 thermal_attr_group.name); 242 thermal_attr_group.name);
244 if (cpu_has(c, X86_FEATURE_PLN)) 243 if (cpu_has(c, X86_FEATURE_PLN))
245 err = sysfs_add_file_to_group(&sys_dev->kobj, 244 err = sysfs_add_file_to_group(&dev->kobj,
246 &attr_package_power_limit_count.attr, 245 &dev_attr_package_power_limit_count.attr,
247 thermal_attr_group.name); 246 thermal_attr_group.name);
248 } 247 }
249 248
250 return err; 249 return err;
251} 250}
252 251
253static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev) 252static __cpuinit void thermal_throttle_remove_dev(struct device *dev)
254{ 253{
255 sysfs_remove_group(&sys_dev->kobj, &thermal_attr_group); 254 sysfs_remove_group(&dev->kobj, &thermal_attr_group);
256} 255}
257 256
258/* Mutex protecting device creation against CPU hotplug: */ 257/* Mutex protecting device creation against CPU hotplug: */
@@ -265,16 +264,16 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
265 void *hcpu) 264 void *hcpu)
266{ 265{
267 unsigned int cpu = (unsigned long)hcpu; 266 unsigned int cpu = (unsigned long)hcpu;
268 struct sys_device *sys_dev; 267 struct device *dev;
269 int err = 0; 268 int err = 0;
270 269
271 sys_dev = get_cpu_sysdev(cpu); 270 dev = get_cpu_device(cpu);
272 271
273 switch (action) { 272 switch (action) {
274 case CPU_UP_PREPARE: 273 case CPU_UP_PREPARE:
275 case CPU_UP_PREPARE_FROZEN: 274 case CPU_UP_PREPARE_FROZEN:
276 mutex_lock(&therm_cpu_lock); 275 mutex_lock(&therm_cpu_lock);
277 err = thermal_throttle_add_dev(sys_dev, cpu); 276 err = thermal_throttle_add_dev(dev, cpu);
278 mutex_unlock(&therm_cpu_lock); 277 mutex_unlock(&therm_cpu_lock);
279 WARN_ON(err); 278 WARN_ON(err);
280 break; 279 break;
@@ -283,7 +282,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
283 case CPU_DEAD: 282 case CPU_DEAD:
284 case CPU_DEAD_FROZEN: 283 case CPU_DEAD_FROZEN:
285 mutex_lock(&therm_cpu_lock); 284 mutex_lock(&therm_cpu_lock);
286 thermal_throttle_remove_dev(sys_dev); 285 thermal_throttle_remove_dev(dev);
287 mutex_unlock(&therm_cpu_lock); 286 mutex_unlock(&therm_cpu_lock);
288 break; 287 break;
289 } 288 }
@@ -310,7 +309,7 @@ static __init int thermal_throttle_init_device(void)
310#endif 309#endif
311 /* connect live CPUs to sysfs */ 310 /* connect live CPUs to sysfs */
312 for_each_online_cpu(cpu) { 311 for_each_online_cpu(cpu) {
313 err = thermal_throttle_add_dev(get_cpu_sysdev(cpu), cpu); 312 err = thermal_throttle_add_dev(get_cpu_device(cpu), cpu);
314 WARN_ON(err); 313 WARN_ON(err);
315 } 314 }
316#ifdef CONFIG_HOTPLUG_CPU 315#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index f2d2a664e79..cf88f2a1647 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -292,8 +292,8 @@ static int reload_for_cpu(int cpu)
292 return err; 292 return err;
293} 293}
294 294
295static ssize_t reload_store(struct sys_device *dev, 295static ssize_t reload_store(struct device *dev,
296 struct sysdev_attribute *attr, 296 struct device_attribute *attr,
297 const char *buf, size_t size) 297 const char *buf, size_t size)
298{ 298{
299 unsigned long val; 299 unsigned long val;
@@ -318,30 +318,30 @@ static ssize_t reload_store(struct sys_device *dev,
318 return ret; 318 return ret;
319} 319}
320 320
321static ssize_t version_show(struct sys_device *dev, 321static ssize_t version_show(struct device *dev,
322 struct sysdev_attribute *attr, char *buf) 322 struct device_attribute *attr, char *buf)
323{ 323{
324 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 324 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
325 325
326 return sprintf(buf, "0x%x\n", uci->cpu_sig.rev); 326 return sprintf(buf, "0x%x\n", uci->cpu_sig.rev);
327} 327}
328 328
329static ssize_t pf_show(struct sys_device *dev, 329static ssize_t pf_show(struct device *dev,
330 struct sysdev_attribute *attr, char *buf) 330 struct device_attribute *attr, char *buf)
331{ 331{
332 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 332 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
333 333
334 return sprintf(buf, "0x%x\n", uci->cpu_sig.pf); 334 return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
335} 335}
336 336
337static SYSDEV_ATTR(reload, 0200, NULL, reload_store); 337static DEVICE_ATTR(reload, 0200, NULL, reload_store);
338static SYSDEV_ATTR(version, 0400, version_show, NULL); 338static DEVICE_ATTR(version, 0400, version_show, NULL);
339static SYSDEV_ATTR(processor_flags, 0400, pf_show, NULL); 339static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
340 340
341static struct attribute *mc_default_attrs[] = { 341static struct attribute *mc_default_attrs[] = {
342 &attr_reload.attr, 342 &dev_attr_reload.attr,
343 &attr_version.attr, 343 &dev_attr_version.attr,
344 &attr_processor_flags.attr, 344 &dev_attr_processor_flags.attr,
345 NULL 345 NULL
346}; 346};
347 347
@@ -405,43 +405,45 @@ static enum ucode_state microcode_update_cpu(int cpu)
405 return ustate; 405 return ustate;
406} 406}
407 407
408static int mc_sysdev_add(struct sys_device *sys_dev) 408static int mc_device_add(struct device *dev, struct subsys_interface *sif)
409{ 409{
410 int err, cpu = sys_dev->id; 410 int err, cpu = dev->id;
411 411
412 if (!cpu_online(cpu)) 412 if (!cpu_online(cpu))
413 return 0; 413 return 0;
414 414
415 pr_debug("CPU%d added\n", cpu); 415 pr_debug("CPU%d added\n", cpu);
416 416
417 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group); 417 err = sysfs_create_group(&dev->kobj, &mc_attr_group);
418 if (err) 418 if (err)
419 return err; 419 return err;
420 420
421 if (microcode_init_cpu(cpu) == UCODE_ERROR) { 421 if (microcode_init_cpu(cpu) == UCODE_ERROR) {
422 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group); 422 sysfs_remove_group(&dev->kobj, &mc_attr_group);
423 return -EINVAL; 423 return -EINVAL;
424 } 424 }
425 425
426 return err; 426 return err;
427} 427}
428 428
429static int mc_sysdev_remove(struct sys_device *sys_dev) 429static int mc_device_remove(struct device *dev, struct subsys_interface *sif)
430{ 430{
431 int cpu = sys_dev->id; 431 int cpu = dev->id;
432 432
433 if (!cpu_online(cpu)) 433 if (!cpu_online(cpu))
434 return 0; 434 return 0;
435 435
436 pr_debug("CPU%d removed\n", cpu); 436 pr_debug("CPU%d removed\n", cpu);
437 microcode_fini_cpu(cpu); 437 microcode_fini_cpu(cpu);
438 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group); 438 sysfs_remove_group(&dev->kobj, &mc_attr_group);
439 return 0; 439 return 0;
440} 440}
441 441
442static struct sysdev_driver mc_sysdev_driver = { 442static struct subsys_interface mc_cpu_interface = {
443 .add = mc_sysdev_add, 443 .name = "microcode",
444 .remove = mc_sysdev_remove, 444 .subsys = &cpu_subsys,
445 .add_dev = mc_device_add,
446 .remove_dev = mc_device_remove,
445}; 447};
446 448
447/** 449/**
@@ -464,9 +466,9 @@ static __cpuinit int
464mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 466mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
465{ 467{
466 unsigned int cpu = (unsigned long)hcpu; 468 unsigned int cpu = (unsigned long)hcpu;
467 struct sys_device *sys_dev; 469 struct device *dev;
468 470
469 sys_dev = get_cpu_sysdev(cpu); 471 dev = get_cpu_device(cpu);
470 switch (action) { 472 switch (action) {
471 case CPU_ONLINE: 473 case CPU_ONLINE:
472 case CPU_ONLINE_FROZEN: 474 case CPU_ONLINE_FROZEN:
@@ -474,13 +476,13 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
474 case CPU_DOWN_FAILED: 476 case CPU_DOWN_FAILED:
475 case CPU_DOWN_FAILED_FROZEN: 477 case CPU_DOWN_FAILED_FROZEN:
476 pr_debug("CPU%d added\n", cpu); 478 pr_debug("CPU%d added\n", cpu);
477 if (sysfs_create_group(&sys_dev->kobj, &mc_attr_group)) 479 if (sysfs_create_group(&dev->kobj, &mc_attr_group))
478 pr_err("Failed to create group for CPU%d\n", cpu); 480 pr_err("Failed to create group for CPU%d\n", cpu);
479 break; 481 break;
480 case CPU_DOWN_PREPARE: 482 case CPU_DOWN_PREPARE:
481 case CPU_DOWN_PREPARE_FROZEN: 483 case CPU_DOWN_PREPARE_FROZEN:
482 /* Suspend is in progress, only remove the interface */ 484 /* Suspend is in progress, only remove the interface */
483 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group); 485 sysfs_remove_group(&dev->kobj, &mc_attr_group);
484 pr_debug("CPU%d removed\n", cpu); 486 pr_debug("CPU%d removed\n", cpu);
485 break; 487 break;
486 488
@@ -527,7 +529,7 @@ static int __init microcode_init(void)
527 get_online_cpus(); 529 get_online_cpus();
528 mutex_lock(&microcode_mutex); 530 mutex_lock(&microcode_mutex);
529 531
530 error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver); 532 error = subsys_interface_register(&mc_cpu_interface);
531 533
532 mutex_unlock(&microcode_mutex); 534 mutex_unlock(&microcode_mutex);
533 put_online_cpus(); 535 put_online_cpus();
@@ -561,7 +563,7 @@ static void __exit microcode_exit(void)
561 get_online_cpus(); 563 get_online_cpus();
562 mutex_lock(&microcode_mutex); 564 mutex_lock(&microcode_mutex);
563 565
564 sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver); 566 subsys_interface_unregister(&mc_cpu_interface);
565 567
566 mutex_unlock(&microcode_mutex); 568 mutex_unlock(&microcode_mutex);
567 put_online_cpus(); 569 put_online_cpus();
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 9d7bc9f6b6c..20a68ca386d 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 870550d6a4b..3b599abf2b4 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 251acea3d35..5bb0298fbcc 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 793f796c4da..6ce1501c7de 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 f6f37a05a0c..ae989c57cd5 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 987a165ede2..8c2df3499da 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 c5072a91e84..390380a8cfc 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 06ce2680d00..59f4261c753 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 38c3fd8b9d7..7db186685c2 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 1e756e160dc..3fe41fe4851 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 95b909ac2b7..3c03c1060be 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}
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 6cb60fd2ea8..fc3da0d70d6 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -14,7 +14,7 @@
14#ifndef _LINUX_CPU_H_ 14#ifndef _LINUX_CPU_H_
15#define _LINUX_CPU_H_ 15#define _LINUX_CPU_H_
16 16
17#include <linux/sysdev.h> 17#include <linux/device.h>
18#include <linux/node.h> 18#include <linux/node.h>
19#include <linux/compiler.h> 19#include <linux/compiler.h>
20#include <linux/cpumask.h> 20#include <linux/cpumask.h>
@@ -22,19 +22,19 @@
22struct cpu { 22struct cpu {
23 int node_id; /* The node which contains the CPU */ 23 int node_id; /* The node which contains the CPU */
24 int hotpluggable; /* creates sysfs control file if hotpluggable */ 24 int hotpluggable; /* creates sysfs control file if hotpluggable */
25 struct sys_device sysdev; 25 struct device dev;
26}; 26};
27 27
28extern int register_cpu(struct cpu *cpu, int num); 28extern int register_cpu(struct cpu *cpu, int num);
29extern struct sys_device *get_cpu_sysdev(unsigned cpu); 29extern struct device *get_cpu_device(unsigned cpu);
30 30
31extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr); 31extern int cpu_add_dev_attr(struct device_attribute *attr);
32extern void cpu_remove_sysdev_attr(struct sysdev_attribute *attr); 32extern void cpu_remove_dev_attr(struct device_attribute *attr);
33 33
34extern int cpu_add_sysdev_attr_group(struct attribute_group *attrs); 34extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
35extern void cpu_remove_sysdev_attr_group(struct attribute_group *attrs); 35extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
36 36
37extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls); 37extern int sched_create_sysfs_power_savings_entries(struct device *dev);
38 38
39#ifdef CONFIG_HOTPLUG_CPU 39#ifdef CONFIG_HOTPLUG_CPU
40extern void unregister_cpu(struct cpu *cpu); 40extern void unregister_cpu(struct cpu *cpu);
@@ -160,7 +160,7 @@ static inline void cpu_maps_update_done(void)
160} 160}
161 161
162#endif /* CONFIG_SMP */ 162#endif /* CONFIG_SMP */
163extern struct sysdev_class cpu_sysdev_class; 163extern struct bus_type cpu_subsys;
164 164
165#ifdef CONFIG_HOTPLUG_CPU 165#ifdef CONFIG_HOTPLUG_CPU
166/* Stop CPUs going up and down. */ 166/* Stop CPUs going up and down. */
diff --git a/kernel/sched.c b/kernel/sched.c
index 0e9344a71be..53077264644 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7923,54 +7923,52 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt)
7923} 7923}
7924 7924
7925#ifdef CONFIG_SCHED_MC 7925#ifdef CONFIG_SCHED_MC
7926static ssize_t sched_mc_power_savings_show(struct sysdev_class *class, 7926static ssize_t sched_mc_power_savings_show(struct device *dev,
7927 struct sysdev_class_attribute *attr, 7927 struct device_attribute *attr,
7928 char *page) 7928 char *buf)
7929{ 7929{
7930 return sprintf(page, "%u\n", sched_mc_power_savings); 7930 return sprintf(buf, "%u\n", sched_mc_power_savings);
7931} 7931}
7932static ssize_t sched_mc_power_savings_store(struct sysdev_class *class, 7932static ssize_t sched_mc_power_savings_store(struct device *dev,
7933 struct sysdev_class_attribute *attr, 7933 struct device_attribute *attr,
7934 const char *buf, size_t count) 7934 const char *buf, size_t count)
7935{ 7935{
7936 return sched_power_savings_store(buf, count, 0); 7936 return sched_power_savings_store(buf, count, 0);
7937} 7937}
7938static SYSDEV_CLASS_ATTR(sched_mc_power_savings, 0644, 7938static DEVICE_ATTR(sched_mc_power_savings, 0644,
7939 sched_mc_power_savings_show, 7939 sched_mc_power_savings_show,
7940 sched_mc_power_savings_store); 7940 sched_mc_power_savings_store);
7941#endif 7941#endif
7942 7942
7943#ifdef CONFIG_SCHED_SMT 7943#ifdef CONFIG_SCHED_SMT
7944static ssize_t sched_smt_power_savings_show(struct sysdev_class *dev, 7944static ssize_t sched_smt_power_savings_show(struct device *dev,
7945 struct sysdev_class_attribute *attr, 7945 struct device_attribute *attr,
7946 char *page) 7946 char *buf)
7947{ 7947{
7948 return sprintf(page, "%u\n", sched_smt_power_savings); 7948 return sprintf(buf, "%u\n", sched_smt_power_savings);
7949} 7949}
7950static ssize_t sched_smt_power_savings_store(struct sysdev_class *dev, 7950static ssize_t sched_smt_power_savings_store(struct device *dev,
7951 struct sysdev_class_attribute *attr, 7951 struct device_attribute *attr,
7952 const char *buf, size_t count) 7952 const char *buf, size_t count)
7953{ 7953{
7954 return sched_power_savings_store(buf, count, 1); 7954 return sched_power_savings_store(buf, count, 1);
7955} 7955}
7956static SYSDEV_CLASS_ATTR(sched_smt_power_savings, 0644, 7956static DEVICE_ATTR(sched_smt_power_savings, 0644,
7957 sched_smt_power_savings_show, 7957 sched_smt_power_savings_show,
7958 sched_smt_power_savings_store); 7958 sched_smt_power_savings_store);
7959#endif 7959#endif
7960 7960
7961int __init sched_create_sysfs_power_savings_entries(struct sysdev_class *cls) 7961int __init sched_create_sysfs_power_savings_entries(struct device *dev)
7962{ 7962{
7963 int err = 0; 7963 int err = 0;
7964 7964
7965#ifdef CONFIG_SCHED_SMT 7965#ifdef CONFIG_SCHED_SMT
7966 if (smt_capable()) 7966 if (smt_capable())
7967 err = sysfs_create_file(&cls->kset.kobj, 7967 err = device_create_file(dev, &dev_attr_sched_smt_power_savings);
7968 &attr_sched_smt_power_savings.attr);
7969#endif 7968#endif
7970#ifdef CONFIG_SCHED_MC 7969#ifdef CONFIG_SCHED_MC
7971 if (!err && mc_capable()) 7970 if (!err && mc_capable())
7972 err = sysfs_create_file(&cls->kset.kobj, 7971 err = device_create_file(dev, &dev_attr_sched_mc_power_savings);
7973 &attr_sched_mc_power_savings.attr);
7974#endif 7972#endif
7975 return err; 7973 return err;
7976} 7974}