[alsa-devel] [PATCH 1/2] ASoC: soc-cache: Use reg_def_copy instead of reg_cache_default

Timur Tabi timur at freescale.com
Thu Jan 6 00:08:20 CET 2011


Mark Brown wrote:
> In general the expectation is that unless it's got a good reason not to
> a well written CODEC driver will use all the standard register cache
> infrastructure, including providing a set of defaults.  Good reasons for
> this include things like not having any registers and indeterminate
> default hardware state.

My concern is that I think it's unwise to hard-code the default values of the
registers in the source file.  Who's to say that a newer version of the chip
won't have different power-on defaults?

I do want to support a register cache, but I don't want to hard-code the default
values into cs4270.c.  Is this supported?

> As you will doubtless have seen when you looked at the code every other
> reference to reg_cache_default checks to see if it's set before using
> it.  This does rather suggest that the intention of the code is that it
> be optional.

So are you saying that there's a bug in this patch?  Perhaps that code should
look like this:

if (codec_drv->reg_cache_default)
	codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default, reg_size, GFP_KERNEL);
else {
	codec->reg_def_copy = kmalloc(reg_size, GFP_KERNEL);
	// here we somehow tell the codec driver to initialize reg_def_copy
}

-- 
Timur Tabi
Linux kernel developer at Freescale



More information about the Alsa-devel mailing list