Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283889
b: refs/heads/master
c: 9d35f3e
h: refs/heads/master
i:
  283887: 30b45a0
v: v3
  • Loading branch information
Stephen Warren authored and Mark Brown committed Dec 6, 2011
1 parent b75057f commit 08724b1
Show file tree
Hide file tree
Showing 2 changed files with 41 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: db81778409227a0dc46ab95b95e1c7184ae9ef48
refs/heads/master: 9d35f3e100eb5cfb91d777c8621fb585ad0327cd
40 changes: 40 additions & 0 deletions trunk/sound/soc/codecs/wm8903.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
Expand Down Expand Up @@ -2036,6 +2037,39 @@ static const struct regmap_config wm8903_regmap = {
.num_reg_defaults = ARRAY_SIZE(wm8903_reg_defaults),
};

static int wm8903_set_pdata_irq_trigger(struct i2c_client *i2c,
struct wm8903_platform_data *pdata)
{
struct irq_data *irq_data = irq_get_irq_data(i2c->irq);
if (!irq_data) {
dev_err(&i2c->dev, "Invalid IRQ: %d\n",
i2c->irq);
return -EINVAL;
}

switch (irqd_get_trigger_type(irq_data)) {
case IRQ_TYPE_NONE:
/*
* We assume the controller imposes no restrictions,
* so we are able to select active-high
*/
/* Fall-through */
case IRQ_TYPE_LEVEL_HIGH:
pdata->irq_active_low = false;
break;
case IRQ_TYPE_LEVEL_LOW:
pdata->irq_active_low = true;
break;
default:
dev_err(&i2c->dev,
"Unsupported IRQ_TYPE %x\n",
irqd_get_trigger_type(irq_data));
return -EINVAL;
}

return 0;
}

static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
Expand Down Expand Up @@ -2071,6 +2105,12 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
dev_err(&i2c->dev, "Failed to allocate pdata\n");
return -ENOMEM;
}

if (i2c->irq) {
ret = wm8903_set_pdata_irq_trigger(i2c, wm8903->pdata);
if (ret != 0)
return ret;
}
}

ret = regmap_read(wm8903->regmap, WM8903_SW_RESET_AND_ID, &val);
Expand Down

0 comments on commit 08724b1

Please sign in to comment.