All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Girdwood, Liam" <lrg@ti.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>,
	alsa-devel@alsa-project.org,
	Harsha Priya <priya.harsha@intel.com>,
	linux-kernel@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
Date: Sat, 3 Sep 2011 17:14:06 +0100	[thread overview]
Message-ID: <CABS+qY2oOCpusNzRngTWmmcHv=jAkv-3N2rWH=mA8G6CSfYc7g@mail.gmail.com> (raw)
In-Reply-To: <1315028507.2268.1.camel@phoenix>

On 3 September 2011 06:41, Axel Lin <axel.lin@gmail.com> wrote:

> In the case of no free channel available,
> current implementation returns 0 instead of negative errno.
>
> This patch fixes the logic to return -EINVAL if no free channel available.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  sound/soc/codecs/sn95031.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
> index 84ffdeb..b4f1cb4 100644
> --- a/sound/soc/codecs/sn95031.c
> +++ b/sound/soc/codecs/sn95031.c
> @@ -79,7 +79,7 @@ static void configure_adc(struct snd_soc_codec
> *sn95031_codec, int val)
>  */
>  static int find_free_channel(struct snd_soc_codec *sn95031_codec)
>  {
> -       int ret = 0, i, value;
> +       int i, value;
>
>        /* check whether ADC is enabled */
>        value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1);
> @@ -91,12 +91,10 @@ static int find_free_channel(struct snd_soc_codec
> *sn95031_codec)
>        for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) {
>                value = snd_soc_read(sn95031_codec,
>                                SN95031_ADC_CHNL_START_ADDR + i);
> -               if (value & SN95031_STOPBIT_MASK) {
> -                       ret = i;
> +               if (value & SN95031_STOPBIT_MASK)
>                        break;
> -               }
>        }
> -       return (ret > SN95031_ADC_LOOP_MAX) ? (-EINVAL) : ret;
> +       return (i == SN95031_ADC_CHANLS_MAX) ? (-EINVAL) : i;
>  }
>
>  /* Initialize the ADC for reading micbias values. Can sleep. */
> --
> 1.7.4.1
>
>
>
>
Acked-by: Liam Girdwood <lrg@ti.com>

Btw, this should be posted to alsa-devel.

  reply	other threads:[~2011-09-03 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-03  5:41 [PATCH] ASoC: sn95031: Fix the logic to find free channel Axel Lin
2011-09-03 16:14 ` Girdwood, Liam [this message]
2011-09-03 17:08   ` Vinod Koul
2011-09-03 17:08     ` Vinod Koul
2011-09-04 15:54 ` Mark Brown
2011-09-04 15:54   ` Mark Brown

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='CABS+qY2oOCpusNzRngTWmmcHv=jAkv-3N2rWH=mA8G6CSfYc7g@mail.gmail.com' \
    --to=lrg@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=priya.harsha@intel.com \
    --cc=vinod.koul@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.