From 7a7f0ba03d521ac2d36c9015278bc35657b3dcc9 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Fri, 19 Sep 2014 14:48:17 +0300 Subject: ASoC: max98090: Move interrupt request from codec probe to i2c probe Keep MAX98090 interrupt requested after i2c device probing as long as the driver is loaded. This fixes the issue where subsequent codec probe max98090_probe() call fails in interrupt request since interrupt wasn't freed over codec remove-reprobe cycle. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'sound/soc/codecs/max98090.c') diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f154365..fe77df6 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2159,12 +2159,16 @@ static void max98090_jack_work(struct work_struct *work) static irqreturn_t max98090_interrupt(int irq, void *data) { - struct snd_soc_codec *codec = data; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = data; + struct snd_soc_codec *codec = max98090->codec; int ret; unsigned int mask; unsigned int active; + /* Treat interrupt before codec is initialized as spurious */ + if (codec == NULL) + return IRQ_NONE; + dev_dbg(codec->dev, "***** max98090_interrupt *****\n"); ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); @@ -2367,17 +2371,6 @@ static int max98090_probe(struct snd_soc_codec *codec) snd_soc_write(codec, M98090_REG_JACK_DETECT, M98090_JDETEN_MASK | M98090_JDEB_25MS); - /* Register for interrupts */ - dev_dbg(codec->dev, "irq = %d\n", max98090->irq); - - ret = devm_request_threaded_irq(codec->dev, max98090->irq, NULL, - max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "max98090_interrupt", codec); - if (ret < 0) { - dev_err(codec->dev, "request_irq failed: %d\n", - ret); - } - /* * Clear any old interrupts. * An old interrupt ocurring prior to installing the ISR @@ -2417,6 +2410,7 @@ static int max98090_remove(struct snd_soc_codec *codec) cancel_delayed_work_sync(&max98090->pll_det_enable_work); cancel_work_sync(&max98090->pll_det_disable_work); cancel_work_sync(&max98090->pll_work); + max98090->codec = NULL; return 0; } @@ -2478,6 +2472,15 @@ static int max98090_i2c_probe(struct i2c_client *i2c, goto err_enable; } + ret = devm_request_threaded_irq(&i2c->dev, max98090->irq, NULL, + max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "max98090_interrupt", max98090); + if (ret < 0) { + dev_err(&i2c->dev, "request_irq failed: %d\n", + ret); + return ret; + } + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98090, max98090_dai, ARRAY_SIZE(max98090_dai)); -- cgit v1.1 From ced1933db67087554abf22bcb285eb6873380b10 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Fri, 19 Sep 2014 14:48:18 +0300 Subject: ASoC: max98090: Remove structure member irq from private data struct max98090_priv member irq is now used only locally in max98090_i2c_probe() and can be removed. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound/soc/codecs/max98090.c') diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index fe77df6..3e27de1 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2463,7 +2463,6 @@ static int max98090_i2c_probe(struct i2c_client *i2c, max98090->devtype = driver_data; i2c_set_clientdata(i2c, max98090); max98090->pdata = i2c->dev.platform_data; - max98090->irq = i2c->irq; max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap); if (IS_ERR(max98090->regmap)) { @@ -2472,7 +2471,7 @@ static int max98090_i2c_probe(struct i2c_client *i2c, goto err_enable; } - ret = devm_request_threaded_irq(&i2c->dev, max98090->irq, NULL, + ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "max98090_interrupt", max98090); if (ret < 0) { -- cgit v1.1 From 3256ff6e5117c493ec20e96aad9f0a20d656d561 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Fri, 19 Sep 2014 14:48:19 +0300 Subject: ASoC: max98090: Remove structure member extmic_mux from private data There is no other use for extmic_mux than setting it to zero so remove it. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound/soc/codecs/max98090.c') diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 3e27de1..f2a3f30 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2333,7 +2333,6 @@ static int max98090_probe(struct snd_soc_codec *codec) max98090->lin_state = 0; max98090->pa1en = 0; max98090->pa2en = 0; - max98090->extmic_mux = 0; ret = snd_soc_read(codec, M98090_REG_REVISION_ID); if (ret < 0) { -- cgit v1.1