]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
ASoC: arizona: Correct checking of FLL ratio limitations
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Wed, 9 Jul 2014 16:41:44 +0000 (17:41 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 10 Jul 2014 10:09:15 +0000 (12:09 +0200)
The check to ensure the Fref frequency is within the bounds for the
current ratio, was placed in the wrong loop. The initial configuration
will always be valid and the loop lowering the ratio will only reinforce
this validity. The check should be on the loop increasing the ratio.
This could on occasion cause an invalid ratio/Fref combination to be
selected.

Reported-by: Ryo Tsutsui <ryo.tsutsui@wolfsonmicro.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/codecs/arizona.c

index b03974eb541ef44d7ab5cd6ad3917b908941017a..4c4727f0837ce47ad904ce0147bec306c2ed57b2 100644 (file)
@@ -1578,6 +1578,10 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
        while (div <= ARIZONA_FLL_MAX_REFDIV) {
                for (ratio = init_ratio; ratio <= ARIZONA_FLL_MAX_FRATIO;
                     ratio++) {
+                       if (ARIZONA_FLL_VCO_CORNER / (fll->vco_mult * ratio) <
+                           Fref)
+                               break;
+
                        if (target % (ratio * Fref)) {
                                cfg->refdiv = refdiv;
                                cfg->fratio = ratio - 1;
@@ -1586,10 +1590,6 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
                }
 
                for (ratio = init_ratio - 1; ratio > 0; ratio--) {
-                       if (ARIZONA_FLL_VCO_CORNER / (fll->vco_mult * ratio) <
-                           Fref)
-                               break;
-
                        if (target % (ratio * Fref)) {
                                cfg->refdiv = refdiv;
                                cfg->fratio = ratio - 1;