diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-08-25 04:54:12 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-10-02 07:19:32 -0400 |
commit | 231d51b8a4d5b24e72112bbc73fdcc38759a26e3 (patch) | |
tree | f01c6b7c3fb8b477475c4ed4d917ad7d9d754088 /drivers/gpio/gpio-altera.c | |
parent | 4843289e60e16bed00b7c3b910e67fb06214631a (diff) |
gpio: altera: use container_of() to get state container
The state container of the Altera GPIO driver is extracted from
the gpio_chip exploiting the fact that offsetof() the
struct gpio_chip inside the struct of_mm_gpio_chip are both 0, so
the container_of() is in practice a noop. However if a member
is added to struct altera_gpio_chip in front of
struct of_mm_gpio_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.
Cc: Tien Hock Loh <thloh@altera.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-altera.c')
-rw-r--r-- | drivers/gpio/gpio-altera.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 1b44941574fa..3e6661bab54a 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c | |||
@@ -42,6 +42,11 @@ struct altera_gpio_chip { | |||
42 | int mapped_irq; | 42 | int mapped_irq; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | static struct altera_gpio_chip *to_altera(struct gpio_chip *gc) | ||
46 | { | ||
47 | return container_of(gc, struct altera_gpio_chip, mmchip.gc); | ||
48 | } | ||
49 | |||
45 | static void altera_gpio_irq_unmask(struct irq_data *d) | 50 | static void altera_gpio_irq_unmask(struct irq_data *d) |
46 | { | 51 | { |
47 | struct altera_gpio_chip *altera_gc; | 52 | struct altera_gpio_chip *altera_gc; |
@@ -49,7 +54,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d) | |||
49 | unsigned long flags; | 54 | unsigned long flags; |
50 | u32 intmask; | 55 | u32 intmask; |
51 | 56 | ||
52 | altera_gc = irq_data_get_irq_chip_data(d); | 57 | altera_gc = to_altera(irq_data_get_irq_chip_data(d)); |
53 | mm_gc = &altera_gc->mmchip; | 58 | mm_gc = &altera_gc->mmchip; |
54 | 59 | ||
55 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 60 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
@@ -67,7 +72,7 @@ static void altera_gpio_irq_mask(struct irq_data *d) | |||
67 | unsigned long flags; | 72 | unsigned long flags; |
68 | u32 intmask; | 73 | u32 intmask; |
69 | 74 | ||
70 | altera_gc = irq_data_get_irq_chip_data(d); | 75 | altera_gc = to_altera(irq_data_get_irq_chip_data(d)); |
71 | mm_gc = &altera_gc->mmchip; | 76 | mm_gc = &altera_gc->mmchip; |
72 | 77 | ||
73 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 78 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
@@ -87,7 +92,7 @@ static int altera_gpio_irq_set_type(struct irq_data *d, | |||
87 | { | 92 | { |
88 | struct altera_gpio_chip *altera_gc; | 93 | struct altera_gpio_chip *altera_gc; |
89 | 94 | ||
90 | altera_gc = irq_data_get_irq_chip_data(d); | 95 | altera_gc = to_altera(irq_data_get_irq_chip_data(d)); |
91 | 96 | ||
92 | if (type == IRQ_TYPE_NONE) | 97 | if (type == IRQ_TYPE_NONE) |
93 | return 0; | 98 | return 0; |
@@ -210,7 +215,7 @@ static void altera_gpio_irq_edge_handler(struct irq_desc *desc) | |||
210 | unsigned long status; | 215 | unsigned long status; |
211 | int i; | 216 | int i; |
212 | 217 | ||
213 | altera_gc = irq_desc_get_handler_data(desc); | 218 | altera_gc = to_altera(irq_desc_get_handler_data(desc)); |
214 | chip = irq_desc_get_chip(desc); | 219 | chip = irq_desc_get_chip(desc); |
215 | mm_gc = &altera_gc->mmchip; | 220 | mm_gc = &altera_gc->mmchip; |
216 | irqdomain = altera_gc->mmchip.gc.irqdomain; | 221 | irqdomain = altera_gc->mmchip.gc.irqdomain; |
@@ -239,7 +244,7 @@ static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc) | |||
239 | unsigned long status; | 244 | unsigned long status; |
240 | int i; | 245 | int i; |
241 | 246 | ||
242 | altera_gc = irq_desc_get_handler_data(desc); | 247 | altera_gc = to_altera(irq_desc_get_handler_data(desc)); |
243 | chip = irq_desc_get_chip(desc); | 248 | chip = irq_desc_get_chip(desc); |
244 | mm_gc = &altera_gc->mmchip; | 249 | mm_gc = &altera_gc->mmchip; |
245 | irqdomain = altera_gc->mmchip.gc.irqdomain; | 250 | irqdomain = altera_gc->mmchip.gc.irqdomain; |