diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-04 08:56:15 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 05:21:01 -0500 |
commit | 1e69c4fe2a67a63e6b392338dd01627ee26f9ca3 (patch) | |
tree | 9a64d73a90e9209835e6967c7291659140c3b6c4 | |
parent | b2afc6f3522c8f49a420cb77f5a9c51fe1d50e33 (diff) |
gpio: adnp: 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().
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-adnp.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index b8a1ac133390..fb5b47b69f14 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c | |||
@@ -36,11 +36,6 @@ struct adnp { | |||
36 | u8 *irq_low; | 36 | u8 *irq_low; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static inline struct adnp *to_adnp(struct gpio_chip *chip) | ||
40 | { | ||
41 | return container_of(chip, struct adnp, gpio); | ||
42 | } | ||
43 | |||
44 | static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value) | 39 | static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value) |
45 | { | 40 | { |
46 | int err; | 41 | int err; |
@@ -72,7 +67,7 @@ static int adnp_write(struct adnp *adnp, unsigned offset, uint8_t value) | |||
72 | 67 | ||
73 | static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset) | 68 | static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset) |
74 | { | 69 | { |
75 | struct adnp *adnp = to_adnp(chip); | 70 | struct adnp *adnp = gpiochip_get_data(chip); |
76 | unsigned int reg = offset >> adnp->reg_shift; | 71 | unsigned int reg = offset >> adnp->reg_shift; |
77 | unsigned int pos = offset & 7; | 72 | unsigned int pos = offset & 7; |
78 | u8 value; | 73 | u8 value; |
@@ -106,7 +101,7 @@ static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value) | |||
106 | 101 | ||
107 | static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 102 | static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
108 | { | 103 | { |
109 | struct adnp *adnp = to_adnp(chip); | 104 | struct adnp *adnp = gpiochip_get_data(chip); |
110 | 105 | ||
111 | mutex_lock(&adnp->i2c_lock); | 106 | mutex_lock(&adnp->i2c_lock); |
112 | __adnp_gpio_set(adnp, offset, value); | 107 | __adnp_gpio_set(adnp, offset, value); |
@@ -115,7 +110,7 @@ static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
115 | 110 | ||
116 | static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | 111 | static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) |
117 | { | 112 | { |
118 | struct adnp *adnp = to_adnp(chip); | 113 | struct adnp *adnp = gpiochip_get_data(chip); |
119 | unsigned int reg = offset >> adnp->reg_shift; | 114 | unsigned int reg = offset >> adnp->reg_shift; |
120 | unsigned int pos = offset & 7; | 115 | unsigned int pos = offset & 7; |
121 | u8 value; | 116 | u8 value; |
@@ -150,7 +145,7 @@ out: | |||
150 | static int adnp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | 145 | static int adnp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, |
151 | int value) | 146 | int value) |
152 | { | 147 | { |
153 | struct adnp *adnp = to_adnp(chip); | 148 | struct adnp *adnp = gpiochip_get_data(chip); |
154 | unsigned int reg = offset >> adnp->reg_shift; | 149 | unsigned int reg = offset >> adnp->reg_shift; |
155 | unsigned int pos = offset & 7; | 150 | unsigned int pos = offset & 7; |
156 | int err; | 151 | int err; |
@@ -187,7 +182,7 @@ out: | |||
187 | 182 | ||
188 | static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | 183 | static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
189 | { | 184 | { |
190 | struct adnp *adnp = to_adnp(chip); | 185 | struct adnp *adnp = gpiochip_get_data(chip); |
191 | unsigned int num_regs = 1 << adnp->reg_shift, i, j; | 186 | unsigned int num_regs = 1 << adnp->reg_shift, i, j; |
192 | int err; | 187 | int err; |
193 | 188 | ||
@@ -270,7 +265,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios) | |||
270 | chip->of_node = chip->parent->of_node; | 265 | chip->of_node = chip->parent->of_node; |
271 | chip->owner = THIS_MODULE; | 266 | chip->owner = THIS_MODULE; |
272 | 267 | ||
273 | err = gpiochip_add(chip); | 268 | err = gpiochip_add_data(chip, adnp); |
274 | if (err) | 269 | if (err) |
275 | return err; | 270 | return err; |
276 | 271 | ||
@@ -340,7 +335,7 @@ static irqreturn_t adnp_irq(int irq, void *data) | |||
340 | static void adnp_irq_mask(struct irq_data *d) | 335 | static void adnp_irq_mask(struct irq_data *d) |
341 | { | 336 | { |
342 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 337 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
343 | struct adnp *adnp = to_adnp(gc); | 338 | struct adnp *adnp = gpiochip_get_data(gc); |
344 | unsigned int reg = d->hwirq >> adnp->reg_shift; | 339 | unsigned int reg = d->hwirq >> adnp->reg_shift; |
345 | unsigned int pos = d->hwirq & 7; | 340 | unsigned int pos = d->hwirq & 7; |
346 | 341 | ||
@@ -350,7 +345,7 @@ static void adnp_irq_mask(struct irq_data *d) | |||
350 | static void adnp_irq_unmask(struct irq_data *d) | 345 | static void adnp_irq_unmask(struct irq_data *d) |
351 | { | 346 | { |
352 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 347 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
353 | struct adnp *adnp = to_adnp(gc); | 348 | struct adnp *adnp = gpiochip_get_data(gc); |
354 | unsigned int reg = d->hwirq >> adnp->reg_shift; | 349 | unsigned int reg = d->hwirq >> adnp->reg_shift; |
355 | unsigned int pos = d->hwirq & 7; | 350 | unsigned int pos = d->hwirq & 7; |
356 | 351 | ||
@@ -360,7 +355,7 @@ static void adnp_irq_unmask(struct irq_data *d) | |||
360 | static int adnp_irq_set_type(struct irq_data *d, unsigned int type) | 355 | static int adnp_irq_set_type(struct irq_data *d, unsigned int type) |
361 | { | 356 | { |
362 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 357 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
363 | struct adnp *adnp = to_adnp(gc); | 358 | struct adnp *adnp = gpiochip_get_data(gc); |
364 | unsigned int reg = d->hwirq >> adnp->reg_shift; | 359 | unsigned int reg = d->hwirq >> adnp->reg_shift; |
365 | unsigned int pos = d->hwirq & 7; | 360 | unsigned int pos = d->hwirq & 7; |
366 | 361 | ||
@@ -390,7 +385,7 @@ static int adnp_irq_set_type(struct irq_data *d, unsigned int type) | |||
390 | static void adnp_irq_bus_lock(struct irq_data *d) | 385 | static void adnp_irq_bus_lock(struct irq_data *d) |
391 | { | 386 | { |
392 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 387 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
393 | struct adnp *adnp = to_adnp(gc); | 388 | struct adnp *adnp = gpiochip_get_data(gc); |
394 | 389 | ||
395 | mutex_lock(&adnp->irq_lock); | 390 | mutex_lock(&adnp->irq_lock); |
396 | } | 391 | } |
@@ -398,7 +393,7 @@ static void adnp_irq_bus_lock(struct irq_data *d) | |||
398 | static void adnp_irq_bus_unlock(struct irq_data *d) | 393 | static void adnp_irq_bus_unlock(struct irq_data *d) |
399 | { | 394 | { |
400 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 395 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
401 | struct adnp *adnp = to_adnp(gc); | 396 | struct adnp *adnp = gpiochip_get_data(gc); |
402 | unsigned int num_regs = 1 << adnp->reg_shift, i; | 397 | unsigned int num_regs = 1 << adnp->reg_shift, i; |
403 | 398 | ||
404 | mutex_lock(&adnp->i2c_lock); | 399 | mutex_lock(&adnp->i2c_lock); |