Message ID | 490341a4cec543fb95aad76b257a2bee525c515c.1718262992.git.perry.yuan@amd.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Mario Limonciello |
Headers | show |
Series | AMD Pstate Driver Core Performance Boost | expand |
On 6/13/2024 02:25, Perry Yuan wrote: > Update the cpufreq store function to use kstrtobool for parsing boolean > values. This simplifies the code and improves readability by using a > standard kernel function for boolean string conversion. > > Signed-off-by: Perry Yuan <perry.yuan@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > --- > drivers/cpufreq/cpufreq.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index a45aac17c20f..1fdabb660231 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -614,10 +614,9 @@ static ssize_t show_boost(struct kobject *kobj, > static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr, > const char *buf, size_t count) > { > - int ret, enable; > + bool enable; > > - ret = sscanf(buf, "%d", &enable); > - if (ret != 1 || enable < 0 || enable > 1) > + if (kstrtobool(buf, &enable)) > return -EINVAL; > > if (cpufreq_boost_trigger_state(enable)) { > @@ -641,10 +640,10 @@ static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf) > static ssize_t store_local_boost(struct cpufreq_policy *policy, > const char *buf, size_t count) > { > - int ret, enable; > + int ret; > + bool enable; > > - ret = kstrtoint(buf, 10, &enable); > - if (ret || enable < 0 || enable > 1) > + if (kstrtobool(buf, &enable)) > return -EINVAL; > > if (!cpufreq_driver->boost_enabled)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a45aac17c20f..1fdabb660231 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -614,10 +614,9 @@ static ssize_t show_boost(struct kobject *kobj, static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - int ret, enable; + bool enable; - ret = sscanf(buf, "%d", &enable); - if (ret != 1 || enable < 0 || enable > 1) + if (kstrtobool(buf, &enable)) return -EINVAL; if (cpufreq_boost_trigger_state(enable)) { @@ -641,10 +640,10 @@ static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf) static ssize_t store_local_boost(struct cpufreq_policy *policy, const char *buf, size_t count) { - int ret, enable; + int ret; + bool enable; - ret = kstrtoint(buf, 10, &enable); - if (ret || enable < 0 || enable > 1) + if (kstrtobool(buf, &enable)) return -EINVAL; if (!cpufreq_driver->boost_enabled)
Update the cpufreq store function to use kstrtobool for parsing boolean values. This simplifies the code and improves readability by using a standard kernel function for boolean string conversion. Signed-off-by: Perry Yuan <perry.yuan@amd.com> --- drivers/cpufreq/cpufreq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)