ASoC: Return early with -EINVAL if invalid dai format is detected
authorAxel Lin <axel.lin@gmail.com>
Wed, 5 Oct 2011 23:29:56 +0000 (07:29 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 6 Oct 2011 19:02:56 +0000 (20:02 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/cs4270.c
sound/soc/codecs/cs42l51.c

index 5830c934a1d139d38a5bf4e89df6fa14526900c3..f1f237ecec2a6c43dcdf9ee31b72da7f0cdecff6 100644 (file)
@@ -261,7 +261,6 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
 {
        struct snd_soc_codec *codec = codec_dai->codec;
        struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
-       int ret = 0;
 
        /* set DAI format */
        switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -271,7 +270,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
                break;
        default:
                dev_err(codec->dev, "invalid dai format\n");
-               ret = -EINVAL;
+               return -EINVAL;
        }
 
        /* set master/slave audio interface */
@@ -284,10 +283,11 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
                break;
        default:
                /* all other modes are unsupported by the hardware */
-               ret = -EINVAL;
+               dev_err(codec->dev, "Unknown master/slave configuration\n");
+               return -EINVAL;
        }
 
-       return ret;
+       return 0;
 }
 
 /**
index 286878d22b6adfbb930f32321625f98b7a4d2e31..8c3c8205d19e99016e47b1564aa58cbdf91b0bab 100644 (file)
@@ -288,7 +288,6 @@ static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai,
 {
        struct snd_soc_codec *codec = codec_dai->codec;
        struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec);
-       int ret = 0;
 
        switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_I2S:
@@ -298,7 +297,7 @@ static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai,
                break;
        default:
                dev_err(codec->dev, "invalid DAI format\n");
-               ret = -EINVAL;
+               return -EINVAL;
        }
 
        switch (format & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -309,11 +308,11 @@ static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai,
                cs42l51->func = MODE_SLAVE_AUTO;
                break;
        default:
-               ret = -EINVAL;
-               break;
+               dev_err(codec->dev, "Unknown master/slave configuration\n");
+               return -EINVAL;
        }
 
-       return ret;
+       return 0;
 }
 
 struct cs42l51_ratios {