diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-07-24 12:49:52 +0100 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-13 00:20:06 +0800 |
commit | d9a7666ff3a9e109844bf5aca5f50e3743f65840 (patch) | |
tree | 3cdc431f7d0a97d60315effc3393e5c1c1387172 /sound | |
parent | 68556ca1e03d6a35be3b315eba58df2f8176e3a0 (diff) | |
download | op-kernel-dev-d9a7666ff3a9e109844bf5aca5f50e3743f65840.zip op-kernel-dev-d9a7666ff3a9e109844bf5aca5f50e3743f65840.tar.gz |
ASoC: Remove ASoC-specific WM8994 I/O code
Just go directly to the regmap API, saving code and making integration
that bit more direct.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm8994.c | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 3eaf56a..2858908 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -184,44 +184,6 @@ static int wm8994_volatile(struct snd_soc_codec *codec, unsigned int reg) } } -static int wm8994_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) -{ - int ret; - - BUG_ON(reg > WM8994_MAX_REGISTER); - - if (!wm8994_volatile(codec, reg)) { - ret = snd_soc_cache_write(codec, reg, value); - if (ret != 0) - dev_err(codec->dev, "Cache write to %x failed: %d\n", - reg, ret); - } - - return wm8994_reg_write(codec->control_data, reg, value); -} - -static unsigned int wm8994_read(struct snd_soc_codec *codec, - unsigned int reg) -{ - unsigned int val; - int ret; - - BUG_ON(reg > WM8994_MAX_REGISTER); - - if (!wm8994_volatile(codec, reg) && wm8994_readable(codec, reg) && - reg < codec->driver->reg_cache_size) { - ret = snd_soc_cache_read(codec, reg, &val); - if (ret >= 0) - return val; - else - dev_err(codec->dev, "Cache read from %x failed: %d\n", - reg, ret); - } - - return wm8994_reg_read(codec->control_data, reg); -} - static int configure_aif_clock(struct snd_soc_codec *codec, int aif) { struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); @@ -2839,8 +2801,8 @@ static int wm8994_resume(struct snd_soc_codec *codec) if (wm8994->revision < 4) { /* force a HW read */ - val = wm8994_reg_read(codec->control_data, - WM8994_POWER_MANAGEMENT_5); + ret = regmap_read(control->regmap, + WM8994_POWER_MANAGEMENT_5, &val); /* modify the cache only */ codec->cache_only = 1; @@ -3455,13 +3417,13 @@ static irqreturn_t wm8994_temp_shut(int irq, void *data) static int wm8994_codec_probe(struct snd_soc_codec *codec) { - struct wm8994 *control; + struct wm8994 *control = dev_get_drvdata(codec->dev->parent); struct wm8994_priv *wm8994; struct snd_soc_dapm_context *dapm = &codec->dapm; + unsigned int reg; int ret, i; - codec->control_data = dev_get_drvdata(codec->dev->parent); - control = codec->control_data; + codec->control_data = control->regmap; wm8994 = devm_kzalloc(codec->dev, sizeof(struct wm8994_priv), GFP_KERNEL); @@ -3469,6 +3431,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) return -ENOMEM; snd_soc_codec_set_drvdata(codec, wm8994); + snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); wm8994->wm8994 = dev_get_drvdata(codec->dev->parent); wm8994->pdata = dev_get_platdata(codec->dev->parent); @@ -3494,11 +3457,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i)) continue; - ret = wm8994_reg_read(codec->control_data, i); + ret = regmap_read(control->regmap, i, ®); if (ret <= 0) continue; - ret = snd_soc_cache_write(codec, i, ret); + ret = snd_soc_cache_write(codec, i, reg); if (ret != 0) { dev_err(codec->dev, "Failed to initialise cache for 0x%x: %d\n", @@ -3653,24 +3616,24 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) * configured on init - if a system wants to do this dynamically * at runtime we can deal with that then. */ - ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_1); + ret = regmap_read(control->regmap, WM8994_GPIO_1, ®); if (ret < 0) { dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret); goto err_irq; } - if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { + if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { wm8994->lrclk_shared[0] = 1; wm8994_dai[0].symmetric_rates = 1; } else { wm8994->lrclk_shared[0] = 0; } - ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_6); + ret = regmap_read(control->regmap, WM8994_GPIO_6, ®); if (ret < 0) { dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret); goto err_irq; } - if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { + if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { wm8994->lrclk_shared[1] = 1; wm8994_dai[1].symmetric_rates = 1; } else { @@ -3937,8 +3900,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { .remove = wm8994_codec_remove, .suspend = wm8994_suspend, .resume = wm8994_resume, - .read = wm8994_read, - .write = wm8994_write, .readable_register = wm8994_readable, .volatile_register = wm8994_volatile, .set_bias_level = wm8994_set_bias_level, |