* [PATCH] gpio: rewrite gpiochip_offset_to_desc()
@ 2013-12-03 3:31 Alexandre Courbot
2013-12-04 12:46 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Courbot @ 2013-12-03 3:31 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Alexandre Courbot
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 <acourbot@nvidia.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 4ca103965d8c..ea95b42c6154 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];
}
/**
--
1.8.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: rewrite gpiochip_offset_to_desc()
2013-12-03 3:31 [PATCH] gpio: rewrite gpiochip_offset_to_desc() Alexandre Courbot
@ 2013-12-04 12:46 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2013-12-04 12:46 UTC (permalink / raw)
To: Alexandre Courbot
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
On Tue, Dec 3, 2013 at 4:31 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> 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 <acourbot@nvidia.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-04 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 3:31 [PATCH] gpio: rewrite gpiochip_offset_to_desc() Alexandre Courbot
2013-12-04 12:46 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).