@@ -1818,27 +1818,26 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
18181818 */
18191819unsigned int cpufreq_quick_get (unsigned int cpu )
18201820{
1821- struct cpufreq_policy * policy ;
1822- unsigned int ret_freq = 0 ;
1821+ struct cpufreq_policy * policy __free (put_cpufreq_policy ) = NULL ;
18231822 unsigned long flags ;
18241823
18251824 read_lock_irqsave (& cpufreq_driver_lock , flags );
18261825
18271826 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+
18291829 read_unlock_irqrestore (& cpufreq_driver_lock , flags );
1830+
18301831 return ret_freq ;
18311832 }
18321833
18331834 read_unlock_irqrestore (& cpufreq_driver_lock , flags );
18341835
18351836 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 ;
18401839
1841- return ret_freq ;
1840+ return 0 ;
18421841}
18431842EXPORT_SYMBOL (cpufreq_quick_get );
18441843
@@ -1850,15 +1849,13 @@ EXPORT_SYMBOL(cpufreq_quick_get);
18501849 */
18511850unsigned int cpufreq_quick_get_max (unsigned int cpu )
18521851{
1853- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1854- unsigned int ret_freq = 0 ;
1852+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
18551853
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 ;
18601857
1861- return ret_freq ;
1858+ return 0 ;
18621859}
18631860EXPORT_SYMBOL (cpufreq_quick_get_max );
18641861
@@ -1870,15 +1867,13 @@ EXPORT_SYMBOL(cpufreq_quick_get_max);
18701867 */
18711868__weak unsigned int cpufreq_get_hw_max_freq (unsigned int cpu )
18721869{
1873- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1874- unsigned int ret_freq = 0 ;
1870+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
18751871
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 ;
18801875
1881- return ret_freq ;
1876+ return 0 ;
18821877}
18831878EXPORT_SYMBOL (cpufreq_get_hw_max_freq );
18841879
@@ -1898,20 +1893,18 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
18981893 */
18991894unsigned int cpufreq_get (unsigned int cpu )
19001895{
1901- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
1902- unsigned int ret_freq = 0 ;
1896+ struct cpufreq_policy * policy __free (put_cpufreq_policy );
19031897
1898+ policy = cpufreq_cpu_get (cpu );
19041899 if (!policy )
19051900 return 0 ;
19061901
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 );
19111903
1912- cpufreq_cpu_put (policy );
1904+ if (cpufreq_driver -> get )
1905+ return __cpufreq_get (policy );
19131906
1914- return ret_freq ;
1907+ return 0 ;
19151908}
19161909EXPORT_SYMBOL (cpufreq_get );
19171910
@@ -2566,7 +2559,8 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
25662559 */
25672560int cpufreq_get_policy (struct cpufreq_policy * policy , unsigned int cpu )
25682561{
2569- struct cpufreq_policy * cpu_policy ;
2562+ struct cpufreq_policy * cpu_policy __free (put_cpufreq_policy );
2563+
25702564 if (!policy )
25712565 return - EINVAL ;
25722566
@@ -2576,7 +2570,6 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
25762570
25772571 memcpy (policy , cpu_policy , sizeof (* policy ));
25782572
2579- cpufreq_cpu_put (cpu_policy );
25802573 return 0 ;
25812574}
25822575EXPORT_SYMBOL (cpufreq_get_policy );
0 commit comments