linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer
@ 2015-12-09 13:16 Linus Walleij
  2015-12-13 12:49 ` Joachim Eastwood
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2015-12-09 13:16 UTC (permalink / raw)
  To: linux-gpio, Johan Hovold, Alexandre Courbot, Michael Welling,
	Markus Pargmann
  Cc: Linus Walleij, Joachim Eastwood

This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().

Cc: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Joachim: this driver looks very simplistic, it seems it can
be totally replaced with drivers/gpio/gpio-generic.c provided
that some (optional) clock handling is added to the generic GPIO
driver, if you have some time, please look into that.
---
 drivers/gpio/gpio-lpc18xx.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c
index b01fbc9db7cd..98832c9f614a 100644
--- a/drivers/gpio/gpio-lpc18xx.c
+++ b/drivers/gpio/gpio-lpc18xx.c
@@ -31,27 +31,22 @@ struct lpc18xx_gpio_chip {
 	spinlock_t lock;
 };
 
-static inline struct lpc18xx_gpio_chip *to_lpc18xx_gpio(struct gpio_chip *chip)
-{
-	return container_of(chip, struct lpc18xx_gpio_chip, gpio);
-}
-
 static void lpc18xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-	struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip);
+	struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip);
 	writeb(value ? 1 : 0, gc->base + offset);
 }
 
 static int lpc18xx_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-	struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip);
+	struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip);
 	return !!readb(gc->base + offset);
 }
 
 static int lpc18xx_gpio_direction(struct gpio_chip *chip, unsigned offset,
 				  bool out)
 {
-	struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip);
+	struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip);
 	unsigned long flags;
 	u32 port, pin, dir;
 
@@ -129,7 +124,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
 
 	gc->gpio.parent = &pdev->dev;
 
-	ret = gpiochip_add(&gc->gpio);
+	ret = gpiochip_add_data(&gc->gpio, gc);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add gpio chip\n");
 		clk_disable_unprepare(gc->clk);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer
  2015-12-09 13:16 [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer Linus Walleij
@ 2015-12-13 12:49 ` Joachim Eastwood
  2015-12-15 12:58   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Joachim Eastwood @ 2015-12-13 12:49 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, Johan Hovold, Alexandre Courbot, Michael Welling,
	Markus Pargmann

On 9 December 2015 at 14:16, Linus Walleij <linus.walleij@linaro.org> wrote:
> This makes the driver use the data pointer added to the gpio_chip
> to store a pointer to the state container instead of relying on
> container_of().
>
> Cc: Joachim Eastwood <manabian@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Joachim Eastwood <manabian@gmail.com>


> Joachim: this driver looks very simplistic, it seems it can
> be totally replaced with drivers/gpio/gpio-generic.c provided
> that some (optional) clock handling is added to the generic GPIO
> driver, if you have some time, please look into that.

I don't think gpio-generic supports one big gpio namespace of 256
gpios which this driver uses.


regards,
Joachim Eastwood

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer
  2015-12-13 12:49 ` Joachim Eastwood
@ 2015-12-15 12:58   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-12-15 12:58 UTC (permalink / raw)
  To: Joachim Eastwood
  Cc: linux-gpio@vger.kernel.org, Johan Hovold, Alexandre Courbot,
	Michael Welling, Markus Pargmann

On Sun, Dec 13, 2015 at 1:49 PM, Joachim  Eastwood <manabian@gmail.com> wrote:
> On 9 December 2015 at 14:16, Linus Walleij <linus.walleij@linaro.org> wrote:

> Acked-by: Joachim Eastwood <manabian@gmail.com>

Thx.

>> Joachim: this driver looks very simplistic, it seems it can
>> be totally replaced with drivers/gpio/gpio-generic.c provided
>> that some (optional) clock handling is added to the generic GPIO
>> driver, if you have some time, please look into that.
>
> I don't think gpio-generic supports one big gpio namespace of 256
> gpios which this driver uses.

No just 8, 16 or 32 simple registers, OK. (Maybe we could make
it more generic but it seems like overkill.)

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-15 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 13:16 [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer Linus Walleij
2015-12-13 12:49 ` Joachim Eastwood
2015-12-15 12:58   ` 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).