]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: CPPC: Modify cppc_get_auto_sel_caps() to cppc_get_auto_sel()
authorLifeng Zheng <zhenglifeng1@huawei.com>
Fri, 11 Apr 2025 09:38:54 +0000 (17:38 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 30 Apr 2025 20:01:31 +0000 (22:01 +0200)
Modify cppc_get_auto_sel_caps() to cppc_get_auto_sel(). Using a
cppc_perf_caps to carry the value is unnecessary.

Add a check to ensure the pointer 'enable' is not null.

Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/20250411093855.982491-8-zhenglifeng1@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/cppc_acpi.c
drivers/cpufreq/amd-pstate.c
include/acpi/cppc_acpi.h

index 62c4673c3ef833793457a3319d5a080293baad74..6163831b8c196e15fc98ab312af6302e37f6479e 100644 (file)
@@ -1602,23 +1602,27 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable)
 EXPORT_SYMBOL_GPL(cppc_set_epp_perf);
 
 /**
- * cppc_get_auto_sel_caps - Read autonomous selection register.
- * @cpunum : CPU from which to read register.
- * @perf_caps : struct where autonomous selection register value is updated.
+ * cppc_get_auto_sel() - Read autonomous selection register.
+ * @cpu: CPU from which to read register.
+ * @enable: Return address.
  */
-int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps)
+int cppc_get_auto_sel(int cpu, bool *enable)
 {
        u64 auto_sel;
        int ret;
 
-       ret = cppc_get_reg_val(cpunum, AUTO_SEL_ENABLE, &auto_sel);
+       if (enable == NULL)
+               return -EINVAL;
+
+       ret = cppc_get_reg_val(cpu, AUTO_SEL_ENABLE, &auto_sel);
        if (ret)
                return ret;
 
-       perf_caps->auto_sel = (bool)auto_sel;
+       *enable = (bool)auto_sel;
+
        return 0;
 }
-EXPORT_SYMBOL_GPL(cppc_get_auto_sel_caps);
+EXPORT_SYMBOL_GPL(cppc_get_auto_sel);
 
 /**
  * cppc_set_auto_sel - Write autonomous selection register.
index b961f3a3b58059691ad169ed265b08fddf9f60d0..4fc10c2191bf03d6d9f96826b78a1a45fa5fbfee 100644 (file)
@@ -417,6 +417,7 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
        struct cppc_perf_caps cppc_perf;
        union perf_cached perf = READ_ONCE(cpudata->perf);
        u64 numerator;
+       bool auto_sel;
 
        int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
        if (ret)
@@ -438,7 +439,7 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
        if (cppc_state == AMD_PSTATE_ACTIVE)
                return 0;
 
-       ret = cppc_get_auto_sel_caps(cpudata->cpu, &cppc_perf);
+       ret = cppc_get_auto_sel(cpudata->cpu, &auto_sel);
        if (ret) {
                pr_warn("failed to get auto_sel, ret: %d\n", ret);
                return 0;
index 62d368bcd9eca5eb105b6be7d6bfa0b6183fb766..31767c65be20c5b07bf0df0d08456cd77ce170b9 100644 (file)
@@ -159,7 +159,7 @@ extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
 extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);
 extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf);
 extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable);
-extern int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps);
+extern int cppc_get_auto_sel(int cpu, bool *enable);
 extern int cppc_set_auto_sel(int cpu, bool enable);
 extern int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf);
 extern int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator);
@@ -229,11 +229,11 @@ static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf)
 {
        return -EOPNOTSUPP;
 }
-static inline int cppc_set_auto_sel(int cpu, bool enable)
+static inline int cppc_get_auto_sel(int cpu, bool *enable)
 {
        return -EOPNOTSUPP;
 }
-static inline int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps)
+static inline int cppc_set_auto_sel(int cpu, bool enable)
 {
        return -EOPNOTSUPP;
 }