public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs
@ 2011-08-14  3:31 Axel Lin
  2011-08-15 12:25 ` Johannes Stezenbach
  2011-08-15 13:54 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2011-08-14  3:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Johannes Stezenbach, Liam Girdwood, Mark Brown, alsa-devel

There is exactly one match or no match at all during the for loop iteration,
thus we can break from the for loop once a match is found.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 sound/soc/codecs/sta32x.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index fbd7eb9..3d155f5 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -524,13 +524,17 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream,
 	rate = params_rate(params);
 	pr_debug("rate: %u\n", rate);
 	for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++)
-		if (interpolation_ratios[i].fs == rate)
+		if (interpolation_ratios[i].fs == rate) {
 			ir = interpolation_ratios[i].ir;
+			break;
+		}
 	if (ir < 0)
 		return -EINVAL;
 	for (i = 0; mclk_ratios[ir][i].ratio; i++)
-		if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk)
+		if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk) {
 			mcs = mclk_ratios[ir][i].mcs;
+			break;
+		}
 	if (mcs < 0)
 		return -EINVAL;
 
-- 
1.7.4.1




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

* Re: [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs
  2011-08-14  3:31 [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs Axel Lin
@ 2011-08-15 12:25 ` Johannes Stezenbach
  2011-08-15 13:54 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Stezenbach @ 2011-08-15 12:25 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown, alsa-devel

On Sun, Aug 14, 2011 at 11:31:04AM +0800, Axel Lin wrote:
> There is exactly one match or no match at all during the for loop iteration,
> thus we can break from the for loop once a match is found.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Looks good.

Acked-by: Johannes Stezenbach <js@sig21.net>


Thanks,
Johannes


> ---
>  sound/soc/codecs/sta32x.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
> index fbd7eb9..3d155f5 100644
> --- a/sound/soc/codecs/sta32x.c
> +++ b/sound/soc/codecs/sta32x.c
> @@ -524,13 +524,17 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream,
>  	rate = params_rate(params);
>  	pr_debug("rate: %u\n", rate);
>  	for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++)
> -		if (interpolation_ratios[i].fs == rate)
> +		if (interpolation_ratios[i].fs == rate) {
>  			ir = interpolation_ratios[i].ir;
> +			break;
> +		}
>  	if (ir < 0)
>  		return -EINVAL;
>  	for (i = 0; mclk_ratios[ir][i].ratio; i++)
> -		if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk)
> +		if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk) {
>  			mcs = mclk_ratios[ir][i].mcs;
> +			break;
> +		}
>  	if (mcs < 0)
>  		return -EINVAL;
>  
> -- 
> 1.7.4.1
> 
> 
> 
> 

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

* Re: [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs
  2011-08-14  3:31 [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs Axel Lin
  2011-08-15 12:25 ` Johannes Stezenbach
@ 2011-08-15 13:54 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-08-15 13:54 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Johannes Stezenbach, Liam Girdwood, alsa-devel

On Sun, Aug 14, 2011 at 11:31:04AM +0800, Axel Lin wrote:
> There is exactly one match or no match at all during the for loop iteration,
> thus we can break from the for loop once a match is found.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2011-08-15 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-14  3:31 [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs Axel Lin
2011-08-15 12:25 ` Johannes Stezenbach
2011-08-15 13:54 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox