diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-17 09:56:13 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-18 06:33:54 -0400 |
commit | ca50410b731c636b9750c02d5ae45be215056634 (patch) | |
tree | b509b9c7de63b13bb608b76ff32179ebdd60a2db /sound/soc/codecs/wm8962.c | |
parent | 61e6cfa80de5760bbe406f4e815b7739205754d2 (diff) |
ASoC: wm8962: Move interrupt initalisation to probe()
This is more idiomatic and fixes bugs in the error handling paths.
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/wm8962.c')
-rw-r--r-- | sound/soc/codecs/wm8962.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 11d80f3b6137..54379ee1cd0c 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
@@ -3377,7 +3377,7 @@ static int wm8962_probe(struct snd_soc_codec *codec) | |||
3377 | int ret; | 3377 | int ret; |
3378 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 3378 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
3379 | struct wm8962_pdata *pdata = &wm8962->pdata; | 3379 | struct wm8962_pdata *pdata = &wm8962->pdata; |
3380 | int i, trigger, irq_pol; | 3380 | int i; |
3381 | bool dmicclk, dmicdat; | 3381 | bool dmicclk, dmicdat; |
3382 | 3382 | ||
3383 | wm8962->codec = codec; | 3383 | wm8962->codec = codec; |
@@ -3506,36 +3506,6 @@ static int wm8962_probe(struct snd_soc_codec *codec) | |||
3506 | wm8962_init_beep(codec); | 3506 | wm8962_init_beep(codec); |
3507 | wm8962_init_gpio(codec); | 3507 | wm8962_init_gpio(codec); |
3508 | 3508 | ||
3509 | if (wm8962->irq) { | ||
3510 | if (pdata->irq_active_low) { | ||
3511 | trigger = IRQF_TRIGGER_LOW; | ||
3512 | irq_pol = WM8962_IRQ_POL; | ||
3513 | } else { | ||
3514 | trigger = IRQF_TRIGGER_HIGH; | ||
3515 | irq_pol = 0; | ||
3516 | } | ||
3517 | |||
3518 | snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL, | ||
3519 | WM8962_IRQ_POL, irq_pol); | ||
3520 | |||
3521 | ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq, | ||
3522 | trigger | IRQF_ONESHOT, | ||
3523 | "wm8962", codec->dev); | ||
3524 | if (ret != 0) { | ||
3525 | dev_err(codec->dev, "Failed to request IRQ %d: %d\n", | ||
3526 | wm8962->irq, ret); | ||
3527 | wm8962->irq = 0; | ||
3528 | /* Non-fatal */ | ||
3529 | } else { | ||
3530 | /* Enable some IRQs by default */ | ||
3531 | snd_soc_update_bits(codec, | ||
3532 | WM8962_INTERRUPT_STATUS_2_MASK, | ||
3533 | WM8962_FLL_LOCK_EINT | | ||
3534 | WM8962_TEMP_SHUT_EINT | | ||
3535 | WM8962_FIFOS_ERR_EINT, 0); | ||
3536 | } | ||
3537 | } | ||
3538 | |||
3539 | return 0; | 3509 | return 0; |
3540 | } | 3510 | } |
3541 | 3511 | ||
@@ -3544,9 +3514,6 @@ static int wm8962_remove(struct snd_soc_codec *codec) | |||
3544 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 3514 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
3545 | int i; | 3515 | int i; |
3546 | 3516 | ||
3547 | if (wm8962->irq) | ||
3548 | free_irq(wm8962->irq, codec); | ||
3549 | |||
3550 | cancel_delayed_work_sync(&wm8962->mic_work); | 3517 | cancel_delayed_work_sync(&wm8962->mic_work); |
3551 | 3518 | ||
3552 | wm8962_free_gpio(codec); | 3519 | wm8962_free_gpio(codec); |
@@ -3619,7 +3586,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
3619 | struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev); | 3586 | struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev); |
3620 | struct wm8962_priv *wm8962; | 3587 | struct wm8962_priv *wm8962; |
3621 | unsigned int reg; | 3588 | unsigned int reg; |
3622 | int ret, i; | 3589 | int ret, i, irq_pol, trigger; |
3623 | 3590 | ||
3624 | wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv), | 3591 | wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv), |
3625 | GFP_KERNEL); | 3592 | GFP_KERNEL); |
@@ -3714,6 +3681,37 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
3714 | ret); | 3681 | ret); |
3715 | } | 3682 | } |
3716 | 3683 | ||
3684 | if (wm8962->irq) { | ||
3685 | if (pdata->irq_active_low) { | ||
3686 | trigger = IRQF_TRIGGER_LOW; | ||
3687 | irq_pol = WM8962_IRQ_POL; | ||
3688 | } else { | ||
3689 | trigger = IRQF_TRIGGER_HIGH; | ||
3690 | irq_pol = 0; | ||
3691 | } | ||
3692 | |||
3693 | regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL, | ||
3694 | WM8962_IRQ_POL, irq_pol); | ||
3695 | |||
3696 | ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL, | ||
3697 | wm8962_irq, | ||
3698 | trigger | IRQF_ONESHOT, | ||
3699 | "wm8962", &i2c->dev); | ||
3700 | if (ret != 0) { | ||
3701 | dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", | ||
3702 | wm8962->irq, ret); | ||
3703 | wm8962->irq = 0; | ||
3704 | /* Non-fatal */ | ||
3705 | } else { | ||
3706 | /* Enable some IRQs by default */ | ||
3707 | regmap_update_bits(wm8962->regmap, | ||
3708 | WM8962_INTERRUPT_STATUS_2_MASK, | ||
3709 | WM8962_FLL_LOCK_EINT | | ||
3710 | WM8962_TEMP_SHUT_EINT | | ||
3711 | WM8962_FIFOS_ERR_EINT, 0); | ||
3712 | } | ||
3713 | } | ||
3714 | |||
3717 | pm_runtime_enable(&i2c->dev); | 3715 | pm_runtime_enable(&i2c->dev); |
3718 | pm_request_idle(&i2c->dev); | 3716 | pm_request_idle(&i2c->dev); |
3719 | 3717 | ||