ASoC: Return early with -EINVAL if invalid dai format is detected
Subsystems (3)
PATCH 1/1 ASoC: Return early with -EINVAL if invalid dai format is detected
Signed-off-by Axel Lin <[email protected]>
Cc Timur Tabi <[email protected]>
Cc Arnaud Patard <[email protected]>
--- sound/soc/codecs/cs4270.c | 2 +- sound/soc/codecs/cs42l51.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/cs4270.c +1 -1
@@ -271,7 +271,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 */
sound/soc/codecs/cs42l51.c +1 -1
@@ -298,7 +298,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 ) {
Signature · 1 line
1.7.4.1
Quoted 13 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>Cc Timur Tabi <[email protected]>Cc Arnaud Patard <[email protected]>--- sound/soc/codecs/cs4270.c | 2 +- sound/soc/codecs/cs42l51.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)sound/soc/codecs/cs4270.c +0
-0
sound/soc/codecs/cs4270.c static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, · line 276
Quoted 7 lines
sound/soc/codecs/cs4270.c +1
-1@@ -271,7 +271,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 ; }
If you're going to make a change like this, I say go all the way:
/* set DAI format */
switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
case SND_SOC_DAIFMT_LEFT_J:
cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
break;
default:
dev_err(codec->dev, "invalid dai format\n");
return -EINVAL;
}
/* set master/slave audio interface */
switch (format & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
cs4270->slave_mode = 1;
break;
case SND_SOC_DAIFMT_CBM_CFM:
cs4270->slave_mode = 0;
break;
default:
/* all other modes are unsupported by the hardware */
---> also add an error message here
return -EINVAL;
}
return 0;Then you can delete local variable 'ret' altogether.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale