diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2013-10-08 03:30:21 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-10-09 07:07:05 -0400 |
commit | 010c51e189c6a37da2908d27c93e73584f6e8fa8 (patch) | |
tree | fd4689e566c4f59f1dad53ecf0cef6fe0097fab5 /drivers/pinctrl | |
parent | a047914e7f123074bc8ee6f40e4502111a1b4cc4 (diff) |
pinctrl: pinctrl-adi2: Remove nested lock+irqsave that resue flags.
Also avoid use NULL pointer in error message.
v2-changes:
- use port pinter only after checking
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-adi2.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c index 8089fda00427..a74e6f4ffbd7 100644 --- a/drivers/pinctrl/pinctrl-adi2.c +++ b/drivers/pinctrl/pinctrl-adi2.c | |||
@@ -247,7 +247,7 @@ static void adi_gpio_ack_irq(struct irq_data *d) | |||
247 | unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); | 247 | unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); |
248 | 248 | ||
249 | spin_lock_irqsave(&port->lock, flags); | 249 | spin_lock_irqsave(&port->lock, flags); |
250 | spin_lock_irqsave(&port->pint->lock, flags); | 250 | spin_lock(&port->pint->lock); |
251 | 251 | ||
252 | if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { | 252 | if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { |
253 | if (readl(®s->invert_set) & pintbit) | 253 | if (readl(®s->invert_set) & pintbit) |
@@ -258,7 +258,7 @@ static void adi_gpio_ack_irq(struct irq_data *d) | |||
258 | 258 | ||
259 | writel(pintbit, ®s->request); | 259 | writel(pintbit, ®s->request); |
260 | 260 | ||
261 | spin_unlock_irqrestore(&port->pint->lock, flags); | 261 | spin_unlock(&port->pint->lock); |
262 | spin_unlock_irqrestore(&port->lock, flags); | 262 | spin_unlock_irqrestore(&port->lock, flags); |
263 | } | 263 | } |
264 | 264 | ||
@@ -270,7 +270,7 @@ static void adi_gpio_mask_ack_irq(struct irq_data *d) | |||
270 | unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); | 270 | unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); |
271 | 271 | ||
272 | spin_lock_irqsave(&port->lock, flags); | 272 | spin_lock_irqsave(&port->lock, flags); |
273 | spin_lock_irqsave(&port->pint->lock, flags); | 273 | spin_lock(&port->pint->lock); |
274 | 274 | ||
275 | if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { | 275 | if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { |
276 | if (readl(®s->invert_set) & pintbit) | 276 | if (readl(®s->invert_set) & pintbit) |
@@ -282,7 +282,7 @@ static void adi_gpio_mask_ack_irq(struct irq_data *d) | |||
282 | writel(pintbit, ®s->request); | 282 | writel(pintbit, ®s->request); |
283 | writel(pintbit, ®s->mask_clear); | 283 | writel(pintbit, ®s->mask_clear); |
284 | 284 | ||
285 | spin_unlock_irqrestore(&port->pint->lock, flags); | 285 | spin_unlock(&port->pint->lock); |
286 | spin_unlock_irqrestore(&port->lock, flags); | 286 | spin_unlock_irqrestore(&port->lock, flags); |
287 | } | 287 | } |
288 | 288 | ||
@@ -293,11 +293,11 @@ static void adi_gpio_mask_irq(struct irq_data *d) | |||
293 | struct gpio_pint_regs *regs = port->pint->regs; | 293 | struct gpio_pint_regs *regs = port->pint->regs; |
294 | 294 | ||
295 | spin_lock_irqsave(&port->lock, flags); | 295 | spin_lock_irqsave(&port->lock, flags); |
296 | spin_lock_irqsave(&port->pint->lock, flags); | 296 | spin_lock(&port->pint->lock); |
297 | 297 | ||
298 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_clear); | 298 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_clear); |
299 | 299 | ||
300 | spin_unlock_irqrestore(&port->pint->lock, flags); | 300 | spin_unlock(&port->pint->lock); |
301 | spin_unlock_irqrestore(&port->lock, flags); | 301 | spin_unlock_irqrestore(&port->lock, flags); |
302 | } | 302 | } |
303 | 303 | ||
@@ -308,11 +308,11 @@ static void adi_gpio_unmask_irq(struct irq_data *d) | |||
308 | struct gpio_pint_regs *regs = port->pint->regs; | 308 | struct gpio_pint_regs *regs = port->pint->regs; |
309 | 309 | ||
310 | spin_lock_irqsave(&port->lock, flags); | 310 | spin_lock_irqsave(&port->lock, flags); |
311 | spin_lock_irqsave(&port->pint->lock, flags); | 311 | spin_lock(&port->pint->lock); |
312 | 312 | ||
313 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_set); | 313 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_set); |
314 | 314 | ||
315 | spin_unlock_irqrestore(&port->pint->lock, flags); | 315 | spin_unlock(&port->pint->lock); |
316 | spin_unlock_irqrestore(&port->lock, flags); | 316 | spin_unlock_irqrestore(&port->lock, flags); |
317 | } | 317 | } |
318 | 318 | ||
@@ -320,15 +320,17 @@ static unsigned int adi_gpio_irq_startup(struct irq_data *d) | |||
320 | { | 320 | { |
321 | unsigned long flags; | 321 | unsigned long flags; |
322 | struct gpio_port *port = irq_data_get_irq_chip_data(d); | 322 | struct gpio_port *port = irq_data_get_irq_chip_data(d); |
323 | struct gpio_pint_regs *regs = port->pint->regs; | 323 | struct gpio_pint_regs *regs; |
324 | 324 | ||
325 | if (!port) { | 325 | if (!port) { |
326 | dev_err(port->dev, "GPIO IRQ %d :Not exist\n", d->irq); | 326 | pr_err("GPIO IRQ %d :Not exist\n", d->irq); |
327 | return -ENODEV; | 327 | return -ENODEV; |
328 | } | 328 | } |
329 | 329 | ||
330 | regs = port->pint->regs; | ||
331 | |||
330 | spin_lock_irqsave(&port->lock, flags); | 332 | spin_lock_irqsave(&port->lock, flags); |
331 | spin_lock_irqsave(&port->pint->lock, flags); | 333 | spin_lock(&port->pint->lock); |
332 | 334 | ||
333 | port_setup(port, d->hwirq, true); | 335 | port_setup(port, d->hwirq, true); |
334 | writew(BIT(d->hwirq), &port->regs->dir_clear); | 336 | writew(BIT(d->hwirq), &port->regs->dir_clear); |
@@ -336,7 +338,7 @@ static unsigned int adi_gpio_irq_startup(struct irq_data *d) | |||
336 | 338 | ||
337 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_set); | 339 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_set); |
338 | 340 | ||
339 | spin_unlock_irqrestore(&port->pint->lock, flags); | 341 | spin_unlock(&port->pint->lock); |
340 | spin_unlock_irqrestore(&port->lock, flags); | 342 | spin_unlock_irqrestore(&port->lock, flags); |
341 | 343 | ||
342 | return 0; | 344 | return 0; |
@@ -349,11 +351,11 @@ static void adi_gpio_irq_shutdown(struct irq_data *d) | |||
349 | struct gpio_pint_regs *regs = port->pint->regs; | 351 | struct gpio_pint_regs *regs = port->pint->regs; |
350 | 352 | ||
351 | spin_lock_irqsave(&port->lock, flags); | 353 | spin_lock_irqsave(&port->lock, flags); |
352 | spin_lock_irqsave(&port->pint->lock, flags); | 354 | spin_lock(&port->pint->lock); |
353 | 355 | ||
354 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_clear); | 356 | writel(hwirq_to_pintbit(port, d->hwirq), ®s->mask_clear); |
355 | 357 | ||
356 | spin_unlock_irqrestore(&port->pint->lock, flags); | 358 | spin_unlock(&port->pint->lock); |
357 | spin_unlock_irqrestore(&port->lock, flags); | 359 | spin_unlock_irqrestore(&port->lock, flags); |
358 | } | 360 | } |
359 | 361 | ||
@@ -361,21 +363,23 @@ static int adi_gpio_irq_type(struct irq_data *d, unsigned int type) | |||
361 | { | 363 | { |
362 | unsigned long flags; | 364 | unsigned long flags; |
363 | struct gpio_port *port = irq_data_get_irq_chip_data(d); | 365 | struct gpio_port *port = irq_data_get_irq_chip_data(d); |
364 | struct gpio_pint_regs *pint_regs = port->pint->regs; | 366 | struct gpio_pint_regs *pint_regs; |
365 | unsigned pintmask; | 367 | unsigned pintmask; |
366 | unsigned int irq = d->irq; | 368 | unsigned int irq = d->irq; |
367 | int ret = 0; | 369 | int ret = 0; |
368 | char buf[16]; | 370 | char buf[16]; |
369 | 371 | ||
370 | if (!port) { | 372 | if (!port) { |
371 | dev_err(port->dev, "GPIO IRQ %d :Not exist\n", irq); | 373 | pr_err("GPIO IRQ %d :Not exist\n", d->irq); |
372 | return -ENODEV; | 374 | return -ENODEV; |
373 | } | 375 | } |
374 | 376 | ||
377 | pint_regs = port->pint->regs; | ||
378 | |||
375 | pintmask = hwirq_to_pintbit(port, d->hwirq); | 379 | pintmask = hwirq_to_pintbit(port, d->hwirq); |
376 | 380 | ||
377 | spin_lock_irqsave(&port->lock, flags); | 381 | spin_lock_irqsave(&port->lock, flags); |
378 | spin_lock_irqsave(&port->pint->lock, flags); | 382 | spin_lock(&port->pint->lock); |
379 | 383 | ||
380 | /* In case of interrupt autodetect, set irq type to edge sensitive. */ | 384 | /* In case of interrupt autodetect, set irq type to edge sensitive. */ |
381 | if (type == IRQ_TYPE_PROBE) | 385 | if (type == IRQ_TYPE_PROBE) |
@@ -416,7 +420,7 @@ static int adi_gpio_irq_type(struct irq_data *d, unsigned int type) | |||
416 | } | 420 | } |
417 | 421 | ||
418 | out: | 422 | out: |
419 | spin_unlock_irqrestore(&port->pint->lock, flags); | 423 | spin_unlock(&port->pint->lock); |
420 | spin_unlock_irqrestore(&port->lock, flags); | 424 | spin_unlock_irqrestore(&port->lock, flags); |
421 | 425 | ||
422 | return ret; | 426 | return ret; |