aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2016-02-22 02:24:01 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-03-08 22:43:09 -0500
commitcd0d3f58a0ca05773c29b5e5b82f075b607777ba (patch)
tree47af7eaebdd4417ae2f43fda12e8364088c68925
parentfa4007ca06e4c808b002067c2ea02a9bebdc044b (diff)
gpio: mpc8xxx: Remove *read_reg and *write_reg from struct mpc8xxx_gpio_chip
*read_reg and *write_reg can be removed because at all the places to call them, we can just use gc->read_reg/gc->write_reg instead. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-mpc8xxx.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index d2472c5dfe6f..bc042ad62cfb 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -37,9 +37,6 @@ struct mpc8xxx_gpio_chip {
37 void __iomem *regs; 37 void __iomem *regs;
38 raw_spinlock_t lock; 38 raw_spinlock_t lock;
39 39
40 unsigned long (*read_reg)(void __iomem *reg);
41 void (*write_reg)(void __iomem *reg, unsigned long data);
42
43 int (*direction_output)(struct gpio_chip *chip, 40 int (*direction_output)(struct gpio_chip *chip,
44 unsigned offset, int value); 41 unsigned offset, int value);
45 42
@@ -58,8 +55,8 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
58 struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); 55 struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc);
59 u32 out_mask, out_shadow; 56 u32 out_mask, out_shadow;
60 57
61 out_mask = mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_DIR); 58 out_mask = gc->read_reg(mpc8xxx_gc->regs + GPIO_DIR);
62 val = mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_DAT) & ~out_mask; 59 val = gc->read_reg(mpc8xxx_gc->regs + GPIO_DAT) & ~out_mask;
63 out_shadow = gc->bgpio_data & out_mask; 60 out_shadow = gc->bgpio_data & out_mask;
64 61
65 return !!((val | out_shadow) & gc->pin2mask(gc, gpio)); 62 return !!((val | out_shadow) & gc->pin2mask(gc, gpio));
@@ -101,10 +98,11 @@ static void mpc8xxx_gpio_irq_cascade(struct irq_desc *desc)
101{ 98{
102 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_desc_get_handler_data(desc); 99 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_desc_get_handler_data(desc);
103 struct irq_chip *chip = irq_desc_get_chip(desc); 100 struct irq_chip *chip = irq_desc_get_chip(desc);
101 struct gpio_chip *gc = &mpc8xxx_gc->gc;
104 unsigned int mask; 102 unsigned int mask;
105 103
106 mask = mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_IER) 104 mask = gc->read_reg(mpc8xxx_gc->regs + GPIO_IER)
107 & mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR); 105 & gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR);
108 if (mask) 106 if (mask)
109 generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq, 107 generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
110 32 - ffs(mask))); 108 32 - ffs(mask)));
@@ -120,8 +118,8 @@ static void mpc8xxx_irq_unmask(struct irq_data *d)
120 118
121 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 119 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
122 120
123 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, 121 gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR,
124 mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR) 122 gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR)
125 | gc->pin2mask(gc, irqd_to_hwirq(d))); 123 | gc->pin2mask(gc, irqd_to_hwirq(d)));
126 124
127 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 125 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
@@ -135,8 +133,8 @@ static void mpc8xxx_irq_mask(struct irq_data *d)
135 133
136 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 134 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
137 135
138 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, 136 gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR,
139 mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR) 137 gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR)
140 & ~(gc->pin2mask(gc, irqd_to_hwirq(d)))); 138 & ~(gc->pin2mask(gc, irqd_to_hwirq(d))));
141 139
142 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 140 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
@@ -147,8 +145,8 @@ static void mpc8xxx_irq_ack(struct irq_data *d)
147 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d); 145 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d);
148 struct gpio_chip *gc = &mpc8xxx_gc->gc; 146 struct gpio_chip *gc = &mpc8xxx_gc->gc;
149 147
150 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_IER, 148 gc->write_reg(mpc8xxx_gc->regs + GPIO_IER,
151 gc->pin2mask(gc, irqd_to_hwirq(d))); 149 gc->pin2mask(gc, irqd_to_hwirq(d)));
152} 150}
153 151
154static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) 152static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type)
@@ -160,16 +158,16 @@ static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type)
160 switch (flow_type) { 158 switch (flow_type) {
161 case IRQ_TYPE_EDGE_FALLING: 159 case IRQ_TYPE_EDGE_FALLING:
162 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 160 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
163 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR, 161 gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR,
164 mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR) 162 gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR)
165 | gc->pin2mask(gc, irqd_to_hwirq(d))); 163 | gc->pin2mask(gc, irqd_to_hwirq(d)));
166 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 164 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
167 break; 165 break;
168 166
169 case IRQ_TYPE_EDGE_BOTH: 167 case IRQ_TYPE_EDGE_BOTH:
170 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 168 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
171 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR, 169 gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR,
172 mpc8xxx_gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR) 170 gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR)
173 & ~(gc->pin2mask(gc, irqd_to_hwirq(d)))); 171 & ~(gc->pin2mask(gc, irqd_to_hwirq(d))));
174 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 172 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
175 break; 173 break;
@@ -184,6 +182,7 @@ static int mpc8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type)
184static int mpc512x_irq_set_type(struct irq_data *d, unsigned int flow_type) 182static int mpc512x_irq_set_type(struct irq_data *d, unsigned int flow_type)
185{ 183{
186 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d); 184 struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_data_get_irq_chip_data(d);
185 struct gpio_chip *gc = &mpc8xxx_gc->gc;
187 unsigned long gpio = irqd_to_hwirq(d); 186 unsigned long gpio = irqd_to_hwirq(d);
188 void __iomem *reg; 187 void __iomem *reg;
189 unsigned int shift; 188 unsigned int shift;
@@ -201,8 +200,7 @@ static int mpc512x_irq_set_type(struct irq_data *d, unsigned int flow_type)
201 case IRQ_TYPE_EDGE_FALLING: 200 case IRQ_TYPE_EDGE_FALLING:
202 case IRQ_TYPE_LEVEL_LOW: 201 case IRQ_TYPE_LEVEL_LOW:
203 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 202 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
204 mpc8xxx_gc->write_reg(reg, 203 gc->write_reg(reg, (gc->read_reg(reg) & ~(3 << shift))
205 (mpc8xxx_gc->read_reg(reg) & ~(3 << shift))
206 | (2 << shift)); 204 | (2 << shift));
207 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 205 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
208 break; 206 break;
@@ -210,16 +208,14 @@ static int mpc512x_irq_set_type(struct irq_data *d, unsigned int flow_type)
210 case IRQ_TYPE_EDGE_RISING: 208 case IRQ_TYPE_EDGE_RISING:
211 case IRQ_TYPE_LEVEL_HIGH: 209 case IRQ_TYPE_LEVEL_HIGH:
212 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 210 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
213 mpc8xxx_gc->write_reg(reg, 211 gc->write_reg(reg, (gc->read_reg(reg) & ~(3 << shift))
214 (mpc8xxx_gc->read_reg(reg) & ~(3 << shift))
215 | (1 << shift)); 212 | (1 << shift));
216 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 213 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
217 break; 214 break;
218 215
219 case IRQ_TYPE_EDGE_BOTH: 216 case IRQ_TYPE_EDGE_BOTH:
220 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 217 raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
221 mpc8xxx_gc->write_reg(reg, 218 gc->write_reg(reg, (gc->read_reg(reg) & ~(3 << shift)));
222 (mpc8xxx_gc->read_reg(reg) & ~(3 << shift)));
223 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 219 raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
224 break; 220 break;
225 221
@@ -332,8 +328,6 @@ static int mpc8xxx_probe(struct platform_device *pdev)
332 dev_dbg(&pdev->dev, "GPIO registers are BIG endian\n"); 328 dev_dbg(&pdev->dev, "GPIO registers are BIG endian\n");
333 } 329 }
334 330
335 mpc8xxx_gc->read_reg = gc->read_reg;
336 mpc8xxx_gc->write_reg = gc->write_reg;
337 mpc8xxx_gc->direction_output = gc->direction_output; 331 mpc8xxx_gc->direction_output = gc->direction_output;
338 332
339 if (!devtype) 333 if (!devtype)
@@ -366,8 +360,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
366 return 0; 360 return 0;
367 361
368 /* ack and mask all irqs */ 362 /* ack and mask all irqs */
369 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_IER, 0xffffffff); 363 gc->write_reg(mpc8xxx_gc->regs + GPIO_IER, 0xffffffff);
370 mpc8xxx_gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, 0); 364 gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, 0);
371 365
372 irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, 366 irq_set_chained_handler_and_data(mpc8xxx_gc->irqn,
373 mpc8xxx_gpio_irq_cascade, mpc8xxx_gc); 367 mpc8xxx_gpio_irq_cascade, mpc8xxx_gc);