* [PATCH] ASoC: Return early with -EINVAL if invalid dai format is detected
@ 2011-10-05 1:45 Axel Lin
2011-10-05 16:16 ` Timur Tabi
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-10-05 1:45 UTC (permalink / raw)
To: linux-kernel
Cc: Timur Tabi, Arnaud Patard, Liam Girdwood, Mark Brown, alsa-devel
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
---
sound/soc/codecs/cs4270.c | 2 +-
sound/soc/codecs/cs42l51.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 5830c93..e645d67 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -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 */
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index 286878d..779294b 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -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) {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: Return early with -EINVAL if invalid dai format is detected
2011-10-05 1:45 [PATCH] ASoC: Return early with -EINVAL if invalid dai format is detected Axel Lin
@ 2011-10-05 16:16 ` Timur Tabi
0 siblings, 0 replies; 2+ messages in thread
From: Timur Tabi @ 2011-10-05 16:16 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Arnaud Patard, Liam Girdwood, Mark Brown,
alsa-devel
Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> Cc: Timur Tabi <timur@freescale.com>
> Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
> ---
> sound/soc/codecs/cs4270.c | 2 +-
> sound/soc/codecs/cs42l51.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
> index 5830c93..e645d67 100644
> --- a/sound/soc/codecs/cs4270.c
> +++ b/sound/soc/codecs/cs4270.c
> @@ -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.
--
Timur Tabi
Linux kernel developer at Freescale
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-05 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 1:45 [PATCH] ASoC: Return early with -EINVAL if invalid dai format is detected Axel Lin
2011-10-05 16:16 ` Timur Tabi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox