Commit 2717cc0d authored by Dave Jones's avatar Dave Jones

[CPUFREQ] Fix locking [6/11]

Change the function parameter of cpufreq_cpu_put to struct
cpufreq_policy *.
parent 3563db15
...@@ -94,9 +94,9 @@ static struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu) ...@@ -94,9 +94,9 @@ static struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu)
return NULL; return NULL;
} }
static void cpufreq_cpu_put(unsigned int cpu) static void cpufreq_cpu_put(struct cpufreq_policy *data)
{ {
kobject_put(&cpufreq_driver->policy[cpu].kobj); kobject_put(&data->kobj);
module_put(cpufreq_driver->owner); module_put(cpufreq_driver->owner);
} }
...@@ -303,10 +303,11 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) ...@@ -303,10 +303,11 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
struct cpufreq_policy * policy = to_policy(kobj); struct cpufreq_policy * policy = to_policy(kobj);
struct freq_attr * fattr = to_attr(attr); struct freq_attr * fattr = to_attr(attr);
ssize_t ret; ssize_t ret;
if (!cpufreq_cpu_get(policy->cpu)) policy = cpufreq_cpu_get(policy->cpu);
if (!policy)
return -EINVAL; return -EINVAL;
ret = fattr->show ? fattr->show(policy,buf) : 0; ret = fattr->show ? fattr->show(policy,buf) : 0;
cpufreq_cpu_put(policy->cpu); cpufreq_cpu_put(policy);
return ret; return ret;
} }
...@@ -316,10 +317,11 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr, ...@@ -316,10 +317,11 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr,
struct cpufreq_policy * policy = to_policy(kobj); struct cpufreq_policy * policy = to_policy(kobj);
struct freq_attr * fattr = to_attr(attr); struct freq_attr * fattr = to_attr(attr);
ssize_t ret; ssize_t ret;
if (!cpufreq_cpu_get(policy->cpu)) policy = cpufreq_cpu_get(policy->cpu);
if (!policy)
return -EINVAL; return -EINVAL;
ret = fattr->store ? fattr->store(policy,buf,count) : 0; ret = fattr->store ? fattr->store(policy,buf,count) : 0;
cpufreq_cpu_put(policy->cpu); cpufreq_cpu_put(policy);
return ret; return ret;
} }
...@@ -473,15 +475,20 @@ static int cpufreq_restore(struct sys_device * sysdev) ...@@ -473,15 +475,20 @@ static int cpufreq_restore(struct sys_device * sysdev)
int cpu = sysdev->id; int cpu = sysdev->id;
unsigned int ret = 0; unsigned int ret = 0;
struct cpufreq_policy policy; struct cpufreq_policy policy;
struct cpufreq_policy *cpu_policy;
if (cpu_online(cpu) && cpufreq_cpu_get(cpu)) { if (!cpu_online(cpu))
down(&cpufreq_driver_sem); return 0;
memcpy(&policy, &cpufreq_driver->policy[cpu],
sizeof(struct cpufreq_policy)); cpu_policy = cpufreq_cpu_get(cpu);
up(&cpufreq_driver_sem);
ret = cpufreq_set_policy(&policy); down(&cpufreq_driver_sem);
cpufreq_cpu_put(cpu); memcpy(&policy, cpu_policy, sizeof(struct cpufreq_policy));
} up(&cpufreq_driver_sem);
ret = cpufreq_set_policy(&policy);
cpufreq_cpu_put(cpu_policy);
return ret; return ret;
} }
...@@ -584,7 +591,7 @@ inline int cpufreq_driver_target(struct cpufreq_policy *policy, ...@@ -584,7 +591,7 @@ inline int cpufreq_driver_target(struct cpufreq_policy *policy,
up(&policy->lock); up(&policy->lock);
cpufreq_cpu_put(policy->cpu); cpufreq_cpu_put(policy);
return ret; return ret;
} }
...@@ -629,7 +636,7 @@ int cpufreq_governor(unsigned int cpu, unsigned int event) ...@@ -629,7 +636,7 @@ int cpufreq_governor(unsigned int cpu, unsigned int event)
ret = -EINVAL; ret = -EINVAL;
} }
cpufreq_cpu_put(cpu); cpufreq_cpu_put(policy);
return ret; return ret;
} }
...@@ -691,16 +698,19 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); ...@@ -691,16 +698,19 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
*/ */
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
{ {
if (!policy || !cpufreq_cpu_get(cpu)) struct cpufreq_policy *cpu_policy;
if (!policy)
return -EINVAL;
cpu_policy = cpufreq_cpu_get(cpu);
if (!cpu_policy)
return -EINVAL; return -EINVAL;
down(&cpufreq_driver_sem); down(&cpufreq_driver_sem);
memcpy(policy, memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy));
&cpufreq_driver->policy[cpu],
sizeof(struct cpufreq_policy));
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
cpufreq_cpu_put(cpu); cpufreq_cpu_put(cpu_policy);
return 0; return 0;
} }
...@@ -796,7 +806,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) ...@@ -796,7 +806,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy)
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
error_out: error_out:
cpufreq_cpu_put(data->cpu); cpufreq_cpu_put(data);
return ret; return ret;
} }
......
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