]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gpio: mockup: parse the module params in init, not probe
authorBartosz Golaszewski <brgl@bgdev.pl>
Mon, 27 Nov 2017 10:48:38 +0000 (11:48 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 2 Dec 2017 21:42:23 +0000 (22:42 +0100)
If the module parameters are invalid, we should bail out from the init
function instead of detecting it during the device probe. That way we
don't even allow the user to load the module if we don't accept the
arguments.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mockup.c

index d21c6d651287682967b376e27364b9bb3c5b0c40..b70f3b0c30b1d9e42a8017dbb16fb30223eee91b 100644 (file)
@@ -275,9 +275,6 @@ static int gpio_mockup_probe(struct platform_device *pdev)
        struct gpio_mockup_chip *chips;
        char *chip_name;
 
-       if (gpio_mockup_params_nr < 2 || (gpio_mockup_params_nr % 2))
-               return -EINVAL;
-
        /* Each chip is described by two values. */
        num_chips = gpio_mockup_params_nr / 2;
 
@@ -333,6 +330,9 @@ static int __init gpio_mockup_init(void)
 {
        int err;
 
+       if (gpio_mockup_params_nr < 2 || (gpio_mockup_params_nr % 2))
+               return -EINVAL;
+
        gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup-event", NULL);
        if (!gpio_mockup_dbg_dir)
                pr_err("%s: error creating debugfs directory\n",