@@ -1818,27 +1818,26 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
1818
1818
*/
1819
1819
unsigned int cpufreq_quick_get (unsigned int cpu )
1820
1820
{
1821
- struct cpufreq_policy * policy ;
1822
- unsigned int ret_freq = 0 ;
1821
+ struct cpufreq_policy * policy __free (put_cpufreq_policy ) = NULL ;
1823
1822
unsigned long flags ;
1824
1823
1825
1824
read_lock_irqsave (& cpufreq_driver_lock , flags );
1826
1825
1827
1826
if (cpufreq_driver && cpufreq_driver -> setpolicy && cpufreq_driver -> get ) {
1828
- ret_freq = cpufreq_driver -> get (cpu );
1827
+ unsigned int ret_freq = cpufreq_driver -> get (cpu );
1828
+
1829
1829
read_unlock_irqrestore (& cpufreq_driver_lock , flags );
1830
+
1830
1831
return ret_freq ;
1831
1832
}
1832
1833
1833
1834
read_unlock_irqrestore (& cpufreq_driver_lock , flags );
1834
1835
1835
1836
policy = cpufreq_cpu_get (cpu );
1836
- if (policy ) {
1837
- ret_freq = policy -> cur ;
1838
- cpufreq_cpu_put (policy );
1839
- }
1837
+ if (policy )
1838
+ return policy -> cur ;
1840
1839
1841
- return ret_freq ;
1840
+ return 0 ;
1842
1841
}
1843
1842
EXPORT_SYMBOL (cpufreq_quick_get );
1844
1843
@@ -1850,15 +1849,13 @@ EXPORT_SYMBOL(cpufreq_quick_get);
1850
1849
*/
1851
1850
unsigned int cpufreq_quick_get_max (unsigned int cpu )
1852
1851
{
1853
- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1854
- unsigned int ret_freq = 0 ;
1852
+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
1855
1853
1856
- if (policy ) {
1857
- ret_freq = policy -> max ;
1858
- cpufreq_cpu_put (policy );
1859
- }
1854
+ policy = cpufreq_cpu_get (cpu );
1855
+ if (policy )
1856
+ return policy -> max ;
1860
1857
1861
- return ret_freq ;
1858
+ return 0 ;
1862
1859
}
1863
1860
EXPORT_SYMBOL (cpufreq_quick_get_max );
1864
1861
@@ -1870,15 +1867,13 @@ EXPORT_SYMBOL(cpufreq_quick_get_max);
1870
1867
*/
1871
1868
__weak unsigned int cpufreq_get_hw_max_freq (unsigned int cpu )
1872
1869
{
1873
- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1874
- unsigned int ret_freq = 0 ;
1870
+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
1875
1871
1876
- if (policy ) {
1877
- ret_freq = policy -> cpuinfo .max_freq ;
1878
- cpufreq_cpu_put (policy );
1879
- }
1872
+ policy = cpufreq_cpu_get (cpu );
1873
+ if (policy )
1874
+ return policy -> cpuinfo .max_freq ;
1880
1875
1881
- return ret_freq ;
1876
+ return 0 ;
1882
1877
}
1883
1878
EXPORT_SYMBOL (cpufreq_get_hw_max_freq );
1884
1879
@@ -1898,20 +1893,18 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
1898
1893
*/
1899
1894
unsigned int cpufreq_get (unsigned int cpu )
1900
1895
{
1901
- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1902
- unsigned int ret_freq = 0 ;
1896
+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
1903
1897
1898
+ policy = cpufreq_cpu_get (cpu );
1904
1899
if (!policy )
1905
1900
return 0 ;
1906
1901
1907
- scoped_guard (cpufreq_policy_read , policy ) {
1908
- if (cpufreq_driver -> get )
1909
- ret_freq = __cpufreq_get (policy );
1910
- }
1902
+ guard (cpufreq_policy_read )(policy );
1911
1903
1912
- cpufreq_cpu_put (policy );
1904
+ if (cpufreq_driver -> get )
1905
+ return __cpufreq_get (policy );
1913
1906
1914
- return ret_freq ;
1907
+ return 0 ;
1915
1908
}
1916
1909
EXPORT_SYMBOL (cpufreq_get );
1917
1910
@@ -2566,7 +2559,8 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
2566
2559
*/
2567
2560
int cpufreq_get_policy (struct cpufreq_policy * policy , unsigned int cpu )
2568
2561
{
2569
- struct cpufreq_policy * cpu_policy ;
2562
+ struct cpufreq_policy * cpu_policy __free (put_cpufreq_policy );
2563
+
2570
2564
if (!policy )
2571
2565
return - EINVAL ;
2572
2566
@@ -2576,7 +2570,6 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
2576
2570
2577
2571
memcpy (policy , cpu_policy , sizeof (* policy ));
2578
2572
2579
- cpufreq_cpu_put (cpu_policy );
2580
2573
return 0 ;
2581
2574
}
2582
2575
EXPORT_SYMBOL (cpufreq_get_policy );
0 commit comments