Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kstrtox: add support for enabled and disabled in kstrtobool()

In some places in the kernel there is a design pattern for sysfs
attributes to use kstrtobool() in store() and str_enabled_disabled() in
show().

This is counterintuitive to interact with because kstrtobool() takes
on/off but str_enabled_disabled() shows enabled/disabled. Some of those
sysfs uses could switch to str_on_off() but for some attributes
enabled/disabled really makes more sense.

Add support for kstrtobool() to accept enabled/disabled.

Link: https://lkml.kernel.org/r/20250321022538.1532445-1-superm1@kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mario Limonciello and committed by
Andrew Morton
ae5b3500 029c896c

+4
+4
lib/kstrtox.c
··· 351 351 return -EINVAL; 352 352 353 353 switch (s[0]) { 354 + case 'e': 355 + case 'E': 354 356 case 'y': 355 357 case 'Y': 356 358 case 't': ··· 360 358 case '1': 361 359 *res = true; 362 360 return 0; 361 + case 'd': 362 + case 'D': 363 363 case 'n': 364 364 case 'N': 365 365 case 'f':