Commit 368b8436 authored by Andy Shevchenko's avatar Andy Shevchenko

gpio: pch: Refactor pch_irq_type() to avoid unnecessary locking

When type is not supported there is no need to lock and check.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 5a4245de
...@@ -229,17 +229,15 @@ static int pch_irq_type(struct irq_data *d, unsigned int type) ...@@ -229,17 +229,15 @@ static int pch_irq_type(struct irq_data *d, unsigned int type)
int ch, irq = d->irq; int ch, irq = d->irq;
ch = irq - chip->irq_base; ch = irq - chip->irq_base;
if (irq <= chip->irq_base + 7) { if (irq < chip->irq_base + 8) {
im_reg = &chip->reg->im0; im_reg = &chip->reg->im0;
im_pos = ch; im_pos = ch - 0;
} else { } else {
im_reg = &chip->reg->im1; im_reg = &chip->reg->im1;
im_pos = ch - 8; im_pos = ch - 8;
} }
dev_dbg(chip->dev, "irq=%d type=%d ch=%d pos=%d\n", irq, type, ch, im_pos); dev_dbg(chip->dev, "irq=%d type=%d ch=%d pos=%d\n", irq, type, ch, im_pos);
spin_lock_irqsave(&chip->spinlock, flags);
switch (type) { switch (type) {
case IRQ_TYPE_EDGE_RISING: case IRQ_TYPE_EDGE_RISING:
val = PCH_EDGE_RISING; val = PCH_EDGE_RISING;
...@@ -257,9 +255,11 @@ static int pch_irq_type(struct irq_data *d, unsigned int type) ...@@ -257,9 +255,11 @@ static int pch_irq_type(struct irq_data *d, unsigned int type)
val = PCH_LEVEL_L; val = PCH_LEVEL_L;
break; break;
default: default:
goto unlock; return 0;
} }
spin_lock_irqsave(&chip->spinlock, flags);
/* Set interrupt mode */ /* Set interrupt mode */
im = ioread32(im_reg) & ~(PCH_IM_MASK << (im_pos * 4)); im = ioread32(im_reg) & ~(PCH_IM_MASK << (im_pos * 4));
iowrite32(im | (val << (im_pos * 4)), im_reg); iowrite32(im | (val << (im_pos * 4)), im_reg);
...@@ -270,7 +270,6 @@ static int pch_irq_type(struct irq_data *d, unsigned int type) ...@@ -270,7 +270,6 @@ static int pch_irq_type(struct irq_data *d, unsigned int type)
else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
irq_set_handler_locked(d, handle_edge_irq); irq_set_handler_locked(d, handle_edge_irq);
unlock:
spin_unlock_irqrestore(&chip->spinlock, flags); spin_unlock_irqrestore(&chip->spinlock, flags);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment