[PATCH] gpiolib: use gpiochip_get_desc() where applicable

From: Bartosz Golaszewski
Date: Wed Feb 19 2020 - 04:47:08 EST


From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>

Whenever retrieving a descriptor from a gpiochip: use the provided
helper which checks for errors.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
---
drivers/gpio/gpiolib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4d0106ceeba7..5c761a738065 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2953,7 +2953,9 @@ const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
if (offset >= chip->ngpio)
return NULL;

- desc = &chip->gpiodev->descs[offset];
+ desc = gpiochip_get_desc(chip, offset);
+ if (IS_ERR(desc))
+ return NULL;

if (test_bit(FLAG_REQUESTED, &desc->flags) == 0)
return NULL;
--
2.25.0