aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 8a67f16987db..31d6f535a79d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1467,25 +1467,27 @@ int cpufreq_driver_target(struct cpufreq_policy *policy,
1467 unsigned int target_freq, 1467 unsigned int target_freq,
1468 unsigned int relation) 1468 unsigned int relation)
1469{ 1469{
1470 int ret; 1470 int ret = -EINVAL;
1471 1471
1472 policy = cpufreq_cpu_get(policy->cpu); 1472 policy = cpufreq_cpu_get(policy->cpu);
1473 if (!policy) 1473 if (!policy)
1474 return -EINVAL; 1474 goto no_policy;
1475 1475
1476 if (unlikely(lock_policy_rwsem_write(policy->cpu))) 1476 if (unlikely(lock_policy_rwsem_write(policy->cpu)))
1477 return -EINVAL; 1477 goto fail;
1478 1478
1479 ret = __cpufreq_driver_target(policy, target_freq, relation); 1479 ret = __cpufreq_driver_target(policy, target_freq, relation);
1480 1480
1481 unlock_policy_rwsem_write(policy->cpu); 1481 unlock_policy_rwsem_write(policy->cpu);
1482 1482
1483fail:
1483 cpufreq_cpu_put(policy); 1484 cpufreq_cpu_put(policy);
1485no_policy:
1484 return ret; 1486 return ret;
1485} 1487}
1486EXPORT_SYMBOL_GPL(cpufreq_driver_target); 1488EXPORT_SYMBOL_GPL(cpufreq_driver_target);
1487 1489
1488int __cpufreq_driver_getavg(struct cpufreq_policy *policy) 1490int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
1489{ 1491{
1490 int ret = 0; 1492 int ret = 0;
1491 1493
@@ -1493,8 +1495,8 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy)
1493 if (!policy) 1495 if (!policy)
1494 return -EINVAL; 1496 return -EINVAL;
1495 1497
1496 if (cpu_online(policy->cpu) && cpufreq_driver->getavg) 1498 if (cpu_online(cpu) && cpufreq_driver->getavg)
1497 ret = cpufreq_driver->getavg(policy->cpu); 1499 ret = cpufreq_driver->getavg(policy, cpu);
1498 1500
1499 cpufreq_cpu_put(policy); 1501 cpufreq_cpu_put(policy);
1500 return ret; 1502 return ret;
@@ -1717,13 +1719,17 @@ int cpufreq_update_policy(unsigned int cpu)
1717{ 1719{
1718 struct cpufreq_policy *data = cpufreq_cpu_get(cpu); 1720 struct cpufreq_policy *data = cpufreq_cpu_get(cpu);
1719 struct cpufreq_policy policy; 1721 struct cpufreq_policy policy;
1720 int ret = 0; 1722 int ret;
1721 1723
1722 if (!data) 1724 if (!data) {
1723 return -ENODEV; 1725 ret = -ENODEV;
1726 goto no_policy;
1727 }
1724 1728
1725 if (unlikely(lock_policy_rwsem_write(cpu))) 1729 if (unlikely(lock_policy_rwsem_write(cpu))) {
1726 return -EINVAL; 1730 ret = -EINVAL;
1731 goto fail;
1732 }
1727 1733
1728 dprintk("updating policy for CPU %u\n", cpu); 1734 dprintk("updating policy for CPU %u\n", cpu);
1729 memcpy(&policy, data, sizeof(struct cpufreq_policy)); 1735 memcpy(&policy, data, sizeof(struct cpufreq_policy));
@@ -1750,7 +1756,9 @@ int cpufreq_update_policy(unsigned int cpu)
1750 1756
1751 unlock_policy_rwsem_write(cpu); 1757 unlock_policy_rwsem_write(cpu);
1752 1758
1759fail:
1753 cpufreq_cpu_put(data); 1760 cpufreq_cpu_put(data);
1761no_policy:
1754 return ret; 1762 return ret;
1755} 1763}
1756EXPORT_SYMBOL(cpufreq_update_policy); 1764EXPORT_SYMBOL(cpufreq_update_policy);