diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-08-25 04:40:23 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-10-02 07:19:31 -0400 |
commit | 4843289e60e16bed00b7c3b910e67fb06214631a (patch) | |
tree | 69c8ae548914fbd63aab12befa324bda7b06b3a1 /drivers/gpio/gpio-etraxfs.c | |
parent | 1dbf7f299f90dc4b45e2322a3af843ad65e1501b (diff) |
gpio: etraxfs: use container_of() to get state container
The state container of the etraxfs GPIO driver is extracted from
the gpio_chip exploiting the fact that offsetof() the
struct gpio_chip inside the struct bgpio_chip are both 0, so
the container_of() is in practice a noop. However if a member
is added to struct etraxfs_gpio_chip in front of
struct bgpio_chip, things will break. Using proper container_of()
avoids this problem.
Semantically this is a noop, the compiler will optimize it away,
but syntactically it makes me happier.
Acked-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-etraxfs.c')
-rw-r--r-- | drivers/gpio/gpio-etraxfs.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c index 2ffcd9fdd1f2..5c15dd12172d 100644 --- a/drivers/gpio/gpio-etraxfs.c +++ b/drivers/gpio/gpio-etraxfs.c | |||
@@ -176,6 +176,11 @@ static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = { | |||
176 | .rw_intr_pins = ARTPEC3_rw_intr_pins, | 176 | .rw_intr_pins = ARTPEC3_rw_intr_pins, |
177 | }; | 177 | }; |
178 | 178 | ||
179 | static struct etraxfs_gpio_chip *to_etraxfs(struct gpio_chip *gc) | ||
180 | { | ||
181 | return container_of(gc, struct etraxfs_gpio_chip, bgc.gc); | ||
182 | } | ||
183 | |||
179 | static unsigned int etraxfs_gpio_chip_to_port(struct gpio_chip *gc) | 184 | static unsigned int etraxfs_gpio_chip_to_port(struct gpio_chip *gc) |
180 | { | 185 | { |
181 | return gc->label[0] - 'A'; | 186 | return gc->label[0] - 'A'; |
@@ -220,7 +225,8 @@ static unsigned int etraxfs_gpio_to_group_pin(struct etraxfs_gpio_chip *chip, | |||
220 | 225 | ||
221 | static void etraxfs_gpio_irq_ack(struct irq_data *d) | 226 | static void etraxfs_gpio_irq_ack(struct irq_data *d) |
222 | { | 227 | { |
223 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 228 | struct etraxfs_gpio_chip *chip = |
229 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
224 | struct etraxfs_gpio_block *block = chip->block; | 230 | struct etraxfs_gpio_block *block = chip->block; |
225 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 231 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
226 | 232 | ||
@@ -229,7 +235,8 @@ static void etraxfs_gpio_irq_ack(struct irq_data *d) | |||
229 | 235 | ||
230 | static void etraxfs_gpio_irq_mask(struct irq_data *d) | 236 | static void etraxfs_gpio_irq_mask(struct irq_data *d) |
231 | { | 237 | { |
232 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 238 | struct etraxfs_gpio_chip *chip = |
239 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
233 | struct etraxfs_gpio_block *block = chip->block; | 240 | struct etraxfs_gpio_block *block = chip->block; |
234 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 241 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
235 | 242 | ||
@@ -241,7 +248,8 @@ static void etraxfs_gpio_irq_mask(struct irq_data *d) | |||
241 | 248 | ||
242 | static void etraxfs_gpio_irq_unmask(struct irq_data *d) | 249 | static void etraxfs_gpio_irq_unmask(struct irq_data *d) |
243 | { | 250 | { |
244 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 251 | struct etraxfs_gpio_chip *chip = |
252 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
245 | struct etraxfs_gpio_block *block = chip->block; | 253 | struct etraxfs_gpio_block *block = chip->block; |
246 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 254 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
247 | 255 | ||
@@ -253,7 +261,8 @@ static void etraxfs_gpio_irq_unmask(struct irq_data *d) | |||
253 | 261 | ||
254 | static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) | 262 | static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) |
255 | { | 263 | { |
256 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 264 | struct etraxfs_gpio_chip *chip = |
265 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
257 | struct etraxfs_gpio_block *block = chip->block; | 266 | struct etraxfs_gpio_block *block = chip->block; |
258 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 267 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
259 | u32 cfg; | 268 | u32 cfg; |
@@ -289,7 +298,8 @@ static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) | |||
289 | 298 | ||
290 | static int etraxfs_gpio_irq_request_resources(struct irq_data *d) | 299 | static int etraxfs_gpio_irq_request_resources(struct irq_data *d) |
291 | { | 300 | { |
292 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 301 | struct etraxfs_gpio_chip *chip = |
302 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
293 | struct etraxfs_gpio_block *block = chip->block; | 303 | struct etraxfs_gpio_block *block = chip->block; |
294 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 304 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
295 | int ret = -EBUSY; | 305 | int ret = -EBUSY; |
@@ -319,7 +329,8 @@ out: | |||
319 | 329 | ||
320 | static void etraxfs_gpio_irq_release_resources(struct irq_data *d) | 330 | static void etraxfs_gpio_irq_release_resources(struct irq_data *d) |
321 | { | 331 | { |
322 | struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); | 332 | struct etraxfs_gpio_chip *chip = |
333 | to_etraxfs(irq_data_get_irq_chip_data(d)); | ||
323 | struct etraxfs_gpio_block *block = chip->block; | 334 | struct etraxfs_gpio_block *block = chip->block; |
324 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 335 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
325 | 336 | ||