gpio: lpc18xx: use gpiochip data pointer
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 7 Dec 2015 08:13:57 +0000 (09:13 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 5 Jan 2016 10:21:06 +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: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-lpc18xx.c

index b01fbc9db7cdcd12acc349d04376364133ef49aa..98832c9f614a26e59e78aee6509a92506e1d3115 100644 (file)
@@ -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);
This page took 0.025491 seconds and 5 git commands to generate.