@@ -1191,16 +1191,32 @@ static void amd_pstate_driver_cleanup(void)
1191
1191
current_pstate_driver = NULL ;
1192
1192
}
1193
1193
1194
+ static int amd_pstate_set_driver (int mode_idx )
1195
+ {
1196
+ if (mode_idx >= AMD_PSTATE_DISABLE && mode_idx < AMD_PSTATE_MAX ) {
1197
+ cppc_state = mode_idx ;
1198
+ if (cppc_state == AMD_PSTATE_DISABLE )
1199
+ pr_info ("driver is explicitly disabled\n" );
1200
+
1201
+ if (cppc_state == AMD_PSTATE_ACTIVE )
1202
+ current_pstate_driver = & amd_pstate_epp_driver ;
1203
+
1204
+ if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED )
1205
+ current_pstate_driver = & amd_pstate_driver ;
1206
+
1207
+ return 0 ;
1208
+ }
1209
+
1210
+ return - EINVAL ;
1211
+ }
1212
+
1194
1213
static int amd_pstate_register_driver (int mode )
1195
1214
{
1196
1215
int ret ;
1197
1216
1198
- if (mode == AMD_PSTATE_PASSIVE || mode == AMD_PSTATE_GUIDED )
1199
- current_pstate_driver = & amd_pstate_driver ;
1200
- else if (mode == AMD_PSTATE_ACTIVE )
1201
- current_pstate_driver = & amd_pstate_epp_driver ;
1202
- else
1203
- return - EINVAL ;
1217
+ ret = amd_pstate_set_driver (mode );
1218
+ if (ret )
1219
+ return ret ;
1204
1220
1205
1221
cppc_state = mode ;
1206
1222
@@ -1726,25 +1742,6 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
1726
1742
.attr = amd_pstate_epp_attr ,
1727
1743
};
1728
1744
1729
- static int __init amd_pstate_set_driver (int mode_idx )
1730
- {
1731
- if (mode_idx >= AMD_PSTATE_DISABLE && mode_idx < AMD_PSTATE_MAX ) {
1732
- cppc_state = mode_idx ;
1733
- if (cppc_state == AMD_PSTATE_DISABLE )
1734
- pr_info ("driver is explicitly disabled\n" );
1735
-
1736
- if (cppc_state == AMD_PSTATE_ACTIVE )
1737
- current_pstate_driver = & amd_pstate_epp_driver ;
1738
-
1739
- if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED )
1740
- current_pstate_driver = & amd_pstate_driver ;
1741
-
1742
- return 0 ;
1743
- }
1744
-
1745
- return - EINVAL ;
1746
- }
1747
-
1748
1745
/*
1749
1746
* CPPC function is not supported for family ID 17H with model_ID ranging from 0x10 to 0x2F.
1750
1747
* show the debug message that helps to check if the CPU has CPPC support for loading issue.
0 commit comments