gpio: 74x164: use gpiochip data pointer
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 3 Dec 2015 17:20:29 +0000 (18:20 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 5 Jan 2016 10:21:01 +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().

Cc: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-74x164.c

index 54a4147fba52f2f7811a5e30f85ac239b3716aa1..c81224ff2dca988b69eaf54296713aad225f6935 100644 (file)
@@ -33,11 +33,6 @@ struct gen_74x164_chip {
        u8                      buffer[0];
 };
 
-static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc)
-{
-       return container_of(gc, struct gen_74x164_chip, gpio_chip);
-}
-
 static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
 {
        struct spi_transfer xfer = {
@@ -51,7 +46,7 @@ static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
 
 static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset)
 {
-       struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc);
+       struct gen_74x164_chip *chip = gpiochip_get_data(gc);
        u8 bank = chip->registers - 1 - offset / 8;
        u8 pin = offset % 8;
        int ret;
@@ -66,7 +61,7 @@ static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset)
 static void gen_74x164_set_value(struct gpio_chip *gc,
                unsigned offset, int val)
 {
-       struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc);
+       struct gen_74x164_chip *chip = gpiochip_get_data(gc);
        u8 bank = chip->registers - 1 - offset / 8;
        u8 pin = offset % 8;
 
@@ -136,7 +131,7 @@ static int gen_74x164_probe(struct spi_device *spi)
                goto exit_destroy;
        }
 
-       ret = gpiochip_add(&chip->gpio_chip);
+       ret = gpiochip_add_data(&chip->gpio_chip, chip);
        if (!ret)
                return 0;
 
This page took 0.025706 seconds and 5 git commands to generate.