regulator: wm8350: Select maximum current in specific range
authorAxel Lin <axel.lin@ingics.com>
Tue, 12 Mar 2019 16:33:55 +0000 (00:33 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 13 Mar 2019 15:13:44 +0000 (15:13 +0000)
.set_current_limit callback should select the current closest to max_uA.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/wm8350-regulator.c

index a1c7dfee5c37d74288938d02eb099dde33205110..d1758a2bc769324e3f433bebbb670a0ac9b2d59e 100644 (file)
@@ -99,7 +99,7 @@ static int get_isink_val(int min_uA, int max_uA, u16 *setting)
 {
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(isink_cur); i++) {
+       for (i = ARRAY_SIZE(isink_cur) - 1; i >= 0; i--) {
                if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
                        *setting = i;
                        return 0;