Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcma: gpio: use gpiochip data pointer

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: Kalle Valo <kvalo@codeaurora.org>
Cc: linux-wireless@vger.kernel.org
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+9 -14
+9 -14
drivers/bcma/driver_gpio.c
··· 17 17 18 18 #define BCMA_GPIO_MAX_PINS 32 19 19 20 - static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip) 21 - { 22 - return container_of(chip, struct bcma_drv_cc, gpio); 23 - } 24 - 25 20 static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio) 26 21 { 27 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 22 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 28 23 29 24 return !!bcma_chipco_gpio_in(cc, 1 << gpio); 30 25 } ··· 27 32 static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio, 28 33 int value) 29 34 { 30 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 35 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 31 36 32 37 bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); 33 38 } 34 39 35 40 static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) 36 41 { 37 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 42 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 38 43 39 44 bcma_chipco_gpio_outen(cc, 1 << gpio, 0); 40 45 return 0; ··· 43 48 static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, 44 49 int value) 45 50 { 46 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 51 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 47 52 48 53 bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio); 49 54 bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); ··· 52 57 53 58 static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio) 54 59 { 55 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 60 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 56 61 57 62 bcma_chipco_gpio_control(cc, 1 << gpio, 0); 58 63 /* clear pulldown */ ··· 65 70 66 71 static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio) 67 72 { 68 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); 73 + struct bcma_drv_cc *cc = gpiochip_get_data(chip); 69 74 70 75 /* clear pullup */ 71 76 bcma_chipco_gpio_pullup(cc, 1 << gpio, 0); ··· 76 81 static void bcma_gpio_irq_unmask(struct irq_data *d) 77 82 { 78 83 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 79 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(gc); 84 + struct bcma_drv_cc *cc = gpiochip_get_data(gc); 80 85 int gpio = irqd_to_hwirq(d); 81 86 u32 val = bcma_chipco_gpio_in(cc, BIT(gpio)); 82 87 ··· 87 92 static void bcma_gpio_irq_mask(struct irq_data *d) 88 93 { 89 94 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 90 - struct bcma_drv_cc *cc = bcma_gpio_get_cc(gc); 95 + struct bcma_drv_cc *cc = gpiochip_get_data(gc); 91 96 int gpio = irqd_to_hwirq(d); 92 97 93 98 bcma_chipco_gpio_intmask(cc, BIT(gpio), 0); ··· 211 216 else 212 217 chip->base = -1; 213 218 214 - err = gpiochip_add(chip); 219 + err = gpiochip_add_data(chip, cc); 215 220 if (err) 216 221 return err; 217 222