Skip to content

Commit

Permalink
gpio: mockup: parse the module params in init, not probe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bartosz Golaszewski authored and Linus Walleij committed Dec 2, 2017
1 parent f3b4717 commit 20c35ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpio/gpio-mockup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 20c35ac

Please sign in to comment.