Re: [PATCH v4 1/8] cpufreq: CPPC: Add generic helpers for sysfs show/store
From: Viresh Kumar
Date: Mon Nov 10 2025 - 05:57:53 EST
On 05-11-25, 17:08, Sumit Gupta wrote:
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> -static ssize_t show_auto_act_window(struct cpufreq_policy *policy, char *buf)
> +static ssize_t cppc_cpufreq_sysfs_show_u64(unsigned int cpu, int (*get_func)(int, u64 *), char *buf)
> {
> u64 val;
> - int ret;
> -
> - ret = cppc_get_auto_act_window(policy->cpu, &val);
> + int ret = get_func(cpu, &val);
Why no casting required here, when you need it ...
> -static ssize_t store_auto_act_window(struct cpufreq_policy *policy,
> - const char *buf, size_t count)
> +static ssize_t cppc_cpufreq_sysfs_store_u64(unsigned int cpu, int (*set_func)(int, u64),
> + const char *buf, size_t count)
> {
> - u64 usec;
> + u64 val;
> int ret;
>
> - ret = kstrtou64(buf, 0, &usec);
> + ret = kstrtou64(buf, 0, &val);
> if (ret)
> return ret;
>
> - ret = cppc_set_auto_act_window(policy->cpu, usec);
> - if (ret)
> - return ret;
> + ret = set_func((int)cpu, val);
... here ?
--
viresh