[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181012061136.11421-1-ricardo.ribalda@gmail.com>
Date: Fri, 12 Oct 2018 08:11:36 +0200
From: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
To: Vignesh R <vigneshr@...com>, Jeffrey Hugo <jhugo@...eaurora.org>,
Linus Walleij <linus.walleij@...aro.org>,
Timur Tabi <timur@...nel.org>,
Stephen Boyd <swboyd@...omium.org>,
linux-gpio <linux-gpio@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Subject: [PATCH] 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@...com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
---
drivers/gpio/gpiolib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e016b22658ff..bcd0ef49ce97 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1349,6 +1349,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
@@ -1380,8 +1383,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;
--
2.19.1
Powered by blists - more mailing lists