All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sn95031: Fix the logic to find free channel
@ 2011-09-03  5:41 Axel Lin
  2011-09-03 16:14 ` Girdwood, Liam
  2011-09-04 15:54   ` Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Axel Lin @ 2011-09-03  5:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Harsha Priya, Vinod Koul, Liam Girdwood, Mark Brown, alsa-devel

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




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
  2011-09-03  5:41 [PATCH] ASoC: sn95031: Fix the logic to find free channel Axel Lin
@ 2011-09-03 16:14 ` Girdwood, Liam
  2011-09-03 17:08     ` Vinod Koul
  2011-09-04 15:54   ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Girdwood, Liam @ 2011-09-03 16:14 UTC (permalink / raw)
  To: Axel Lin; +Cc: Vinod Koul, alsa-devel, Harsha Priya, linux-kernel, Mark Brown

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
  2011-09-03 16:14 ` Girdwood, Liam
@ 2011-09-03 17:08     ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2011-09-03 17:08 UTC (permalink / raw)
  To: Girdwood, Liam
  Cc: Axel Lin, linux-kernel, Harsha Priya, Mark Brown, alsa-devel

On Sat, 2011-09-03 at 21:44 +0530, Girdwood, Liam wrote:
> 
> 
> 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.
Acked-by: Vinod Koul <vinod.koul@linux.intel.com>


-- 
~Vinod


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
@ 2011-09-03 17:08     ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2011-09-03 17:08 UTC (permalink / raw)
  To: Girdwood, Liam
  Cc: Axel Lin, Harsha Priya, linux-kernel, alsa-devel, Mark Brown

On Sat, 2011-09-03 at 21:44 +0530, Girdwood, Liam wrote:
> 
> 
> 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.
Acked-by: Vinod Koul <vinod.koul@linux.intel.com>


-- 
~Vinod

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
  2011-09-03  5:41 [PATCH] ASoC: sn95031: Fix the logic to find free channel Axel Lin
@ 2011-09-04 15:54   ` Mark Brown
  2011-09-04 15:54   ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-09-04 15:54 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Harsha Priya, Vinod Koul, Liam Girdwood, alsa-devel

On Sat, Sep 03, 2011 at 01:41:47PM +0800, Axel Lin 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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: sn95031: Fix the logic to find free channel
@ 2011-09-04 15:54   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-09-04 15:54 UTC (permalink / raw)
  To: Axel Lin
  Cc: Vinod Koul, alsa-devel, Harsha Priya, linux-kernel, Liam Girdwood

On Sat, Sep 03, 2011 at 01:41:47PM +0800, Axel Lin 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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-04 15:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-03  5:41 [PATCH] ASoC: sn95031: Fix the logic to find free channel Axel Lin
2011-09-03 16:14 ` Girdwood, Liam
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

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.