aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-08 04:24:54 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 08:15:04 -0500
commit7cb093c4bce3a145cc1586d4464cd362376c2cc6 (patch)
tree2045bff455e05a819aa7e4b20cd34c2199784494
parent88057d6e4a2a9c221bf81cfd18f25d0ff956af9e (diff)
pinctrl: sh-pfc: 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: Geert Uytterhoeven <geert+renesas@glider.be> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/sh-pfc/gpio.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index cdb2460a7b00..a6681b8b17c3 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -38,14 +38,10 @@ struct sh_pfc_chip {
38 struct sh_pfc_gpio_pin *pins; 38 struct sh_pfc_gpio_pin *pins;
39}; 39};
40 40
41static struct sh_pfc_chip *gpio_to_pfc_chip(struct gpio_chip *gc)
42{
43 return container_of(gc, struct sh_pfc_chip, gpio_chip);
44}
45
46static struct sh_pfc *gpio_to_pfc(struct gpio_chip *gc) 41static struct sh_pfc *gpio_to_pfc(struct gpio_chip *gc)
47{ 42{
48 return gpio_to_pfc_chip(gc)->pfc; 43 struct sh_pfc_chip *chip = gpiochip_get_data(gc);
44 return chip->pfc;
49} 45}
50 46
51static void gpio_get_data_reg(struct sh_pfc_chip *chip, unsigned int offset, 47static void gpio_get_data_reg(struct sh_pfc_chip *chip, unsigned int offset,
@@ -178,14 +174,14 @@ static int gpio_pin_direction_input(struct gpio_chip *gc, unsigned offset)
178static int gpio_pin_direction_output(struct gpio_chip *gc, unsigned offset, 174static int gpio_pin_direction_output(struct gpio_chip *gc, unsigned offset,
179 int value) 175 int value)
180{ 176{
181 gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value); 177 gpio_pin_set_value(gpiochip_get_data(gc), offset, value);
182 178
183 return pinctrl_gpio_direction_output(offset); 179 return pinctrl_gpio_direction_output(offset);
184} 180}
185 181
186static int gpio_pin_get(struct gpio_chip *gc, unsigned offset) 182static int gpio_pin_get(struct gpio_chip *gc, unsigned offset)
187{ 183{
188 struct sh_pfc_chip *chip = gpio_to_pfc_chip(gc); 184 struct sh_pfc_chip *chip = gpiochip_get_data(gc);
189 struct sh_pfc_gpio_data_reg *reg; 185 struct sh_pfc_gpio_data_reg *reg;
190 unsigned int bit; 186 unsigned int bit;
191 unsigned int pos; 187 unsigned int pos;
@@ -199,7 +195,7 @@ static int gpio_pin_get(struct gpio_chip *gc, unsigned offset)
199 195
200static void gpio_pin_set(struct gpio_chip *gc, unsigned offset, int value) 196static void gpio_pin_set(struct gpio_chip *gc, unsigned offset, int value)
201{ 197{
202 gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value); 198 gpio_pin_set_value(gpiochip_get_data(gc), offset, value);
203} 199}
204 200
205static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset) 201static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset)
@@ -322,7 +318,7 @@ sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *),
322 if (ret < 0) 318 if (ret < 0)
323 return ERR_PTR(ret); 319 return ERR_PTR(ret);
324 320
325 ret = gpiochip_add(&chip->gpio_chip); 321 ret = gpiochip_add_data(&chip->gpio_chip, chip);
326 if (unlikely(ret < 0)) 322 if (unlikely(ret < 0))
327 return ERR_PTR(ret); 323 return ERR_PTR(ret);
328 324