aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8962.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-06-07 18:13:53 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-06-08 10:24:46 -0400
commitc7356da9e2ede4a89d000bde8a8a4408890943b9 (patch)
tree4478ef435b24cde5941166dd25dfeb7ba2fe3612 /sound/soc/codecs/wm8962.c
parentffdaa48aed8dae94037b26a2f9050128facfaa2e (diff)
ASoC: Factor out I2C usage in WM8962 driver
The chip can actually support SPI so we shouldn't assume we've got an I2C device even though that's the most common configuration. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/codecs/wm8962.c')
-rw-r--r--sound/soc/codecs/wm8962.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index f90ae427242b..b0cb4368d1b4 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -78,6 +78,8 @@ struct wm8962_priv {
78#ifdef CONFIG_GPIOLIB 78#ifdef CONFIG_GPIOLIB
79 struct gpio_chip gpio_chip; 79 struct gpio_chip gpio_chip;
80#endif 80#endif
81
82 int irq;
81}; 83};
82 84
83/* We can't use the same notifier block for more than one supply and 85/* We can't use the same notifier block for more than one supply and
@@ -3731,8 +3733,6 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3731 int ret; 3733 int ret;
3732 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 3734 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3733 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); 3735 struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
3734 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
3735 dev);
3736 u16 *reg_cache = codec->reg_cache; 3736 u16 *reg_cache = codec->reg_cache;
3737 int i, trigger, irq_pol; 3737 int i, trigger, irq_pol;
3738 bool dmicclk, dmicdat; 3738 bool dmicclk, dmicdat;
@@ -3899,7 +3899,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3899 wm8962_init_beep(codec); 3899 wm8962_init_beep(codec);
3900 wm8962_init_gpio(codec); 3900 wm8962_init_gpio(codec);
3901 3901
3902 if (i2c->irq) { 3902 if (wm8962->irq) {
3903 if (pdata && pdata->irq_active_low) { 3903 if (pdata && pdata->irq_active_low) {
3904 trigger = IRQF_TRIGGER_LOW; 3904 trigger = IRQF_TRIGGER_LOW;
3905 irq_pol = WM8962_IRQ_POL; 3905 irq_pol = WM8962_IRQ_POL;
@@ -3911,12 +3911,13 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3911 snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL, 3911 snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL,
3912 WM8962_IRQ_POL, irq_pol); 3912 WM8962_IRQ_POL, irq_pol);
3913 3913
3914 ret = request_threaded_irq(i2c->irq, NULL, wm8962_irq, 3914 ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq,
3915 trigger | IRQF_ONESHOT, 3915 trigger | IRQF_ONESHOT,
3916 "wm8962", codec); 3916 "wm8962", codec);
3917 if (ret != 0) { 3917 if (ret != 0) {
3918 dev_err(codec->dev, "Failed to request IRQ %d: %d\n", 3918 dev_err(codec->dev, "Failed to request IRQ %d: %d\n",
3919 i2c->irq, ret); 3919 wm8962->irq, ret);
3920 wm8962->irq = 0;
3920 /* Non-fatal */ 3921 /* Non-fatal */
3921 } else { 3922 } else {
3922 /* Enable some IRQs by default */ 3923 /* Enable some IRQs by default */
@@ -3941,12 +3942,10 @@ err:
3941static int wm8962_remove(struct snd_soc_codec *codec) 3942static int wm8962_remove(struct snd_soc_codec *codec)
3942{ 3943{
3943 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 3944 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3944 struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
3945 dev);
3946 int i; 3945 int i;
3947 3946
3948 if (i2c->irq) 3947 if (wm8962->irq)
3949 free_irq(i2c->irq, codec); 3948 free_irq(wm8962->irq, codec);
3950 3949
3951 cancel_delayed_work_sync(&wm8962->mic_work); 3950 cancel_delayed_work_sync(&wm8962->mic_work);
3952 3951
@@ -3986,6 +3985,8 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3986 3985
3987 i2c_set_clientdata(i2c, wm8962); 3986 i2c_set_clientdata(i2c, wm8962);
3988 3987
3988 wm8962->irq = i2c->irq;
3989
3989 ret = snd_soc_register_codec(&i2c->dev, 3990 ret = snd_soc_register_codec(&i2c->dev,
3990 &soc_codec_dev_wm8962, &wm8962_dai, 1); 3991 &soc_codec_dev_wm8962, &wm8962_dai, 1);
3991 if (ret < 0) 3992 if (ret < 0)