]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
input: adp5588-keys: use gpiochip data pointer
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 8 Dec 2015 15:29:50 +0000 (16:29 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 26 Apr 2016 13:33:44 +0000 (15:33 +0200)
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: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/input/keyboard/adp5588-keys.c

index 21a62d0fa764806323927d8cfd1366b1c53bf259..53fe9a3fb6204d6114c7cd03f27ed87a1c7f3d92 100644 (file)
@@ -73,7 +73,7 @@ static int adp5588_write(struct i2c_client *client, u8 reg, u8 val)
 #ifdef CONFIG_GPIOLIB
 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
 {
-       struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
+       struct adp5588_kpad *kpad = gpiochip_get_data(chip);
        unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
        unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
        int val;
@@ -93,7 +93,7 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
 static void adp5588_gpio_set_value(struct gpio_chip *chip,
                                   unsigned off, int val)
 {
-       struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
+       struct adp5588_kpad *kpad = gpiochip_get_data(chip);
        unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
        unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
 
@@ -112,7 +112,7 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
 
 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off)
 {
-       struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
+       struct adp5588_kpad *kpad = gpiochip_get_data(chip);
        unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
        unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
        int ret;
@@ -130,7 +130,7 @@ static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off)
 static int adp5588_gpio_direction_output(struct gpio_chip *chip,
                                         unsigned off, int val)
 {
-       struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
+       struct adp5588_kpad *kpad = gpiochip_get_data(chip);
        unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
        unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
        int ret;
@@ -210,7 +210,7 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad)
 
        mutex_init(&kpad->gpio_lock);
 
-       error = gpiochip_add(&kpad->gc);
+       error = gpiochip_add_data(&kpad->gc, kpad);
        if (error) {
                dev_err(dev, "gpiochip_add failed, err: %d\n", error);
                return error;