From: Alexandre Courbot Date: Tue, 3 Dec 2013 03:31:11 +0000 (+0900) Subject: gpio: rewrite gpiochip_offset_to_desc() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b7d0a28a9f65c4f8a547ceece820b8167a854968;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git gpio: rewrite gpiochip_offset_to_desc() gpiochip_offset_to_desc() was using gpio_to_desc(), which directly addresses the global GPIO array we are hoping to get rid of someday. Reimplement it using the descriptor array of the chip itself, after checking the requested offset is within the valid bounds of the chip. Signed-off-by: Alexandre Courbot Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4e10b10d3ddd..c6326e44e2c0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -150,9 +150,10 @@ EXPORT_SYMBOL_GPL(gpio_to_desc); static struct gpio_desc *gpiochip_offset_to_desc(struct gpio_chip *chip, unsigned int offset) { - unsigned int gpio = chip->base + offset; + if (offset >= chip->ngpio) + return ERR_PTR(-EINVAL); - return gpio_to_desc(gpio); + return &chip->desc[offset]; } /**