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

Dimitris Papastamos dp at opensource.wolfsonmicro.com
Thu Jan 6 17:53:26 CET 2011


On Wed, 2011-01-05 at 15:04 -0600, Timur Tabi wrote:
> Which is this line:
> 
> > @@ -3463,6 +3464,19 @@ int snd_soc_register_codec(struct device *dev,
> >
> >        /* allocate CODEC register cache */
> >        if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
> > +               reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
> > +               /* it is necessary to make a copy of the default register cache
> > +                * because in the case of using a compression type that requires
> > +                * the default register cache to be marked as __devinitconst the
> > +                * kernel might have freed the array by the time we initialize
> > +                * the cache.
> > +                */
> > +               codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
> > +                                             reg_size, GFP_KERNEL);

The semantics behind this code is that if the driver provides a
reg_cache_size and a reg_word_size it *should* provide a defaults
register cache as well.  If you want to manage your own register cache
in the driver which is not advised, you will have to add similar
functionality in your _priv struct.  If you require more flexible
functionality you need to consider implementing a sensible strategy and
submitting it as a patch.

Thanks,
Dimitris



More information about the Alsa-devel mailing list