Commit e15eba7e authored by Patrick Mochel's avatar Patrick Mochel

[cpufreq] Convert to use new system device API

- Remove explicit call from arm PM sequence, as its handled implicitly 
  by sysdev_restore() in driver model core.
parent 623532ff
......@@ -11,7 +11,6 @@
#include <linux/config.h>
#include <linux/pm.h>
#include <linux/device.h>
#include <linux/cpufreq.h>
#include <asm/leds.h>
#include <asm/system.h>
......@@ -66,13 +65,6 @@ int suspend(void)
*/
device_resume(RESUME_POWER_ON);
/*
* Restore the CPU frequency settings.
*/
#ifdef CONFIG_CPU_FREQ
cpufreq_restore();
#endif
/*
* Resume LDM devices.
*/
......
......@@ -205,10 +205,6 @@ struct freq_attr {
int cpufreq_set_policy(struct cpufreq_policy *policy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
#ifdef CONFIG_PM
int cpufreq_restore(void);
#endif
/* the proc_intf.c needs this */
int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpufreq_governor **governor);
......
......@@ -52,8 +52,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)
return 0;
......@@ -110,24 +108,8 @@ int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpu
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;
/**
......@@ -327,9 +309,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;
......@@ -354,14 +336,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);
......@@ -392,12 +372,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) &&
......@@ -417,9 +397,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 *
......@@ -839,7 +827,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);
......@@ -857,7 +845,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);
......@@ -870,41 +858,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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment