From: Timur Tabi <timur@freescale.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: <linux-kernel@vger.kernel.org>,
Arnaud Patard <arnaud.patard@rtp-net.org>,
Liam Girdwood <lrg@ti.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
<alsa-devel@alsa-project.org>
Subject: Re: [PATCH] ASoC: Return early with -EINVAL if invalid dai format is detected
Date: Wed, 5 Oct 2011 11:16:57 -0500 [thread overview]
Message-ID: <4E8C82F9.1030306@freescale.com> (raw)
In-Reply-To: <1317779135.2595.1.camel@phoenix>
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
prev parent reply other threads:[~2011-10-05 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E8C82F9.1030306@freescale.com \
--to=timur@freescale.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.patard@rtp-net.org \
--cc=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox