Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323297
b: refs/heads/master
c: 0c00c50
h: refs/heads/master
i:
  323295: 21bf666
v: v3
  • Loading branch information
Mark Brown committed Aug 7, 2012
1 parent 136ff0d commit dc018b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 40052ca0c243d101cfadd65936f60ef81df10b02
refs/heads/master: 0c00c50b41a9a6ee83eb16fb5c6c22e5115391b8
25 changes: 25 additions & 0 deletions trunk/drivers/base/regmap/regmap-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/irqdomain.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>

#include "internal.h"
Expand Down Expand Up @@ -62,6 +63,13 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
int i, ret;
u32 reg;

if (d->chip->runtime_pm) {
ret = pm_runtime_get_sync(map->dev);
if (ret < 0)
dev_err(map->dev, "IRQ sync failed to resume: %d\n",
ret);
}

/*
* If there's been a change in the mask write it back to the
* hardware. We rely on the use of the regmap core cache to
Expand All @@ -77,6 +85,9 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
reg);
}

if (d->chip->runtime_pm)
pm_runtime_put(map->dev);

/* If we've changed our wakeup count propagate it to the parent */
if (d->wake_count < 0)
for (i = d->wake_count; i < 0; i++)
Expand Down Expand Up @@ -147,6 +158,15 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
bool handled = false;
u32 reg;

if (chip->runtime_pm) {
ret = pm_runtime_get_sync(map->dev);
if (ret < 0) {
dev_err(map->dev, "IRQ thread failed to resume: %d\n",
ret);
return IRQ_NONE;
}
}

/*
* Ignore masked IRQs and ack if we need to; we ack early so
* there is no race between handling and acknowleding the
Expand All @@ -162,6 +182,8 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
if (ret != 0) {
dev_err(map->dev, "Failed to read IRQ status: %d\n",
ret);
if (chip->runtime_pm)
pm_runtime_put(map->dev);
return IRQ_NONE;
}

Expand All @@ -185,6 +207,9 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
}
}

if (chip->runtime_pm)
pm_runtime_put(map->dev);

if (handled)
return IRQ_HANDLED;
else
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ struct regmap_irq {
* @ack_base: Base ack address. If zero then the chip is clear on read.
* @wake_base: Base address for wake enables. If zero unsupported.
* @irq_reg_stride: Stride to use for chips where registers are not contiguous.
* @runtime_pm: Hold a runtime PM lock on the device when accessing it.
*
* @num_regs: Number of registers in each control bank.
* @irqs: Descriptors for individual IRQs. Interrupt numbers are
Expand All @@ -299,6 +300,7 @@ struct regmap_irq_chip {
unsigned int ack_base;
unsigned int wake_base;
unsigned int irq_reg_stride;
bool runtime_pm;

int num_regs;

Expand Down

0 comments on commit dc018b0

Please sign in to comment.