On Thu, Jun 09, 2011 at 07:10:49PM +0100, Liam Girdwood wrote:
+static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg) +{
- if (w->codec)
return snd_soc_read(w->codec, reg);
- return 0;
+}
I guess this and write() should return an error if they can't find something to interact with. And realistically to also complain in the logs given how usefully we can actualy handle errors.
I'm tempted to say let me post my regmap API that I've had sitting in my -next queue over the weekend then we can just unconditionally use a regmap here. I'd not been too happy with how it was handling mutli-word I/O but there's only one user of that in ASoC so far. We still need the _widget and so on versions wrapping them in ASoC of course so that we can pass sensible objects in.
+int soc_widget_update_bits(struct snd_soc_dapm_widget *w, unsigned short reg,
unsigned int mask, unsigned int value)
+{
- int change;
- unsigned int old, new;
- old = soc_widget_read(w, reg);
- new = (old & ~mask) | value;
Should do the & mask on value that I added to the vanilla one last week - that would've avoided a genuine bug.