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

gpio: tz1090: 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: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+8 -9
+8 -9
drivers/gpio/gpio-tz1090.c
··· 62 62 int irq; 63 63 char label[16]; 64 64 }; 65 - #define to_bank(c) container_of(c, struct tz1090_gpio_bank, chip) 66 65 67 66 /** 68 67 * struct tz1090_gpio - Overall GPIO device private data ··· 186 187 static int tz1090_gpio_direction_input(struct gpio_chip *chip, 187 188 unsigned int offset) 188 189 { 189 - struct tz1090_gpio_bank *bank = to_bank(chip); 190 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 190 191 tz1090_gpio_set_bit(bank, REG_GPIO_DIR, offset); 191 192 192 193 return 0; ··· 195 196 static int tz1090_gpio_direction_output(struct gpio_chip *chip, 196 197 unsigned int offset, int output_value) 197 198 { 198 - struct tz1090_gpio_bank *bank = to_bank(chip); 199 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 199 200 int lstat; 200 201 201 202 __global_lock2(lstat); ··· 211 212 */ 212 213 static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) 213 214 { 214 - struct tz1090_gpio_bank *bank = to_bank(chip); 215 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 215 216 216 217 return !!tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); 217 218 } ··· 222 223 static void tz1090_gpio_set(struct gpio_chip *chip, unsigned int offset, 223 224 int output_value) 224 225 { 225 - struct tz1090_gpio_bank *bank = to_bank(chip); 226 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 226 227 227 228 tz1090_gpio_mod_bit(bank, REG_GPIO_DOUT, offset, output_value); 228 229 } 229 230 230 231 static int tz1090_gpio_request(struct gpio_chip *chip, unsigned int offset) 231 232 { 232 - struct tz1090_gpio_bank *bank = to_bank(chip); 233 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 233 234 int ret; 234 235 235 236 ret = pinctrl_request_gpio(chip->base + offset); ··· 244 245 245 246 static void tz1090_gpio_free(struct gpio_chip *chip, unsigned int offset) 246 247 { 247 - struct tz1090_gpio_bank *bank = to_bank(chip); 248 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 248 249 249 250 pinctrl_free_gpio(chip->base + offset); 250 251 ··· 253 254 254 255 static int tz1090_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) 255 256 { 256 - struct tz1090_gpio_bank *bank = to_bank(chip); 257 + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); 257 258 258 259 if (!bank->domain) 259 260 return -EINVAL; ··· 439 440 bank->chip.ngpio = 30; 440 441 441 442 /* Add the GPIO bank */ 442 - gpiochip_add(&bank->chip); 443 + gpiochip_add_data(&bank->chip, bank); 443 444 444 445 /* Get the GPIO bank IRQ if provided */ 445 446 bank->irq = irq_of_parse_and_map(np, 0);