Skip to content

Commit

Permalink
cpu: convert 'cpu' and 'machinecheck' sysdev_class to a regular subsy…
Browse files Browse the repository at this point in the history
…stem

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>
  • Loading branch information
kaysievers authored and gregkh committed Dec 21, 2011
1 parent cb0c05c commit 8a25a2f
Show file tree
Hide file tree
Showing 38 changed files with 874 additions and 877 deletions.
74 changes: 37 additions & 37 deletions arch/avr32/kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/sysdev.h>
#include <linux/device.h>
#include <linux/seq_file.h>
#include <linux/cpu.h>
#include <linux/module.h>
Expand All @@ -26,16 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
* XXX: If/when a SMP-capable implementation of AVR32 will ever be
* made, we must make sure that the code executes on the correct CPU.
*/
static ssize_t show_pc0event(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pc0event(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pccr;

pccr = sysreg_read(PCCR);
return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
}
static ssize_t store_pc0event(struct sys_device *dev,
struct sysdev_attribute *attr, const char *buf,
static ssize_t store_pc0event(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long val;
Expand All @@ -48,16 +48,16 @@ static ssize_t store_pc0event(struct sys_device *dev,
sysreg_write(PCCR, val);
return count;
}
static ssize_t show_pc0count(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pc0count(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pcnt0;

pcnt0 = sysreg_read(PCNT0);
return sprintf(buf, "%lu\n", pcnt0);
}
static ssize_t store_pc0count(struct sys_device *dev,
struct sysdev_attribute *attr,
static ssize_t store_pc0count(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long val;
Expand All @@ -71,16 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev,
return count;
}

static ssize_t show_pc1event(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pc1event(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pccr;

pccr = sysreg_read(PCCR);
return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
}
static ssize_t store_pc1event(struct sys_device *dev,
struct sysdev_attribute *attr, const char *buf,
static ssize_t store_pc1event(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long val;
Expand All @@ -93,16 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev,
sysreg_write(PCCR, val);
return count;
}
static ssize_t show_pc1count(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pc1count(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pcnt1;

pcnt1 = sysreg_read(PCNT1);
return sprintf(buf, "%lu\n", pcnt1);
}
static ssize_t store_pc1count(struct sys_device *dev,
struct sysdev_attribute *attr, const char *buf,
static ssize_t store_pc1count(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long val;
Expand All @@ -116,16 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev,
return count;
}

static ssize_t show_pccycles(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pccycles(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pccnt;

pccnt = sysreg_read(PCCNT);
return sprintf(buf, "%lu\n", pccnt);
}
static ssize_t store_pccycles(struct sys_device *dev,
struct sysdev_attribute *attr, const char *buf,
static ssize_t store_pccycles(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long val;
Expand All @@ -139,16 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev,
return count;
}

static ssize_t show_pcenable(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t show_pcenable(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long pccr;

pccr = sysreg_read(PCCR);
return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
}
static ssize_t store_pcenable(struct sys_device *dev,
struct sysdev_attribute *attr, const char *buf,
static ssize_t store_pcenable(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
unsigned long pccr, val;
Expand All @@ -167,12 +167,12 @@ static ssize_t store_pcenable(struct sys_device *dev,
return count;
}

static SYSDEV_ATTR(pc0event, 0600, show_pc0event, store_pc0event);
static SYSDEV_ATTR(pc0count, 0600, show_pc0count, store_pc0count);
static SYSDEV_ATTR(pc1event, 0600, show_pc1event, store_pc1event);
static SYSDEV_ATTR(pc1count, 0600, show_pc1count, store_pc1count);
static SYSDEV_ATTR(pccycles, 0600, show_pccycles, store_pccycles);
static SYSDEV_ATTR(pcenable, 0600, show_pcenable, store_pcenable);
static DEVICE_ATTR(pc0event, 0600, show_pc0event, store_pc0event);
static DEVICE_ATTR(pc0count, 0600, show_pc0count, store_pc0count);
static DEVICE_ATTR(pc1event, 0600, show_pc1event, store_pc1event);
static DEVICE_ATTR(pc1count, 0600, show_pc1count, store_pc1count);
static DEVICE_ATTR(pccycles, 0600, show_pccycles, store_pccycles);
static DEVICE_ATTR(pcenable, 0600, show_pcenable, store_pcenable);

#endif /* CONFIG_PERFORMANCE_COUNTERS */

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

#ifdef CONFIG_PERFORMANCE_COUNTERS
sysdev_create_file(&c->sysdev, &attr_pc0event);
sysdev_create_file(&c->sysdev, &attr_pc0count);
sysdev_create_file(&c->sysdev, &attr_pc1event);
sysdev_create_file(&c->sysdev, &attr_pc1count);
sysdev_create_file(&c->sysdev, &attr_pccycles);
sysdev_create_file(&c->sysdev, &attr_pcenable);
device_create_file(&c->dev, &dev_attr_pc0event);
device_create_file(&c->dev, &dev_attr_pc0count);
device_create_file(&c->dev, &dev_attr_pc1event);
device_create_file(&c->dev, &dev_attr_pc1count);
device_create_file(&c->dev, &dev_attr_pccycles);
device_create_file(&c->dev, &dev_attr_pcenable);
#endif
}

Expand Down
52 changes: 26 additions & 26 deletions arch/ia64/kernel/err_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Copyright (C) 2006, Intel Corp. All rights reserved.
*
*/
#include <linux/sysdev.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/cpu.h>
Expand All @@ -35,10 +35,10 @@
#define ERR_DATA_BUFFER_SIZE 3 // Three 8-byte;

#define define_one_ro(name) \
static SYSDEV_ATTR(name, 0444, show_##name, NULL)
static DEVICE_ATTR(name, 0444, show_##name, NULL)

#define define_one_rw(name) \
static SYSDEV_ATTR(name, 0644, show_##name, store_##name)
static DEVICE_ATTR(name, 0644, show_##name, store_##name)

static u64 call_start[NR_CPUS];
static u64 phys_addr[NR_CPUS];
Expand All @@ -55,7 +55,7 @@ static u64 resources[NR_CPUS];

#define show(name) \
static ssize_t \
show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
show_##name(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
u32 cpu=dev->id; \
Expand All @@ -64,7 +64,7 @@ show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \

#define store(name) \
static ssize_t \
store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
store_##name(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t size) \
{ \
unsigned int cpu=dev->id; \
Expand All @@ -78,7 +78,7 @@ show(call_start)
* processor. The cpu number in driver is only used for storing data.
*/
static ssize_t
store_call_start(struct sys_device *dev, struct sysdev_attribute *attr,
store_call_start(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
unsigned int cpu=dev->id;
Expand Down Expand Up @@ -127,15 +127,15 @@ show(err_type_info)
store(err_type_info)

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

static ssize_t
store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
unsigned int cpu=dev->id;
Expand All @@ -159,8 +159,8 @@ show(err_struct_info)
store(err_struct_info)

static ssize_t
show_err_data_buffer(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
show_err_data_buffer(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int cpu=dev->id;

Expand All @@ -171,8 +171,8 @@ show_err_data_buffer(struct sys_device *dev,
}

static ssize_t
store_err_data_buffer(struct sys_device *dev,
struct sysdev_attribute *attr,
store_err_data_buffer(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
unsigned int cpu=dev->id;
Expand Down Expand Up @@ -209,14 +209,14 @@ define_one_ro(capabilities);
define_one_ro(resources);

static struct attribute *default_attrs[] = {
&attr_call_start.attr,
&attr_virtual_to_phys.attr,
&attr_err_type_info.attr,
&attr_err_struct_info.attr,
&attr_err_data_buffer.attr,
&attr_status.attr,
&attr_capabilities.attr,
&attr_resources.attr,
&dev_attr_call_start.attr,
&dev_attr_virtual_to_phys.attr,
&dev_attr_err_type_info.attr,
&dev_attr_err_struct_info.attr,
&dev_attr_err_data_buffer.attr,
&dev_attr_status.attr,
&dev_attr_capabilities.attr,
&dev_attr_resources.attr,
NULL
};

Expand All @@ -225,12 +225,12 @@ static struct attribute_group err_inject_attr_group = {
.name = "err_inject"
};
/* Add/Remove err_inject interface for CPU device */
static int __cpuinit err_inject_add_dev(struct sys_device * sys_dev)
static int __cpuinit err_inject_add_dev(struct device * sys_dev)
{
return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group);
}

static int __cpuinit err_inject_remove_dev(struct sys_device * sys_dev)
static int __cpuinit err_inject_remove_dev(struct device * sys_dev)
{
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
return 0;
Expand All @@ -239,9 +239,9 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;
struct sys_device *sys_dev;
struct device *sys_dev;

sys_dev = get_cpu_sysdev(cpu);
sys_dev = get_cpu_device(cpu);
switch (action) {
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
Expand Down Expand Up @@ -283,13 +283,13 @@ static void __exit
err_inject_exit(void)
{
int i;
struct sys_device *sys_dev;
struct device *sys_dev;

#ifdef ERR_INJ_DEBUG
printk(KERN_INFO "Exit error injection driver.\n");
#endif
for_each_online_cpu(i) {
sys_dev = get_cpu_sysdev(i);
sys_dev = get_cpu_device(i);
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
}
unregister_hotcpu_notifier(&err_inject_cpu_notifier);
Expand Down
10 changes: 5 additions & 5 deletions arch/ia64/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int __cpuinit cpu_cache_sysfs_init(unsigned int cpu)
}

/* Add cache interface for CPU device */
static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
static int __cpuinit cache_add_dev(struct device * sys_dev)
{
unsigned int cpu = sys_dev->id;
unsigned long i, j;
Expand Down Expand Up @@ -400,7 +400,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
}

/* Remove cache interface for CPU device */
static int __cpuinit cache_remove_dev(struct sys_device * sys_dev)
static int __cpuinit cache_remove_dev(struct device * sys_dev)
{
unsigned int cpu = sys_dev->id;
unsigned long i;
Expand Down Expand Up @@ -428,9 +428,9 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;
struct sys_device *sys_dev;
struct device *sys_dev;

sys_dev = get_cpu_sysdev(cpu);
sys_dev = get_cpu_device(cpu);
switch (action) {
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
Expand All @@ -454,7 +454,7 @@ static int __init cache_sysfs_init(void)
int i;

for_each_online_cpu(i) {
struct sys_device *sys_dev = get_cpu_sysdev((unsigned int)i);
struct device *sys_dev = get_cpu_device((unsigned int)i);
cache_add_dev(sys_dev);
}

Expand Down
Loading

0 comments on commit 8a25a2f

Please sign in to comment.