]> git.karo-electronics.de Git - linux-beck.git/commitdiff
gpio: ts5500: use gpiochip data pointer
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 7 Dec 2015 13:52:55 +0000 (14:52 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 5 Jan 2016 10:21:16 +0000 (11:21 +0100)
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().

Acked-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-ts5500.c

index aafe7910e030bdbf63d640e73a57c7c5e8cbf998..5f945083f9d8c8f699fce925fe403e4ed54f626c 100644 (file)
@@ -185,11 +185,6 @@ static const struct ts5500_dio ts5500_lcd[] = {
        TS5500_DIO_IN_IRQ(0x73, 7, 1),
 };
 
-static inline struct ts5500_priv *ts5500_gc_to_priv(struct gpio_chip *chip)
-{
-       return container_of(chip, struct ts5500_priv, gpio_chip);
-}
-
 static inline void ts5500_set_mask(u8 mask, u8 addr)
 {
        u8 val = inb(addr);
@@ -206,7 +201,7 @@ static inline void ts5500_clear_mask(u8 mask, u8 addr)
 
 static int ts5500_gpio_input(struct gpio_chip *chip, unsigned offset)
 {
-       struct ts5500_priv *priv = ts5500_gc_to_priv(chip);
+       struct ts5500_priv *priv = gpiochip_get_data(chip);
        const struct ts5500_dio line = priv->pinout[offset];
        unsigned long flags;
 
@@ -225,7 +220,7 @@ static int ts5500_gpio_input(struct gpio_chip *chip, unsigned offset)
 
 static int ts5500_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-       struct ts5500_priv *priv = ts5500_gc_to_priv(chip);
+       struct ts5500_priv *priv = gpiochip_get_data(chip);
        const struct ts5500_dio line = priv->pinout[offset];
 
        return !!(inb(line.value_addr) & line.value_mask);
@@ -233,7 +228,7 @@ static int ts5500_gpio_get(struct gpio_chip *chip, unsigned offset)
 
 static int ts5500_gpio_output(struct gpio_chip *chip, unsigned offset, int val)
 {
-       struct ts5500_priv *priv = ts5500_gc_to_priv(chip);
+       struct ts5500_priv *priv = gpiochip_get_data(chip);
        const struct ts5500_dio line = priv->pinout[offset];
        unsigned long flags;
 
@@ -255,7 +250,7 @@ static int ts5500_gpio_output(struct gpio_chip *chip, unsigned offset, int val)
 
 static void ts5500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
 {
-       struct ts5500_priv *priv = ts5500_gc_to_priv(chip);
+       struct ts5500_priv *priv = gpiochip_get_data(chip);
        const struct ts5500_dio line = priv->pinout[offset];
        unsigned long flags;
 
@@ -269,7 +264,7 @@ static void ts5500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
 
 static int ts5500_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-       struct ts5500_priv *priv = ts5500_gc_to_priv(chip);
+       struct ts5500_priv *priv = gpiochip_get_data(chip);
        const struct ts5500_dio *block = priv->pinout;
        const struct ts5500_dio line = block[offset];
 
@@ -414,7 +409,7 @@ static int ts5500_dio_probe(struct platform_device *pdev)
                break;
        }
 
-       ret = gpiochip_add(&priv->gpio_chip);
+       ret = gpiochip_add_data(&priv->gpio_chip, priv);
        if (ret) {
                dev_err(dev, "failed to register the gpio chip\n");
                return ret;