[alsa-devel] [PATCH v3] ASoC: sgtl5000: Fix the cache handling

Mark Brown broonie at kernel.org
Fri May 23 20:33:57 CEST 2014

On Fri, May 23, 2014 at 11:48:58AM -0300, Fabio Estevam wrote:

>  static int sgtl5000_resume(struct snd_soc_codec *codec)
>  {
> +	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
>  	/* Bring the codec back up to standby to enable regulators */
>  	sgtl5000_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
>  	/* Restore registers by cached in memory */
>  	sgtl5000_restore_regs(codec);
> +
> +	regcache_cache_only(sgtl5000->regmap, false);
>  	return 0;

Like Lars said this seems broken - why are we restoring the registers in
cache only mode, and what is actually doing the sync?  I expect the
errors you were seeing when not in cache only mode were due to the I/O
failing, most likely due to the device not being powered.

This appears to be another one of those confused things that the driver
has been doing since the early versions rather than something introduced
by your patch (or the regmap conversion for that matter) - I'd be
surprised if we're not just seeing the results of better error checking

Looking at the code what I'd expect to happen here is that
set_bias_level() manages the cache enable, turning on cache only mode
just before it turns the regulators off and restoring normal mode just
after enabling them, then calling _restore_regs() after that.  The
resume call should just be a call to set_bias_level() then.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140523/84724bea/attachment.sig>

More information about the Alsa-devel mailing list