public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@sig21.net>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lrg@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH] ASoC: sta32x: shortcut the for loop to get ir and mcs
Date: Mon, 15 Aug 2011 14:25:06 +0200	[thread overview]
Message-ID: <20110815122506.GA26490@sig21.net> (raw)
In-Reply-To: <1313292664.6074.1.camel@phoenix>

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
> 
> 
> 
> 

  reply	other threads:[~2011-08-15 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-08-15 13: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=20110815122506.GA26490@sig21.net \
    --to=js@sig21.net \
    --cc=alsa-devel@alsa-project.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