summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-04 10:19:52 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:21:04 -0500
commit0f6082d2b811ec56c4f7ecdde80410e17cf04452 (patch)
treefd08009498f70b6e8c00e091363fdab21b1fa571
parentc634fc19fe39f49a00d0e8e922a60ae24b8855b1 (diff)
gpio: da9052: 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: Ashish Jangam <ashish.jangam@kpitcummins.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-da9052.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c
index 38bd8f122bfc..f9b3247ad14b 100644
--- a/drivers/gpio/gpio-da9052.c
+++ b/drivers/gpio/gpio-da9052.c
@@ -51,11 +51,6 @@ struct da9052_gpio {
51 struct gpio_chip gp; 51 struct gpio_chip gp;
52}; 52};
53 53
54static inline struct da9052_gpio *to_da9052_gpio(struct gpio_chip *chip)
55{
56 return container_of(chip, struct da9052_gpio, gp);
57}
58
59static unsigned char da9052_gpio_port_odd(unsigned offset) 54static unsigned char da9052_gpio_port_odd(unsigned offset)
60{ 55{
61 return offset % 2; 56 return offset % 2;
@@ -63,7 +58,7 @@ static unsigned char da9052_gpio_port_odd(unsigned offset)
63 58
64static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) 59static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset)
65{ 60{
66 struct da9052_gpio *gpio = to_da9052_gpio(gc); 61 struct da9052_gpio *gpio = gpiochip_get_data(gc);
67 int da9052_port_direction = 0; 62 int da9052_port_direction = 0;
68 int ret; 63 int ret;
69 64
@@ -102,7 +97,7 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset)
102 97
103static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value) 98static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
104{ 99{
105 struct da9052_gpio *gpio = to_da9052_gpio(gc); 100 struct da9052_gpio *gpio = gpiochip_get_data(gc);
106 int ret; 101 int ret;
107 102
108 if (da9052_gpio_port_odd(offset)) { 103 if (da9052_gpio_port_odd(offset)) {
@@ -128,7 +123,7 @@ static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
128 123
129static int da9052_gpio_direction_input(struct gpio_chip *gc, unsigned offset) 124static int da9052_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
130{ 125{
131 struct da9052_gpio *gpio = to_da9052_gpio(gc); 126 struct da9052_gpio *gpio = gpiochip_get_data(gc);
132 unsigned char register_value; 127 unsigned char register_value;
133 int ret; 128 int ret;
134 129
@@ -154,7 +149,7 @@ static int da9052_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
154static int da9052_gpio_direction_output(struct gpio_chip *gc, 149static int da9052_gpio_direction_output(struct gpio_chip *gc,
155 unsigned offset, int value) 150 unsigned offset, int value)
156{ 151{
157 struct da9052_gpio *gpio = to_da9052_gpio(gc); 152 struct da9052_gpio *gpio = gpiochip_get_data(gc);
158 unsigned char register_value; 153 unsigned char register_value;
159 int ret; 154 int ret;
160 155
@@ -179,7 +174,7 @@ static int da9052_gpio_direction_output(struct gpio_chip *gc,
179 174
180static int da9052_gpio_to_irq(struct gpio_chip *gc, u32 offset) 175static int da9052_gpio_to_irq(struct gpio_chip *gc, u32 offset)
181{ 176{
182 struct da9052_gpio *gpio = to_da9052_gpio(gc); 177 struct da9052_gpio *gpio = gpiochip_get_data(gc);
183 struct da9052 *da9052 = gpio->da9052; 178 struct da9052 *da9052 = gpio->da9052;
184 179
185 int irq; 180 int irq;
@@ -219,7 +214,7 @@ static int da9052_gpio_probe(struct platform_device *pdev)
219 if (pdata && pdata->gpio_base) 214 if (pdata && pdata->gpio_base)
220 gpio->gp.base = pdata->gpio_base; 215 gpio->gp.base = pdata->gpio_base;
221 216
222 ret = gpiochip_add(&gpio->gp); 217 ret = gpiochip_add_data(&gpio->gp, gpio);
223 if (ret < 0) { 218 if (ret < 0) {
224 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 219 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
225 return ret; 220 return ret;