Skip to content

Commit

Permalink
ASoC: wm8962: Hold a runtime PM reference while handling interrupts
Browse files Browse the repository at this point in the history
If the device is runtime suspended then we can't interact with it as it
may have been powered off and the register map will be in cache only
mode.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Feb 3, 2014
1 parent 38dbfb5 commit 7e9614e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sound/soc/codecs/wm8962.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,24 +3003,34 @@ static irqreturn_t wm8962_irq(int irq, void *data)
unsigned int active;
int reg, ret;

ret = pm_runtime_get_sync(dev);
if (ret < 0) {
dev_err(dev, "Failed to resume: %d\n", ret);
return IRQ_NONE;
}

ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK,
&mask);
if (ret != 0) {
pm_runtime_put(dev);
dev_err(dev, "Failed to read interrupt mask: %d\n",
ret);
return IRQ_NONE;
}

ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, &active);
if (ret != 0) {
pm_runtime_put(dev);
dev_err(dev, "Failed to read interrupt: %d\n", ret);
return IRQ_NONE;
}

active &= ~mask;

if (!active)
if (!active) {
pm_runtime_put(dev);
return IRQ_NONE;
}

/* Acknowledge the interrupts */
ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active);
Expand Down Expand Up @@ -3070,6 +3080,8 @@ static irqreturn_t wm8962_irq(int irq, void *data)
msecs_to_jiffies(250));
}

pm_runtime_put(dev);

return IRQ_HANDLED;
}

Expand Down

0 comments on commit 7e9614e

Please sign in to comment.