Skip to content

Commit

Permalink
params.c: Use new strtobool function to process boolean inputs
Browse files Browse the repository at this point in the history
No functional changes.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Apr 25, 2011
1 parent 8705b48 commit e7e09cd
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions kernel/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,15 @@ EXPORT_SYMBOL(param_ops_charp);
int param_set_bool(const char *val, const struct kernel_param *kp)
{
bool v;
int ret;

/* No equals means "set"... */
if (!val) val = "1";

/* One of =[yYnN01] */
switch (val[0]) {
case 'y': case 'Y': case '1':
v = true;
break;
case 'n': case 'N': case '0':
v = false;
break;
default:
return -EINVAL;
}
ret = strtobool(val, &v);
if (ret)
return ret;

if (kp->flags & KPARAM_ISBOOL)
*(bool *)kp->arg = v;
Expand Down

0 comments on commit e7e09cd

Please sign in to comment.