On Sat, 8 Nov 2014 09:22:42 +0000 Mark Brown broonie@kernel.org wrote:
On Sat, Nov 08, 2014 at 11:38:03AM +1100, NeilBrown wrote:
- int val = ucontrol->value.integer.value[0];
- if (!!(twl4030_read(codec, TWL4030_REG_CODEC_MODE)
& TWL4030_OPTION_1) == !!val)
/* No change */
return 0;
We shouldn't be accepting attempts to set out of range values so there should be no need for the !! on val (which confused me when I was reading this).
True, the '!!' on val isn't necessary.
I took the opportunity to look around a bit more and discovered there was a snd_soc_get_enum_double, which I really should use in preference to twl4030_read.
So here is the new version. Can it be taken out of the email, or should I resend stand-alone?
Thanks, NeilBrown
From: NeilBrown neilb@suse.de Date: Wed, 2 Oct 2013 14:45:52 +1000 Subject: [PATCH] ASoC: twl4030: don't report EBUSY if no change requested.
"mode" must not be changed when active. However if a request is received to set the mode to what it currently is, that is also rejected when active, which causes confusing error messages.
So check first and if no change is actually requested, don't report an error.
Signed-off-by: NeilBrown neilb@suse.de
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index b6b0cb399599..613b61cee081 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -957,6 +957,16 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_ctl_elem_value currentval; + int ret; + + ret = snd_soc_get_enum_double(kcontrol, ¤tval); + if (ret) + return ret; + if (ucontrol->value.enumerated.item[0] == + currentval.value.enumerated.item[0]) + /* No change */ + return 0;
if (twl4030->configured) { dev_err(codec->dev,