Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2240d3e

Browse files
Perry Yuansuperm1
authored andcommitted
cpufreq: simplify boolean parsing with kstrtobool in store function
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. Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Signed-off-by: Perry Yuan <perry.yuan@amd.com> Link: https://lore.kernel.org/r/d392eba3bad1231776124c321cef8c184ce1482d.1718988436.git.perry.yuan@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent bc76f57 commit 2240d3e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,9 @@ static ssize_t show_boost(struct kobject *kobj,
614614
static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr,
615615
const char *buf, size_t count)
616616
{
617-
int ret, enable;
617+
bool enable;
618618

619-
ret = sscanf(buf, "%d", &enable);
620-
if (ret != 1 || enable < 0 || enable > 1)
619+
if (kstrtobool(buf, &enable))
621620
return -EINVAL;
622621

623622
if (cpufreq_boost_trigger_state(enable)) {
@@ -641,10 +640,10 @@ static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf)
641640
static ssize_t store_local_boost(struct cpufreq_policy *policy,
642641
const char *buf, size_t count)
643642
{
644-
int ret, enable;
643+
int ret;
644+
bool enable;
645645

646-
ret = kstrtoint(buf, 10, &enable);
647-
if (ret || enable < 0 || enable > 1)
646+
if (kstrtobool(buf, &enable))
648647
return -EINVAL;
649648

650649
if (!cpufreq_driver->boost_enabled)

0 commit comments

Comments
 (0)