On Mon, May 12, 2014 at 10:19:26AM +0200, Lars-Peter Clausen wrote:
I was looking at the drivers that were using the SND_SOC_DAPM_PRE_REG event and I noticed that the outmixer_event function for the wm8400, wm8990 and wm8991 is broken. They do a switch statement to determine which kcontrol cause the event in the form of 'switch(kcontrol->private_value) { case (REG | (SHIFT << 8)): ...'. Long long time ago we used to store the register and the shift in the same integer which was stored in private_value. But this was changed in commit 4eaa9819 ("ALSA: ASoC: Convert bitfields in ASoC into full int width"). This was long before the wm8400 and wm8991 drivers were merged and just a month after the wm8990 driver was merged. So these functions have been dead code pretty much for as long as they existed. Do you want to fix this up? If not I'm going to send a patch that removes the functions. If you want to fix this up, this should be re-implemented as a custom put handler for the kcontrols rather than a event callback, which checks whether the change is valid before doing any DAPM changes. The event callback runs in the middle of the DAPM sequence, so half of the changes will already have been applied before the check is made whether the change should be done or not.
Paragraphs are good for legibility... it would be better to fix this up since it's a useful example for people to have, I have seen this sort of "A but not B" thing in other devices. Looking briefly at the WM8400 datasheet custom put controls would be better though looking at the code I'm not sure that the intention with the original code (which predates me) wasn't to enforce a limitation based on the outputs being enabled.