gpio: 104-idi-48: use gpiochip data pointer
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 3 Dec 2015 14:31:48 +0000 (15:31 +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().

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-104-idi-48.c

index 296dbd4cadd979541705ada78fc2db8c96094c86..52eed328ce99ab226f9c70d942692eeca739f299 100644 (file)
@@ -64,14 +64,9 @@ static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
        return 0;
 }
 
-static struct idi_48_gpio *to_idi48gpio(struct gpio_chip *gc)
-{
-       return container_of(gc, struct idi_48_gpio, chip);
-}
-
 static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-       struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip);
+       struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip);
        unsigned i;
        const unsigned register_offset[6] = { 0, 1, 2, 4, 5, 6 };
        unsigned base_offset;
@@ -96,7 +91,7 @@ static void idi_48_irq_ack(struct irq_data *data)
 static void idi_48_irq_mask(struct irq_data *data)
 {
        struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
-       struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip);
+       struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip);
        const unsigned offset = irqd_to_hwirq(data);
        unsigned i;
        unsigned mask;
@@ -127,7 +122,7 @@ static void idi_48_irq_mask(struct irq_data *data)
 static void idi_48_irq_unmask(struct irq_data *data)
 {
        struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
-       struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip);
+       struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip);
        const unsigned offset = irqd_to_hwirq(data);
        unsigned i;
        unsigned mask;
@@ -255,7 +250,7 @@ static int __init idi_48_probe(struct platform_device *pdev)
 
        dev_set_drvdata(dev, idi48gpio);
 
-       err = gpiochip_add(&idi48gpio->chip);
+       err = gpiochip_add_data(&idi48gpio->chip, idi48gpio);
        if (err) {
                dev_err(dev, "GPIO registering failed (%d)\n", err);
                goto err_gpio_register;
This page took 0.025716 seconds and 5 git commands to generate.