[alsa-devel] [RFC 05/12] ASoC: twl6040: Simplify custom put_volsw callback

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


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 |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 1d66127..cc889e9 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -759,15 +759,13 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,
 		out = &twl6040_priv->handsfree;
 		break;
 	default:
-		break;
+		return -EINVAL;
 	}
 
-	if (out) {
-		out->left_vol = ucontrol->value.integer.value[0];
-		out->right_vol = ucontrol->value.integer.value[1];
-		if (!out->active)
-			return 1;
-	}
+	out->left_vol = ucontrol->value.integer.value[0];
+	out->right_vol = ucontrol->value.integer.value[1];
+	if (!out->active)
+		return 1;
 
 	/* call the appropriate handler depending on the rreg */
 	if (mc->rreg)
-- 
1.7.7



More information about the Alsa-devel mailing list