aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-05-21 04:59:29 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-28 19:27:38 -0400
commit8d65775d17941d6d41f5913fc6a99a134c588e01 (patch)
tree008d4a6576e1859884384a99b3fefc110e7c3094
parent1ef546f22f14eea624681aa2793f4f07b051b68d (diff)
cpufreq: handle calls to ->target_index() in separate routine
Handling calls to ->target_index() has got complex over time and might become more complex. So, its better to take target_index() bits out in another routine __target_index() for better code readability. Shouldn't have any functional impact. Tested-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/cpufreq.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a05c92198b9f..ae11dd51f81d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1816,12 +1816,43 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier);
1816 * GOVERNORS * 1816 * GOVERNORS *
1817 *********************************************************************/ 1817 *********************************************************************/
1818 1818
1819static int __target_index(struct cpufreq_policy *policy,
1820 struct cpufreq_frequency_table *freq_table, int index)
1821{
1822 struct cpufreq_freqs freqs;
1823 int retval = -EINVAL;
1824 bool notify;
1825
1826 notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
1827
1828 if (notify) {
1829 freqs.old = policy->cur;
1830 freqs.new = freq_table[index].frequency;
1831 freqs.flags = 0;
1832
1833 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n",
1834 __func__, policy->cpu, freqs.old, freqs.new);
1835
1836 cpufreq_freq_transition_begin(policy, &freqs);
1837 }
1838
1839 retval = cpufreq_driver->target_index(policy, index);
1840 if (retval)
1841 pr_err("%s: Failed to change cpu frequency: %d\n", __func__,
1842 retval);
1843
1844 if (notify)
1845 cpufreq_freq_transition_end(policy, &freqs, retval);
1846
1847 return retval;
1848}
1849
1819int __cpufreq_driver_target(struct cpufreq_policy *policy, 1850int __cpufreq_driver_target(struct cpufreq_policy *policy,
1820 unsigned int target_freq, 1851 unsigned int target_freq,
1821 unsigned int relation) 1852 unsigned int relation)
1822{ 1853{
1823 int retval = -EINVAL;
1824 unsigned int old_target_freq = target_freq; 1854 unsigned int old_target_freq = target_freq;
1855 int retval = -EINVAL;
1825 1856
1826 if (cpufreq_disabled()) 1857 if (cpufreq_disabled())
1827 return -ENODEV; 1858 return -ENODEV;
@@ -1848,8 +1879,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1848 retval = cpufreq_driver->target(policy, target_freq, relation); 1879 retval = cpufreq_driver->target(policy, target_freq, relation);
1849 else if (cpufreq_driver->target_index) { 1880 else if (cpufreq_driver->target_index) {
1850 struct cpufreq_frequency_table *freq_table; 1881 struct cpufreq_frequency_table *freq_table;
1851 struct cpufreq_freqs freqs;
1852 bool notify;
1853 int index; 1882 int index;
1854 1883
1855 freq_table = cpufreq_frequency_get_table(policy->cpu); 1884 freq_table = cpufreq_frequency_get_table(policy->cpu);
@@ -1870,26 +1899,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1870 goto out; 1899 goto out;
1871 } 1900 }
1872 1901
1873 notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); 1902 retval = __target_index(policy, freq_table, index);
1874
1875 if (notify) {
1876 freqs.old = policy->cur;
1877 freqs.new = freq_table[index].frequency;
1878 freqs.flags = 0;
1879
1880 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n",
1881 __func__, policy->cpu, freqs.old, freqs.new);
1882
1883 cpufreq_freq_transition_begin(policy, &freqs);
1884 }
1885
1886 retval = cpufreq_driver->target_index(policy, index);
1887 if (retval)
1888 pr_err("%s: Failed to change cpu frequency: %d\n",
1889 __func__, retval);
1890
1891 if (notify)
1892 cpufreq_freq_transition_end(policy, &freqs, retval);
1893 } 1903 }
1894 1904
1895out: 1905out: