[alsa-devel] [PATCH 2/2] ASoC: wm8804: Merge CODEC probe and bus probe

Charles Keepax ckeepax at opensource.wolfsonmicro.com
Sat Feb 28 18:38:01 CET 2015


On Sun, Feb 22, 2015 at 04:43:22PM +0000, Charles Keepax wrote:
> From: Charles Keepax <ckeepax at gmail.com>
> 
> All of the things in the CODEC probe, such as getting the regulators and
> verifying the chip ID, are better done in bus probe. It is better to
> fail during bus probe if this is the wrong chip and all resource
> allocation should be done in the bus probe anyway. This patch merges
> the CODEC probe into bus probe.
> 
> Signed-off-by: Charles Keepax <ckeepax at opensource.wolfsonmicro.com>
> ---
>  sound/soc/codecs/wm8804.c |  180 ++++++++++++++++++++------------------------
>  1 files changed, 82 insertions(+), 98 deletions(-)
> 
> diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
> index b5a04fc..1bd4ace 100644
> --- a/sound/soc/codecs/wm8804.c
> +++ b/sound/soc/codecs/wm8804.c
> @@ -182,9 +182,9 @@ static bool wm8804_volatile(struct device *dev, unsigned int reg)
>  	}
>  }
>  
> -static int wm8804_reset(struct snd_soc_codec *codec)
> +static int wm8804_reset(struct wm8804_priv *wm8804)
>  {
> -	return snd_soc_write(codec, WM8804_RST_DEVID1, 0x0);
> +	return regmap_write(wm8804->regmap, WM8804_RST_DEVID1, 0x0);
>  }
>  

<snip>

> +	if (id2 != 0x8805) {
> +		dev_err(dev, "Invalid device ID: %#x\n", id2);
> +		ret = -EINVAL;
> +		goto err_reg_enable;
> +	}
> +
> +	ret = regmap_read(regmap, WM8804_DEVREV, &id1);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to read device revision: %d\n",
> +			ret);
> +		goto err_reg_enable;
> +	}
> +	dev_info(dev, "revision %c\n", id1 + 'A');
> +
> +	ret = wm8804_reset(wm8804);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to issue reset: %d\n", ret);
> +		goto err_reg_enable;
> +	}
> +
>  	return snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
>  				      &wm8804_dai, 1);

Oops... we should goto err_reg_enable if this fails. I will send
a new version on Monday.

> +
> +err_reg_enable:
> +	regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(wm8804_probe);
>  

Thanks,
Charles


More information about the Alsa-devel mailing list