diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-07 05:18:17 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 05:21:10 -0500 |
commit | 5b68cc2d5963e2241d36f07c5f5964d54fa7bc6f (patch) | |
tree | f88eca418c807f58465b0ffd0beb4b0d3e06d721 /drivers/gpio/gpio-palmas.c | |
parent | d99f7aec6e8b4ffe10d6df71d17d2c5cbef2ac65 (diff) |
gpio: palmas: 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: Andrew Chew <achew@nvidia.com>
Cc: Stephen Warren <swarren@nvidia.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-palmas.c')
-rw-r--r-- | drivers/gpio/gpio-palmas.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c index ddd1a00c839d..fdfb3b1e0def 100644 --- a/drivers/gpio/gpio-palmas.c +++ b/drivers/gpio/gpio-palmas.c | |||
@@ -35,14 +35,9 @@ struct palmas_device_data { | |||
35 | int ngpio; | 35 | int ngpio; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip) | ||
39 | { | ||
40 | return container_of(chip, struct palmas_gpio, gpio_chip); | ||
41 | } | ||
42 | |||
43 | static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) | 38 | static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) |
44 | { | 39 | { |
45 | struct palmas_gpio *pg = to_palmas_gpio(gc); | 40 | struct palmas_gpio *pg = gpiochip_get_data(gc); |
46 | struct palmas *palmas = pg->palmas; | 41 | struct palmas *palmas = pg->palmas; |
47 | unsigned int val; | 42 | unsigned int val; |
48 | int ret; | 43 | int ret; |
@@ -74,7 +69,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) | |||
74 | static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, | 69 | static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, |
75 | int value) | 70 | int value) |
76 | { | 71 | { |
77 | struct palmas_gpio *pg = to_palmas_gpio(gc); | 72 | struct palmas_gpio *pg = gpiochip_get_data(gc); |
78 | struct palmas *palmas = pg->palmas; | 73 | struct palmas *palmas = pg->palmas; |
79 | int ret; | 74 | int ret; |
80 | unsigned int reg; | 75 | unsigned int reg; |
@@ -96,7 +91,7 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, | |||
96 | static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, | 91 | static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, |
97 | int value) | 92 | int value) |
98 | { | 93 | { |
99 | struct palmas_gpio *pg = to_palmas_gpio(gc); | 94 | struct palmas_gpio *pg = gpiochip_get_data(gc); |
100 | struct palmas *palmas = pg->palmas; | 95 | struct palmas *palmas = pg->palmas; |
101 | int ret; | 96 | int ret; |
102 | unsigned int reg; | 97 | unsigned int reg; |
@@ -118,7 +113,7 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, | |||
118 | 113 | ||
119 | static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) | 114 | static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) |
120 | { | 115 | { |
121 | struct palmas_gpio *pg = to_palmas_gpio(gc); | 116 | struct palmas_gpio *pg = gpiochip_get_data(gc); |
122 | struct palmas *palmas = pg->palmas; | 117 | struct palmas *palmas = pg->palmas; |
123 | int ret; | 118 | int ret; |
124 | unsigned int reg; | 119 | unsigned int reg; |
@@ -136,7 +131,7 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) | |||
136 | 131 | ||
137 | static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | 132 | static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) |
138 | { | 133 | { |
139 | struct palmas_gpio *pg = to_palmas_gpio(gc); | 134 | struct palmas_gpio *pg = gpiochip_get_data(gc); |
140 | struct palmas *palmas = pg->palmas; | 135 | struct palmas *palmas = pg->palmas; |
141 | 136 | ||
142 | return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); | 137 | return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); |
@@ -200,7 +195,7 @@ static int palmas_gpio_probe(struct platform_device *pdev) | |||
200 | else | 195 | else |
201 | palmas_gpio->gpio_chip.base = -1; | 196 | palmas_gpio->gpio_chip.base = -1; |
202 | 197 | ||
203 | ret = gpiochip_add(&palmas_gpio->gpio_chip); | 198 | ret = gpiochip_add_data(&palmas_gpio->gpio_chip, palmas_gpio); |
204 | if (ret < 0) { | 199 | if (ret < 0) { |
205 | dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); | 200 | dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); |
206 | return ret; | 201 | return ret; |