diff options
author | Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> | 2018-10-12 08:11:36 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-10-12 10:16:19 +0200 |
commit | 767cd17a5cc5ce2d5342f5c4bd6c5d36b812c7a7 (patch) | |
tree | 0e1b37573371c0b95530021f3f6f9fb8ab2e7fc3 /drivers/gpio/gpiolib.c | |
parent | 7a42781eee87e45c378e71688824da137a7afbf7 (diff) | |
download | linux-stable-767cd17a5cc5ce2d5342f5c4bd6c5d36b812c7a7.tar.gz linux-stable-767cd17a5cc5ce2d5342f5c4bd6c5d36b812c7a7.tar.bz2 linux-stable-767cd17a5cc5ce2d5342f5c4bd6c5d36b812c7a7.zip |
gpiolib: Initialize gdev field before is used
gpio_hog depends on gdev field being initialized. This patch fixes an
OOPs during initialization of TI's AM335x-ICEv2.
Fixes: 3edfb7bd76bd1cba ("gpiolib: Show correct direction from the beginning")
Tested-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 76ade1a7cf43..1a283fbac84c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1351,6 +1351,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, spin_unlock_irqrestore(&gpio_lock, flags); + for (i = 0; i < chip->ngpio; i++) + gdev->descs[i].gdev = gdev; + #ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&gdev->pin_ranges); #endif @@ -1382,8 +1385,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, for (i = 0; i < chip->ngpio; i++) { struct gpio_desc *desc = &gdev->descs[i]; - desc->gdev = gdev; - if (chip->get_direction && gpiochip_line_is_valid(chip, i)) desc->flags = !chip->get_direction(chip, i) ? (1 << FLAG_IS_OUT) : 0; |