params.c: Use new strtobool function to process boolean inputs
authorJonathan Cameron <jic23@cam.ac.uk>
Tue, 19 Apr 2011 11:43:47 +0000 (12:43 +0100)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 19 May 2011 07:25:28 +0000 (16:55 +0930)
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
kernel/params.c

index 28c5d5c83f6b7decfa6671271659425b9a900ebb..ed72e1330862d265e4276669830ec3f6b26c7d0d 100644 (file)
@@ -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;