[alsa-devel] [RFC 04/12] ASoC: twl6040: Simplify custom get_volsw callback

Peter Ujfalusi peter.ujfalusi at ti.com
Tue Oct 4 13:39:41 CEST 2011


The custom get_volsw does not need to call any core get_volsw calls,
since we are returning the shadow values for the gains.
Return -EINVAL in the unlikely event, if the function has been called
for unhandled control. This way we can remove one check in the code.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
---
 sound/soc/codecs/twl6040.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 7e1c4c2..1d66127 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -798,20 +798,12 @@ static int twl6040_get_volsw(struct snd_kcontrol *kcontrol,
 		out = &twl6040_priv->handsfree;
 		break;
 	default:
-		break;
-	}
-
-	if (out) {
-		ucontrol->value.integer.value[0] = out->left_vol;
-		ucontrol->value.integer.value[1] = out->right_vol;
-		return 0;
+		return -EINVAL;
 	}
 
-	/* call the appropriate handler depending on the rreg */
-	if (mc->rreg)
-		return snd_soc_get_volsw_2r(kcontrol, ucontrol);
-	else
-		return snd_soc_get_volsw(kcontrol, ucontrol);
+	ucontrol->value.integer.value[0] = out->left_vol;
+	ucontrol->value.integer.value[1] = out->right_vol;
+	return 0;
 }
 
 static int twl6040_soc_dapm_put_vibra_enum(struct snd_kcontrol *kcontrol,
-- 
1.7.7



More information about the Alsa-devel mailing list