misc: pm8058-pwm: select higher resolution if possible
More bits in PWM size means higher resolution, which is preferred
if we have such choice without sacrificing accuracy.
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
diff --git a/drivers/misc/pmic8058-pwm.c b/drivers/misc/pmic8058-pwm.c
index 93d89f0..059e767 100644
--- a/drivers/misc/pmic8058-pwm.c
+++ b/drivers/misc/pmic8058-pwm.c
@@ -357,6 +357,12 @@
}
}
+ /* Use higher resolution */
+ if (best_m >= 3 && n == 6) {
+ n += 3;
+ best_m -= 3;
+ }
+
period->pwm_size = n;
period->clk = best_clk;
period->pre_div = best_div;