Skip to content

Commit 8a25a2f

Browse files
kaysieversgregkh
authored andcommitted
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 <[email protected]> Cc: Hans-Christian Egtvedt <[email protected]> Cc: Tony Luck <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Paul Mundt <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Chris Metcalf <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Tigran Aivazian <[email protected]> Cc: Len Brown <[email protected]> Cc: Zhang Rui <[email protected]> Cc: Dave Jones <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Russell King <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: "Srivatsa S. Bhat" <[email protected]> Signed-off-by: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cb0c05c commit 8a25a2f

File tree

38 files changed

+874
-877
lines changed

38 files changed

+874
-877
lines changed

arch/avr32/kernel/cpu.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* published by the Free Software Foundation.
77
*/
88
#include <linux/init.h>
9-
#include <linux/sysdev.h>
9+
#include <linux/device.h>
1010
#include <linux/seq_file.h>
1111
#include <linux/cpu.h>
1212
#include <linux/module.h>
@@ -26,16 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
2626
* XXX: If/when a SMP-capable implementation of AVR32 will ever be
2727
* made, we must make sure that the code executes on the correct CPU.
2828
*/
29-
static ssize_t show_pc0event(struct sys_device *dev,
30-
struct sysdev_attribute *attr, char *buf)
29+
static ssize_t show_pc0event(struct device *dev,
30+
struct device_attribute *attr, char *buf)
3131
{
3232
unsigned long pccr;
3333

3434
pccr = sysreg_read(PCCR);
3535
return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
3636
}
37-
static ssize_t store_pc0event(struct sys_device *dev,
38-
struct sysdev_attribute *attr, const char *buf,
37+
static ssize_t store_pc0event(struct device *dev,
38+
struct device_attribute *attr, const char *buf,
3939
size_t count)
4040
{
4141
unsigned long val;
@@ -48,16 +48,16 @@ static ssize_t store_pc0event(struct sys_device *dev,
4848
sysreg_write(PCCR, val);
4949
return count;
5050
}
51-
static ssize_t show_pc0count(struct sys_device *dev,
52-
struct sysdev_attribute *attr, char *buf)
51+
static ssize_t show_pc0count(struct device *dev,
52+
struct device_attribute *attr, char *buf)
5353
{
5454
unsigned long pcnt0;
5555

5656
pcnt0 = sysreg_read(PCNT0);
5757
return sprintf(buf, "%lu\n", pcnt0);
5858
}
59-
static ssize_t store_pc0count(struct sys_device *dev,
60-
struct sysdev_attribute *attr,
59+
static ssize_t store_pc0count(struct device *dev,
60+
struct device_attribute *attr,
6161
const char *buf, size_t count)
6262
{
6363
unsigned long val;
@@ -71,16 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev,
7171
return count;
7272
}
7373

74-
static ssize_t show_pc1event(struct sys_device *dev,
75-
struct sysdev_attribute *attr, char *buf)
74+
static ssize_t show_pc1event(struct device *dev,
75+
struct device_attribute *attr, char *buf)
7676
{
7777
unsigned long pccr;
7878

7979
pccr = sysreg_read(PCCR);
8080
return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
8181
}
82-
static ssize_t store_pc1event(struct sys_device *dev,
83-
struct sysdev_attribute *attr, const char *buf,
82+
static ssize_t store_pc1event(struct device *dev,
83+
struct device_attribute *attr, const char *buf,
8484
size_t count)
8585
{
8686
unsigned long val;
@@ -93,16 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev,
9393
sysreg_write(PCCR, val);
9494
return count;
9595
}
96-
static ssize_t show_pc1count(struct sys_device *dev,
97-
struct sysdev_attribute *attr, char *buf)
96+
static ssize_t show_pc1count(struct device *dev,
97+
struct device_attribute *attr, char *buf)
9898
{
9999
unsigned long pcnt1;
100100

101101
pcnt1 = sysreg_read(PCNT1);
102102
return sprintf(buf, "%lu\n", pcnt1);
103103
}
104-
static ssize_t store_pc1count(struct sys_device *dev,
105-
struct sysdev_attribute *attr, const char *buf,
104+
static ssize_t store_pc1count(struct device *dev,
105+
struct device_attribute *attr, const char *buf,
106106
size_t count)
107107
{
108108
unsigned long val;
@@ -116,16 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev,
116116
return count;
117117
}
118118

119-
static ssize_t show_pccycles(struct sys_device *dev,
120-
struct sysdev_attribute *attr, char *buf)
119+
static ssize_t show_pccycles(struct device *dev,
120+
struct device_attribute *attr, char *buf)
121121
{
122122
unsigned long pccnt;
123123

124124
pccnt = sysreg_read(PCCNT);
125125
return sprintf(buf, "%lu\n", pccnt);
126126
}
127-
static ssize_t store_pccycles(struct sys_device *dev,
128-
struct sysdev_attribute *attr, const char *buf,
127+
static ssize_t store_pccycles(struct device *dev,
128+
struct device_attribute *attr, const char *buf,
129129
size_t count)
130130
{
131131
unsigned long val;
@@ -139,16 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev,
139139
return count;
140140
}
141141

142-
static ssize_t show_pcenable(struct sys_device *dev,
143-
struct sysdev_attribute *attr, char *buf)
142+
static ssize_t show_pcenable(struct device *dev,
143+
struct device_attribute *attr, char *buf)
144144
{
145145
unsigned long pccr;
146146

147147
pccr = sysreg_read(PCCR);
148148
return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
149149
}
150-
static ssize_t store_pcenable(struct sys_device *dev,
151-
struct sysdev_attribute *attr, const char *buf,
150+
static ssize_t store_pcenable(struct device *dev,
151+
struct device_attribute *attr, const char *buf,
152152
size_t count)
153153
{
154154
unsigned long pccr, val;
@@ -167,12 +167,12 @@ static ssize_t store_pcenable(struct sys_device *dev,
167167
return count;
168168
}
169169

170-
static SYSDEV_ATTR(pc0event, 0600, show_pc0event, store_pc0event);
171-
static SYSDEV_ATTR(pc0count, 0600, show_pc0count, store_pc0count);
172-
static SYSDEV_ATTR(pc1event, 0600, show_pc1event, store_pc1event);
173-
static SYSDEV_ATTR(pc1count, 0600, show_pc1count, store_pc1count);
174-
static SYSDEV_ATTR(pccycles, 0600, show_pccycles, store_pccycles);
175-
static SYSDEV_ATTR(pcenable, 0600, show_pcenable, store_pcenable);
170+
static DEVICE_ATTR(pc0event, 0600, show_pc0event, store_pc0event);
171+
static DEVICE_ATTR(pc0count, 0600, show_pc0count, store_pc0count);
172+
static DEVICE_ATTR(pc1event, 0600, show_pc1event, store_pc1event);
173+
static DEVICE_ATTR(pc1count, 0600, show_pc1count, store_pc1count);
174+
static DEVICE_ATTR(pccycles, 0600, show_pccycles, store_pccycles);
175+
static DEVICE_ATTR(pcenable, 0600, show_pcenable, store_pcenable);
176176

177177
#endif /* CONFIG_PERFORMANCE_COUNTERS */
178178

@@ -186,12 +186,12 @@ static int __init topology_init(void)
186186
register_cpu(c, cpu);
187187

188188
#ifdef CONFIG_PERFORMANCE_COUNTERS
189-
sysdev_create_file(&c->sysdev, &attr_pc0event);
190-
sysdev_create_file(&c->sysdev, &attr_pc0count);
191-
sysdev_create_file(&c->sysdev, &attr_pc1event);
192-
sysdev_create_file(&c->sysdev, &attr_pc1count);
193-
sysdev_create_file(&c->sysdev, &attr_pccycles);
194-
sysdev_create_file(&c->sysdev, &attr_pcenable);
189+
device_create_file(&c->dev, &dev_attr_pc0event);
190+
device_create_file(&c->dev, &dev_attr_pc0count);
191+
device_create_file(&c->dev, &dev_attr_pc1event);
192+
device_create_file(&c->dev, &dev_attr_pc1count);
193+
device_create_file(&c->dev, &dev_attr_pccycles);
194+
device_create_file(&c->dev, &dev_attr_pcenable);
195195
#endif
196196
}
197197

arch/ia64/kernel/err_inject.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Copyright (C) 2006, Intel Corp. All rights reserved.
2525
*
2626
*/
27-
#include <linux/sysdev.h>
27+
#include <linux/device.h>
2828
#include <linux/init.h>
2929
#include <linux/mm.h>
3030
#include <linux/cpu.h>
@@ -35,10 +35,10 @@
3535
#define ERR_DATA_BUFFER_SIZE 3 // Three 8-byte;
3636

3737
#define define_one_ro(name) \
38-
static SYSDEV_ATTR(name, 0444, show_##name, NULL)
38+
static DEVICE_ATTR(name, 0444, show_##name, NULL)
3939

4040
#define define_one_rw(name) \
41-
static SYSDEV_ATTR(name, 0644, show_##name, store_##name)
41+
static DEVICE_ATTR(name, 0644, show_##name, store_##name)
4242

4343
static u64 call_start[NR_CPUS];
4444
static u64 phys_addr[NR_CPUS];
@@ -55,7 +55,7 @@ static u64 resources[NR_CPUS];
5555

5656
#define show(name) \
5757
static ssize_t \
58-
show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
58+
show_##name(struct device *dev, struct device_attribute *attr, \
5959
char *buf) \
6060
{ \
6161
u32 cpu=dev->id; \
@@ -64,7 +64,7 @@ show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
6464

6565
#define store(name) \
6666
static ssize_t \
67-
store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
67+
store_##name(struct device *dev, struct device_attribute *attr, \
6868
const char *buf, size_t size) \
6969
{ \
7070
unsigned int cpu=dev->id; \
@@ -78,7 +78,7 @@ show(call_start)
7878
* processor. The cpu number in driver is only used for storing data.
7979
*/
8080
static ssize_t
81-
store_call_start(struct sys_device *dev, struct sysdev_attribute *attr,
81+
store_call_start(struct device *dev, struct device_attribute *attr,
8282
const char *buf, size_t size)
8383
{
8484
unsigned int cpu=dev->id;
@@ -127,15 +127,15 @@ show(err_type_info)
127127
store(err_type_info)
128128

129129
static ssize_t
130-
show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
130+
show_virtual_to_phys(struct device *dev, struct device_attribute *attr,
131131
char *buf)
132132
{
133133
unsigned int cpu=dev->id;
134134
return sprintf(buf, "%lx\n", phys_addr[cpu]);
135135
}
136136

137137
static ssize_t
138-
store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
138+
store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
139139
const char *buf, size_t size)
140140
{
141141
unsigned int cpu=dev->id;
@@ -159,8 +159,8 @@ show(err_struct_info)
159159
store(err_struct_info)
160160

161161
static ssize_t
162-
show_err_data_buffer(struct sys_device *dev,
163-
struct sysdev_attribute *attr, char *buf)
162+
show_err_data_buffer(struct device *dev,
163+
struct device_attribute *attr, char *buf)
164164
{
165165
unsigned int cpu=dev->id;
166166

@@ -171,8 +171,8 @@ show_err_data_buffer(struct sys_device *dev,
171171
}
172172

173173
static ssize_t
174-
store_err_data_buffer(struct sys_device *dev,
175-
struct sysdev_attribute *attr,
174+
store_err_data_buffer(struct device *dev,
175+
struct device_attribute *attr,
176176
const char *buf, size_t size)
177177
{
178178
unsigned int cpu=dev->id;
@@ -209,14 +209,14 @@ define_one_ro(capabilities);
209209
define_one_ro(resources);
210210

211211
static struct attribute *default_attrs[] = {
212-
&attr_call_start.attr,
213-
&attr_virtual_to_phys.attr,
214-
&attr_err_type_info.attr,
215-
&attr_err_struct_info.attr,
216-
&attr_err_data_buffer.attr,
217-
&attr_status.attr,
218-
&attr_capabilities.attr,
219-
&attr_resources.attr,
212+
&dev_attr_call_start.attr,
213+
&dev_attr_virtual_to_phys.attr,
214+
&dev_attr_err_type_info.attr,
215+
&dev_attr_err_struct_info.attr,
216+
&dev_attr_err_data_buffer.attr,
217+
&dev_attr_status.attr,
218+
&dev_attr_capabilities.attr,
219+
&dev_attr_resources.attr,
220220
NULL
221221
};
222222

@@ -225,12 +225,12 @@ static struct attribute_group err_inject_attr_group = {
225225
.name = "err_inject"
226226
};
227227
/* Add/Remove err_inject interface for CPU device */
228-
static int __cpuinit err_inject_add_dev(struct sys_device * sys_dev)
228+
static int __cpuinit err_inject_add_dev(struct device * sys_dev)
229229
{
230230
return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group);
231231
}
232232

233-
static int __cpuinit err_inject_remove_dev(struct sys_device * sys_dev)
233+
static int __cpuinit err_inject_remove_dev(struct device * sys_dev)
234234
{
235235
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
236236
return 0;
@@ -239,9 +239,9 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
239239
unsigned long action, void *hcpu)
240240
{
241241
unsigned int cpu = (unsigned long)hcpu;
242-
struct sys_device *sys_dev;
242+
struct device *sys_dev;
243243

244-
sys_dev = get_cpu_sysdev(cpu);
244+
sys_dev = get_cpu_device(cpu);
245245
switch (action) {
246246
case CPU_ONLINE:
247247
case CPU_ONLINE_FROZEN:
@@ -283,13 +283,13 @@ static void __exit
283283
err_inject_exit(void)
284284
{
285285
int i;
286-
struct sys_device *sys_dev;
286+
struct device *sys_dev;
287287

288288
#ifdef ERR_INJ_DEBUG
289289
printk(KERN_INFO "Exit error injection driver.\n");
290290
#endif
291291
for_each_online_cpu(i) {
292-
sys_dev = get_cpu_sysdev(i);
292+
sys_dev = get_cpu_device(i);
293293
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
294294
}
295295
unregister_hotcpu_notifier(&err_inject_cpu_notifier);

arch/ia64/kernel/topology.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static int __cpuinit cpu_cache_sysfs_init(unsigned int cpu)
350350
}
351351

352352
/* Add cache interface for CPU device */
353-
static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
353+
static int __cpuinit cache_add_dev(struct device * sys_dev)
354354
{
355355
unsigned int cpu = sys_dev->id;
356356
unsigned long i, j;
@@ -400,7 +400,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
400400
}
401401

402402
/* Remove cache interface for CPU device */
403-
static int __cpuinit cache_remove_dev(struct sys_device * sys_dev)
403+
static int __cpuinit cache_remove_dev(struct device * sys_dev)
404404
{
405405
unsigned int cpu = sys_dev->id;
406406
unsigned long i;
@@ -428,9 +428,9 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
428428
unsigned long action, void *hcpu)
429429
{
430430
unsigned int cpu = (unsigned long)hcpu;
431-
struct sys_device *sys_dev;
431+
struct device *sys_dev;
432432

433-
sys_dev = get_cpu_sysdev(cpu);
433+
sys_dev = get_cpu_device(cpu);
434434
switch (action) {
435435
case CPU_ONLINE:
436436
case CPU_ONLINE_FROZEN:
@@ -454,7 +454,7 @@ static int __init cache_sysfs_init(void)
454454
int i;
455455

456456
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);
458458
cache_add_dev(sys_dev);
459459
}
460460

0 commit comments

Comments
 (0)