ASoC: sta32x: shortcut the for loop to get ir and mcs
authorAxel Lin <axel.lin@gmail.com>
Sun, 14 Aug 2011 03:31:04 +0000 (11:31 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 15 Aug 2011 13:54:11 +0000 (22:54 +0900)
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>
Acked-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/sta32x.c

index fbd7eb9e61ce197ae9c5bb22df308d618f9545eb..3d155f5266723a3a71369e894391ed865904b343 100644 (file)
@@ -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;