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]>
This commit is contained in:
Kay Sievers 2011-12-21 14:29:42 -08:00 • committed by Greg Kroah-Hartman
commit 8a25a2fd12
38 changed files with 874 additions and 877 deletions

View file

@ -291,10 +291,10 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
static int __cpuidle_register_device(struct cpuidle_device *dev)
{
int ret;
struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
if (!sys_dev)
if (!dev)
return -EINVAL;
if (!try_module_get(cpuidle_driver->owner))
return -EINVAL;
@ -303,7 +303,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
per_cpu(cpuidle_devices, dev->cpu) = dev;
list_add(&dev->device_list, &cpuidle_detected_devices);
if ((ret = cpuidle_add_sysfs(sys_dev))) {
if ((ret = cpuidle_add_sysfs(cpu_dev))) {
module_put(cpuidle_driver->owner);
return ret;
}
@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device);
*/
void cpuidle_unregister_device(struct cpuidle_device *dev)
{
struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
if (dev->registered == 0)
@ -354,7 +354,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
cpuidle_disable_device(dev);
cpuidle_remove_sysfs(sys_dev);
cpuidle_remove_sysfs(cpu_dev);
list_del(&dev->device_list);
wait_for_completion(&dev->kobj_unregister);
per_cpu(cpuidle_devices, dev->cpu) = NULL;
@ -411,7 +411,7 @@ static int __init cpuidle_init(void)
if (cpuidle_disabled())
return -ENODEV;
ret = cpuidle_add_class_sysfs(&cpu_sysdev_class);
ret = cpuidle_add_interface(cpu_subsys.dev_root);
if (ret)
return ret;

View file

@ -5,7 +5,7 @@
#ifndef __DRIVER_CPUIDLE_H
#define __DRIVER_CPUIDLE_H
#include <linux/sysdev.h>
#include <linux/device.h>
/* For internal use only */
extern struct cpuidle_governor *cpuidle_curr_governor;
@ -23,11 +23,11 @@ extern void cpuidle_uninstall_idle_handler(void);
extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
/* sysfs */
extern int cpuidle_add_class_sysfs(struct sysdev_class *cls);
extern void cpuidle_remove_class_sysfs(struct sysdev_class *cls);
extern int cpuidle_add_interface(struct device *dev);
extern void cpuidle_remove_interface(struct device *dev);
extern int cpuidle_add_state_sysfs(struct cpuidle_device *device);
extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
extern int cpuidle_add_sysfs(struct sys_device *sysdev);
extern void cpuidle_remove_sysfs(struct sys_device *sysdev);
extern int cpuidle_add_sysfs(struct device *dev);
extern void cpuidle_remove_sysfs(struct device *dev);
#endif /* __DRIVER_CPUIDLE_H */

View file

@ -22,8 +22,8 @@ static int __init cpuidle_sysfs_setup(char *unused)
}
__setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
static ssize_t show_available_governors(struct sysdev_class *class,
struct sysdev_class_attribute *attr,
static ssize_t show_available_governors(struct device *dev,
struct device_attribute *attr,
char *buf)
{
ssize_t i = 0;
@ -42,8 +42,8 @@ out:
return i;
}
static ssize_t show_current_driver(struct sysdev_class *class,
struct sysdev_class_attribute *attr,
static ssize_t show_current_driver(struct device *dev,
struct device_attribute *attr,
char *buf)
{
ssize_t ret;
@ -59,8 +59,8 @@ static ssize_t show_current_driver(struct sysdev_class *class,
return ret;
}
static ssize_t show_current_governor(struct sysdev_class *class,
struct sysdev_class_attribute *attr,
static ssize_t show_current_governor(struct device *dev,
struct device_attribute *attr,
char *buf)
{
ssize_t ret;
@ -75,8 +75,8 @@ static ssize_t show_current_governor(struct sysdev_class *class,
return ret;
}
static ssize_t store_current_governor(struct sysdev_class *class,
struct sysdev_class_attribute *attr,
static ssize_t store_current_governor(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
char gov_name[CPUIDLE_NAME_LEN];
@ -109,50 +109,48 @@ static ssize_t store_current_governor(struct sysdev_class *class,
return count;
}
static SYSDEV_CLASS_ATTR(current_driver, 0444, show_current_driver, NULL);
static SYSDEV_CLASS_ATTR(current_governor_ro, 0444, show_current_governor,
NULL);
static DEVICE_ATTR(current_driver, 0444, show_current_driver, NULL);
static DEVICE_ATTR(current_governor_ro, 0444, show_current_governor, NULL);
static struct attribute *cpuclass_default_attrs[] = {
&attr_current_driver.attr,
&attr_current_governor_ro.attr,
static struct attribute *cpuidle_default_attrs[] = {
&dev_attr_current_driver.attr,
&dev_attr_current_governor_ro.attr,
NULL
};
static SYSDEV_CLASS_ATTR(available_governors, 0444, show_available_governors,
NULL);
static SYSDEV_CLASS_ATTR(current_governor, 0644, show_current_governor,
store_current_governor);
static DEVICE_ATTR(available_governors, 0444, show_available_governors, NULL);
static DEVICE_ATTR(current_governor, 0644, show_current_governor,
store_current_governor);
static struct attribute *cpuclass_switch_attrs[] = {
&attr_available_governors.attr,
&attr_current_driver.attr,
&attr_current_governor.attr,
static struct attribute *cpuidle_switch_attrs[] = {
&dev_attr_available_governors.attr,
&dev_attr_current_driver.attr,
&dev_attr_current_governor.attr,
NULL
};
static struct attribute_group cpuclass_attr_group = {
.attrs = cpuclass_default_attrs,
static struct attribute_group cpuidle_attr_group = {
.attrs = cpuidle_default_attrs,
.name = "cpuidle",
};
/**
* cpuidle_add_class_sysfs - add CPU global sysfs attributes
* cpuidle_add_interface - add CPU global sysfs attributes
*/
int cpuidle_add_class_sysfs(struct sysdev_class *cls)
int cpuidle_add_interface(struct device *dev)
{
if (sysfs_switch)
cpuclass_attr_group.attrs = cpuclass_switch_attrs;
cpuidle_attr_group.attrs = cpuidle_switch_attrs;
return sysfs_create_group(&cls->kset.kobj, &cpuclass_attr_group);
return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
}
/**
* cpuidle_remove_class_sysfs - remove CPU global sysfs attributes
* cpuidle_remove_interface - remove CPU global sysfs attributes
*/
void cpuidle_remove_class_sysfs(struct sysdev_class *cls)
void cpuidle_remove_interface(struct device *dev)
{
sysfs_remove_group(&cls->kset.kobj, &cpuclass_attr_group);
sysfs_remove_group(&dev->kobj, &cpuidle_attr_group);
}
struct cpuidle_attr {
@ -365,16 +363,16 @@ void cpuidle_remove_state_sysfs(struct cpuidle_device *device)
/**
* cpuidle_add_sysfs - creates a sysfs instance for the target device
* @sysdev: the target device
* @dev: the target device
*/
int cpuidle_add_sysfs(struct sys_device *sysdev)
int cpuidle_add_sysfs(struct device *cpu_dev)
{
int cpu = sysdev->id;
int cpu = cpu_dev->id;
struct cpuidle_device *dev;
int error;
dev = per_cpu(cpuidle_devices, cpu);
error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj,
error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj,
"cpuidle");
if (!error)
kobject_uevent(&dev->kobj, KOBJ_ADD);
@ -383,11 +381,11 @@ int cpuidle_add_sysfs(struct sys_device *sysdev)
/**
* cpuidle_remove_sysfs - deletes a sysfs instance on the target device
* @sysdev: the target device
* @dev: the target device
*/
void cpuidle_remove_sysfs(struct sys_device *sysdev)
void cpuidle_remove_sysfs(struct device *cpu_dev)
{
int cpu = sysdev->id;
int cpu = cpu_dev->id;
struct cpuidle_device *dev;
dev = per_cpu(cpuidle_devices, cpu);