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

gpio: mb86s7x: 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: Jassi Brar <jaswinder.singh@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+7 -12
+7 -12
drivers/gpio/gpio-mb86s7x.c
··· 44 44 spinlock_t lock; 45 45 }; 46 46 47 - static inline struct mb86s70_gpio_chip *chip_to_mb86s70(struct gpio_chip *gc) 48 - { 49 - return container_of(gc, struct mb86s70_gpio_chip, gc); 50 - } 51 - 52 47 static int mb86s70_gpio_request(struct gpio_chip *gc, unsigned gpio) 53 48 { 54 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 49 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 55 50 unsigned long flags; 56 51 u32 val; 57 52 ··· 68 73 69 74 static void mb86s70_gpio_free(struct gpio_chip *gc, unsigned gpio) 70 75 { 71 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 76 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 72 77 unsigned long flags; 73 78 u32 val; 74 79 ··· 83 88 84 89 static int mb86s70_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) 85 90 { 86 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 91 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 87 92 unsigned long flags; 88 93 unsigned char val; 89 94 ··· 101 106 static int mb86s70_gpio_direction_output(struct gpio_chip *gc, 102 107 unsigned gpio, int value) 103 108 { 104 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 109 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 105 110 unsigned long flags; 106 111 unsigned char val; 107 112 ··· 125 130 126 131 static int mb86s70_gpio_get(struct gpio_chip *gc, unsigned gpio) 127 132 { 128 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 133 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 129 134 130 135 return !!(readl(gchip->base + PDR(gpio)) & OFFSET(gpio)); 131 136 } 132 137 133 138 static void mb86s70_gpio_set(struct gpio_chip *gc, unsigned gpio, int value) 134 139 { 135 - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); 140 + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); 136 141 unsigned long flags; 137 142 unsigned char val; 138 143 ··· 187 192 188 193 platform_set_drvdata(pdev, gchip); 189 194 190 - ret = gpiochip_add(&gchip->gc); 195 + ret = gpiochip_add_data(&gchip->gc, gchip); 191 196 if (ret) { 192 197 dev_err(&pdev->dev, "couldn't register gpio driver\n"); 193 198 clk_disable_unprepare(gchip->clk);