summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-06-10 01:25:48 -0700
committerPatrick Mochel <mochel@osdl.org>2003-06-10 01:25:48 -0700
commitbe9e929da5c6deff7004e455010965ef71998324 (patch)
treefffaa7c1ddab0af300d720828e3b4eab5c53f4b2 /kernel
parentae6a0c465d560a2c5e1fa16dd3d2ed769119cf2c (diff)
parent3d983e57eeb0d84ffafe1bb5b78688646ebd1d17 (diff)
Hand merge
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpufreq.c83
1 files changed, 32 insertions, 51 deletions
diff --git a/kernel/cpufreq.c b/kernel/cpufreq.c
index ab772ccf9c59..6ae2b821830e 100644
--- a/kernel/cpufreq.c
+++ b/kernel/cpufreq.c
@@ -49,8 +49,6 @@ static DECLARE_RWSEM (cpufreq_notifier_rwsem);
static LIST_HEAD(cpufreq_governor_list);
static DECLARE_MUTEX (cpufreq_governor_sem);
-static struct class_interface cpufreq_interface;
-
static int cpufreq_cpu_get(unsigned int cpu)
{
if (cpu >= NR_CPUS)
@@ -113,24 +111,8 @@ int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
EXPORT_SYMBOL_GPL(cpufreq_parse_governor);
-/* forward declarations */
-static int cpufreq_add_dev (struct class_device * dev);
-static void cpufreq_remove_dev (struct class_device * dev);
-
/* drivers/base/cpu.c */
-extern struct device_class cpu_devclass;
-
-static struct class_interface cpufreq_interface = {
- .class = &cpu_class,
- .add = &cpufreq_add_dev,
- .remove = &cpufreq_remove_dev,
-};
-
-static inline int to_cpu_nr (struct class_device *dev)
-{
- struct sys_device * cpu_sys_dev = container_of(dev->dev, struct sys_device, dev);
- return (cpu_sys_dev->id);
-}
+extern struct sysdev_class cpu_sysdev_class;
/**
@@ -331,9 +313,9 @@ static struct kobj_type ktype_cpufreq = {
*
* Adds the cpufreq interface for a CPU device.
*/
-static int cpufreq_add_dev (struct class_device * class_dev)
+static int cpufreq_add_dev (struct sys_device * sys_dev)
{
- unsigned int cpu = to_cpu_nr(class_dev);
+ unsigned int cpu = sys_dev->id;
int ret = 0;
struct cpufreq_policy new_policy;
struct cpufreq_policy *policy;
@@ -358,14 +340,12 @@ static int cpufreq_add_dev (struct class_device * class_dev)
memcpy(&new_policy,
policy,
sizeof(struct cpufreq_policy));
- class_set_devdata(class_dev, policy);
up(&cpufreq_driver_sem);
init_MUTEX(&policy->lock);
/* prepare interface data */
- policy->kobj.parent = &class_dev->kobj;
+ policy->kobj.parent = &sys_dev->kobj;
policy->kobj.ktype = &ktype_cpufreq;
-// policy->dev = dev->dev;
strlcpy(policy->kobj.name, "cpufreq", KOBJ_NAME_LEN);
ret = kobject_register(&policy->kobj);
@@ -396,12 +376,12 @@ static int cpufreq_add_dev (struct class_device * class_dev)
*
* Removes the cpufreq interface for a CPU device.
*/
-static void cpufreq_remove_dev (struct class_device * class_dev)
+static int cpufreq_remove_dev (struct sys_device * sys_dev)
{
- unsigned int cpu = to_cpu_nr(class_dev);
+ unsigned int cpu = sys_dev->id;
if (!kobject_get(&cpufreq_driver->policy[cpu].kobj))
- return;
+ return -EFAULT;
down(&cpufreq_driver_sem);
if ((cpufreq_driver->target) &&
@@ -421,9 +401,17 @@ static void cpufreq_remove_dev (struct class_device * class_dev)
up(&cpufreq_driver_sem);
kobject_put(&cpufreq_driver->policy[cpu].kobj);
- return;
+ return 0;
}
+static int cpufreq_restore(struct sys_device *);
+
+static struct sysdev_driver cpufreq_sysdev_driver = {
+ .add = cpufreq_add_dev,
+ .remove = cpufreq_remove_dev,
+ .restore = cpufreq_restore,
+};
+
/*********************************************************************
* NOTIFIER LISTS INTERFACE *
@@ -843,7 +831,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
memset(cpufreq_driver->policy, 0, NR_CPUS * sizeof(struct cpufreq_policy));
- return class_interface_register(&cpufreq_interface);
+ return sysdev_driver_register(&cpu_sysdev_class,&cpufreq_sysdev_driver);
}
EXPORT_SYMBOL_GPL(cpufreq_register_driver);
@@ -861,7 +849,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
if (!cpufreq_driver || (driver != cpufreq_driver))
return -EINVAL;
- class_interface_unregister(&cpufreq_interface);
+ sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
down(&cpufreq_driver_sem);
kfree(cpufreq_driver->policy);
@@ -874,41 +862,34 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
#ifdef CONFIG_PM
+
/**
* cpufreq_restore - restore the CPU clock frequency after resume
*
* Restore the CPU clock frequency so that our idea of the current
* frequency reflects the actual hardware.
*/
-int cpufreq_restore(void)
+static int cpufreq_restore(struct sys_device * sysdev)
{
- struct cpufreq_policy policy;
- unsigned int i;
+ int cpu = sysdev->id;
unsigned int ret = 0;
+ struct cpufreq_policy policy;
- if (in_interrupt())
- panic("cpufreq_restore() called from interrupt context!");
-
- if (!try_module_get(cpufreq_driver->owner))
- goto error_out;
-
- for (i=0;i<NR_CPUS;i++) {
- if (!cpu_online(i) || !cpufreq_cpu_get(i))
- continue;
-
+ if (cpu_online(cpu) && cpufreq_cpu_get(cpu)) {
down(&cpufreq_driver_sem);
- memcpy(&policy, &cpufreq_driver->policy[i], sizeof(struct cpufreq_policy));
+ memcpy(&policy, &cpufreq_driver->policy[cpu],
+ sizeof(struct cpufreq_policy));
up(&cpufreq_driver_sem);
- ret += cpufreq_set_policy(&policy);
-
- cpufreq_cpu_put(i);
+ ret = cpufreq_set_policy(&policy);
+ cpufreq_cpu_put(cpu);
}
- module_put(cpufreq_driver->owner);
- error_out:
return ret;
}
-EXPORT_SYMBOL_GPL(cpufreq_restore);
+
#else
-#define cpufreq_restore() do {} while (0)
+static int cpufreq_restore(struct sys_device * sysdev)
+{
+ return 0;
+}
#endif /* CONFIG_PM */