aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/cpufreq/cpufreq.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 8a67f16987db..9bbdc258624c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1467,20 +1467,22 @@ 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);
@@ -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);