@@ -758,12 +758,12 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
758
758
pr_err ("Boost mode is not supported by this processor or SBIOS\n" );
759
759
return - EOPNOTSUPP ;
760
760
}
761
- mutex_lock (& amd_pstate_driver_lock );
761
+ guard (mutex )(& amd_pstate_driver_lock );
762
+
762
763
ret = amd_pstate_cpu_boost_update (policy , state );
763
764
WRITE_ONCE (cpudata -> boost_state , !ret ? state : false);
764
765
policy -> boost_enabled = !ret ? state : false;
765
766
refresh_frequency_limits (policy );
766
- mutex_unlock (& amd_pstate_driver_lock );
767
767
768
768
return ret ;
769
769
}
@@ -854,7 +854,8 @@ static void amd_pstate_update_limits(unsigned int cpu)
854
854
if (!amd_pstate_prefcore )
855
855
return ;
856
856
857
- mutex_lock (& amd_pstate_driver_lock );
857
+ guard (mutex )(& amd_pstate_driver_lock );
858
+
858
859
ret = amd_get_highest_perf (cpu , & cur_high );
859
860
if (ret )
860
861
goto free_cpufreq_put ;
@@ -874,7 +875,6 @@ static void amd_pstate_update_limits(unsigned int cpu)
874
875
if (!highest_perf_changed )
875
876
cpufreq_update_policy (cpu );
876
877
877
- mutex_unlock (& amd_pstate_driver_lock );
878
878
}
879
879
880
880
/*
@@ -1203,11 +1203,11 @@ static ssize_t store_energy_performance_preference(
1203
1203
if (ret < 0 )
1204
1204
return - EINVAL ;
1205
1205
1206
- mutex_lock (& amd_pstate_limits_lock );
1206
+ guard (mutex )(& amd_pstate_limits_lock );
1207
+
1207
1208
ret = amd_pstate_set_energy_pref_index (cpudata , ret );
1208
- mutex_unlock (& amd_pstate_limits_lock );
1209
1209
1210
- return ret ?: count ;
1210
+ return ret ? ret : count ;
1211
1211
}
1212
1212
1213
1213
static ssize_t show_energy_performance_preference (
@@ -1371,13 +1371,10 @@ EXPORT_SYMBOL_GPL(amd_pstate_update_status);
1371
1371
static ssize_t status_show (struct device * dev ,
1372
1372
struct device_attribute * attr , char * buf )
1373
1373
{
1374
- ssize_t ret ;
1375
1374
1376
- mutex_lock (& amd_pstate_driver_lock );
1377
- ret = amd_pstate_show_status (buf );
1378
- mutex_unlock (& amd_pstate_driver_lock );
1375
+ guard (mutex )(& amd_pstate_driver_lock );
1379
1376
1380
- return ret ;
1377
+ return amd_pstate_show_status ( buf ) ;
1381
1378
}
1382
1379
1383
1380
static ssize_t status_store (struct device * a , struct device_attribute * b ,
@@ -1386,9 +1383,8 @@ static ssize_t status_store(struct device *a, struct device_attribute *b,
1386
1383
char * p = memchr (buf , '\n' , count );
1387
1384
int ret ;
1388
1385
1389
- mutex_lock (& amd_pstate_driver_lock );
1386
+ guard ( mutex ) (& amd_pstate_driver_lock );
1390
1387
ret = amd_pstate_update_status (buf , p ? p - buf : count );
1391
- mutex_unlock (& amd_pstate_driver_lock );
1392
1388
1393
1389
return ret < 0 ? ret : count ;
1394
1390
}
@@ -1689,7 +1685,7 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
1689
1685
1690
1686
min_perf = READ_ONCE (cpudata -> lowest_perf );
1691
1687
1692
- mutex_lock (& amd_pstate_limits_lock );
1688
+ guard ( mutex ) (& amd_pstate_limits_lock );
1693
1689
1694
1690
if (trace_amd_pstate_epp_perf_enabled ()) {
1695
1691
trace_amd_pstate_epp_perf (cpudata -> cpu , cpudata -> highest_perf ,
@@ -1700,8 +1696,6 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
1700
1696
amd_pstate_update_perf (cpudata , min_perf , 0 , min_perf , false);
1701
1697
amd_pstate_set_epp (cpudata , AMD_CPPC_EPP_BALANCE_POWERSAVE );
1702
1698
1703
- mutex_unlock (& amd_pstate_limits_lock );
1704
-
1705
1699
return 0 ;
1706
1700
}
1707
1701
@@ -1730,13 +1724,11 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy)
1730
1724
struct amd_cpudata * cpudata = policy -> driver_data ;
1731
1725
1732
1726
if (cpudata -> suspended ) {
1733
- mutex_lock (& amd_pstate_limits_lock );
1727
+ guard ( mutex ) (& amd_pstate_limits_lock );
1734
1728
1735
1729
/* enable amd pstate from suspend state*/
1736
1730
amd_pstate_epp_reenable (cpudata );
1737
1731
1738
- mutex_unlock (& amd_pstate_limits_lock );
1739
-
1740
1732
cpudata -> suspended = false;
1741
1733
}
1742
1734
0 commit comments