params.c: Use new strtobool function to process boolean inputs
No functional changes. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
8705b48e71
Коммит
e7e09cd667
|
@ -297,21 +297,15 @@ EXPORT_SYMBOL(param_ops_charp);
|
||||||
int param_set_bool(const char *val, const struct kernel_param *kp)
|
int param_set_bool(const char *val, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
bool v;
|
bool v;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* No equals means "set"... */
|
/* No equals means "set"... */
|
||||||
if (!val) val = "1";
|
if (!val) val = "1";
|
||||||
|
|
||||||
/* One of =[yYnN01] */
|
/* One of =[yYnN01] */
|
||||||
switch (val[0]) {
|
ret = strtobool(val, &v);
|
||||||
case 'y': case 'Y': case '1':
|
if (ret)
|
||||||
v = true;
|
return ret;
|
||||||
break;
|
|
||||||
case 'n': case 'N': case '0':
|
|
||||||
v = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kp->flags & KPARAM_ISBOOL)
|
if (kp->flags & KPARAM_ISBOOL)
|
||||||
*(bool *)kp->arg = v;
|
*(bool *)kp->arg = v;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче