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

gpio: ath79: 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().

Acked-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+7 -9
+7 -9
drivers/gpio/gpio-ath79.c
··· 24 24 spinlock_t lock; 25 25 }; 26 26 27 - #define to_ath79_gpio_ctrl(c) container_of(c, struct ath79_gpio_ctrl, chip) 28 - 29 27 static void ath79_gpio_set_value(struct gpio_chip *chip, 30 28 unsigned gpio, int value) 31 29 { 32 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 30 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 33 31 34 32 if (value) 35 33 __raw_writel(BIT(gpio), ctrl->base + AR71XX_GPIO_REG_SET); ··· 37 39 38 40 static int ath79_gpio_get_value(struct gpio_chip *chip, unsigned gpio) 39 41 { 40 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 42 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 41 43 42 44 return (__raw_readl(ctrl->base + AR71XX_GPIO_REG_IN) >> gpio) & 1; 43 45 } ··· 45 47 static int ath79_gpio_direction_input(struct gpio_chip *chip, 46 48 unsigned offset) 47 49 { 48 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 50 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 49 51 unsigned long flags; 50 52 51 53 spin_lock_irqsave(&ctrl->lock, flags); ··· 62 64 static int ath79_gpio_direction_output(struct gpio_chip *chip, 63 65 unsigned offset, int value) 64 66 { 65 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 67 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 66 68 unsigned long flags; 67 69 68 70 spin_lock_irqsave(&ctrl->lock, flags); ··· 83 85 84 86 static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 85 87 { 86 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 88 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 87 89 unsigned long flags; 88 90 89 91 spin_lock_irqsave(&ctrl->lock, flags); ··· 100 102 static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, 101 103 int value) 102 104 { 103 - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); 105 + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); 104 106 unsigned long flags; 105 107 106 108 spin_lock_irqsave(&ctrl->lock, flags); ··· 182 184 ctrl->chip.direction_output = ar934x_gpio_direction_output; 183 185 } 184 186 185 - err = gpiochip_add(&ctrl->chip); 187 + err = gpiochip_add_data(&ctrl->chip, ctrl); 186 188 if (err) { 187 189 dev_err(&pdev->dev, 188 190 "cannot add AR71xx GPIO chip, error=%d", err);