Skip to content

Commit e3591ee

Browse files
dhananjay-AMDsuperm1
authored andcommitted
cpufreq/amd-pstate: Call amd_pstate_set_driver() in amd_pstate_register_driver()
Replace a similar chunk of code in amd_pstate_register_driver() with amd_pstate_set_driver() call. Signed-off-by: Dhananjay Ugwekar <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]>
1 parent 6f241fa commit e3591ee

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,16 +1191,32 @@ static void amd_pstate_driver_cleanup(void)
11911191
current_pstate_driver = NULL;
11921192
}
11931193

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+
11941213
static int amd_pstate_register_driver(int mode)
11951214
{
11961215
int ret;
11971216

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;
12041220

12051221
cppc_state = mode;
12061222

@@ -1726,25 +1742,6 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
17261742
.attr = amd_pstate_epp_attr,
17271743
};
17281744

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-
17481745
/*
17491746
* CPPC function is not supported for family ID 17H with model_ID ranging from 0x10 to 0x2F.
17501747
* show the debug message that helps to check if the CPU has CPPC support for loading issue.

0 commit comments

Comments
 (0)