gpio: aspeed: Don't attempt to debounce if disabled
authorJoel Stanley <joel@jms.id.au>
Tue, 2 May 2017 06:08:24 +0000 (15:38 +0930)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 22 May 2017 08:37:07 +0000 (10:37 +0200)
We warn the user at driver probe time that debouncing is disabled.
However, if they request debouncing later on we print a confusing error
message:

 gpio_aspeed 1e780000.gpio: Failed to convert 5000us to cycles at 0Hz: -524

Instead bail out when the clock is not present.

Fixes: 5ae4cb94b3133 (gpio: aspeed: Add debounce support)
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-aspeed.c

index ccea609676eebfe8bbcd6e01acaa8f6c4499ffe7..4ca436e66bdb24f674280dd51a459a3d90809457 100644 (file)
@@ -646,6 +646,9 @@ static int enable_debounce(struct gpio_chip *chip, unsigned int offset,
        int rc;
        int i;
 
+       if (!gpio->clk)
+               return -EINVAL;
+
        rc = usecs_to_cycles(gpio, usecs, &requested_cycles);
        if (rc < 0) {
                dev_warn(chip->parent, "Failed to convert %luus to cycles at %luHz: %d\n",