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: 3edfb7bd76 ("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>
This commit is contained in:
Ricardo Ribalda Delgado 2018-10-12 08:11:36 +02:00 коммит произвёл Linus Walleij
Родитель 7a42781eee
Коммит 767cd17a5c
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -1351,6 +1351,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags);
for (i = 0; i < chip->ngpio; i++)
gdev->descs[i].gdev = gdev;
#ifdef CONFIG_PINCTRL #ifdef CONFIG_PINCTRL
INIT_LIST_HEAD(&gdev->pin_ranges); INIT_LIST_HEAD(&gdev->pin_ranges);
#endif #endif
@ -1382,8 +1385,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
for (i = 0; i < chip->ngpio; i++) { for (i = 0; i < chip->ngpio; i++) {
struct gpio_desc *desc = &gdev->descs[i]; struct gpio_desc *desc = &gdev->descs[i];
desc->gdev = gdev;
if (chip->get_direction && gpiochip_line_is_valid(chip, i)) if (chip->get_direction && gpiochip_line_is_valid(chip, i))
desc->flags = !chip->get_direction(chip, i) ? desc->flags = !chip->get_direction(chip, i) ?
(1 << FLAG_IS_OUT) : 0; (1 << FLAG_IS_OUT) : 0;