diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-07 05:37:33 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 05:21:11 -0500 |
commit | d81b37fcad764c7babd7dd858aeb1b9afd2df5cc (patch) | |
tree | daae174b93df02a910a577a099a021de064a5c12 | |
parent | 510f48713711abed9a79aa405147687dd256d072 (diff) |
gpio: pl061: 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: Haojian Zhuang <haojian.zhuang@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-pl061.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index f937bc7e42dd..5cb38212bbc0 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -61,7 +61,7 @@ struct pl061_gpio { | |||
61 | 61 | ||
62 | static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | 62 | static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) |
63 | { | 63 | { |
64 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 64 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
65 | unsigned long flags; | 65 | unsigned long flags; |
66 | unsigned char gpiodir; | 66 | unsigned char gpiodir; |
67 | 67 | ||
@@ -80,7 +80,7 @@ static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | |||
80 | static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | 80 | static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, |
81 | int value) | 81 | int value) |
82 | { | 82 | { |
83 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 83 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
84 | unsigned long flags; | 84 | unsigned long flags; |
85 | unsigned char gpiodir; | 85 | unsigned char gpiodir; |
86 | 86 | ||
@@ -105,14 +105,14 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | |||
105 | 105 | ||
106 | static int pl061_get_value(struct gpio_chip *gc, unsigned offset) | 106 | static int pl061_get_value(struct gpio_chip *gc, unsigned offset) |
107 | { | 107 | { |
108 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 108 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
109 | 109 | ||
110 | return !!readb(chip->base + (BIT(offset + 2))); | 110 | return !!readb(chip->base + (BIT(offset + 2))); |
111 | } | 111 | } |
112 | 112 | ||
113 | static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) | 113 | static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) |
114 | { | 114 | { |
115 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 115 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
116 | 116 | ||
117 | writeb(!!value << offset, chip->base + (BIT(offset + 2))); | 117 | writeb(!!value << offset, chip->base + (BIT(offset + 2))); |
118 | } | 118 | } |
@@ -120,7 +120,7 @@ static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) | |||
120 | static int pl061_irq_type(struct irq_data *d, unsigned trigger) | 120 | static int pl061_irq_type(struct irq_data *d, unsigned trigger) |
121 | { | 121 | { |
122 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 122 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
123 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 123 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
124 | int offset = irqd_to_hwirq(d); | 124 | int offset = irqd_to_hwirq(d); |
125 | unsigned long flags; | 125 | unsigned long flags; |
126 | u8 gpiois, gpioibe, gpioiev; | 126 | u8 gpiois, gpioibe, gpioiev; |
@@ -210,7 +210,7 @@ static void pl061_irq_handler(struct irq_desc *desc) | |||
210 | unsigned long pending; | 210 | unsigned long pending; |
211 | int offset; | 211 | int offset; |
212 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); | 212 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
213 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 213 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
214 | struct irq_chip *irqchip = irq_desc_get_chip(desc); | 214 | struct irq_chip *irqchip = irq_desc_get_chip(desc); |
215 | 215 | ||
216 | chained_irq_enter(irqchip, desc); | 216 | chained_irq_enter(irqchip, desc); |
@@ -228,7 +228,7 @@ static void pl061_irq_handler(struct irq_desc *desc) | |||
228 | static void pl061_irq_mask(struct irq_data *d) | 228 | static void pl061_irq_mask(struct irq_data *d) |
229 | { | 229 | { |
230 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 230 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
231 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 231 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
232 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 232 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
233 | u8 gpioie; | 233 | u8 gpioie; |
234 | 234 | ||
@@ -241,7 +241,7 @@ static void pl061_irq_mask(struct irq_data *d) | |||
241 | static void pl061_irq_unmask(struct irq_data *d) | 241 | static void pl061_irq_unmask(struct irq_data *d) |
242 | { | 242 | { |
243 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 243 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
244 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 244 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
245 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 245 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
246 | u8 gpioie; | 246 | u8 gpioie; |
247 | 247 | ||
@@ -262,7 +262,7 @@ static void pl061_irq_unmask(struct irq_data *d) | |||
262 | static void pl061_irq_ack(struct irq_data *d) | 262 | static void pl061_irq_ack(struct irq_data *d) |
263 | { | 263 | { |
264 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 264 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
265 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 265 | struct pl061_gpio *chip = gpiochip_get_data(gc); |
266 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 266 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
267 | 267 | ||
268 | spin_lock(&chip->lock); | 268 | spin_lock(&chip->lock); |
@@ -328,7 +328,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
328 | chip->gc.parent = dev; | 328 | chip->gc.parent = dev; |
329 | chip->gc.owner = THIS_MODULE; | 329 | chip->gc.owner = THIS_MODULE; |
330 | 330 | ||
331 | ret = gpiochip_add(&chip->gc); | 331 | ret = gpiochip_add_data(&chip->gc, chip); |
332 | if (ret) | 332 | if (ret) |
333 | return ret; | 333 | return ret; |
334 | 334 | ||