mfd: pm8xxx-pwm: simplify code by eliminating macros
Simplify period preprocessing to favor n=9 for big period_us.
This removes MAX_MPT here with no disadvantage. Also remove
MAX_MPT as initial min_err because it doesn't have advantage
over using maximum unsigned integer value.
Change-Id: Ie905922802ed88f322a627b1a89f4c00cc214459
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
diff --git a/drivers/mfd/pm8xxx-pwm.c b/drivers/mfd/pm8xxx-pwm.c
index 6ffc7cc..a814827 100644
--- a/drivers/mfd/pm8xxx-pwm.c
+++ b/drivers/mfd/pm8xxx-pwm.c
@@ -177,9 +177,6 @@
},
};
-#define MIN_MPT ((PRE_DIVIDE_MIN * CLK_PERIOD_MIN) << PM8XXX_PWM_M_MIN)
-#define MAX_MPT ((PRE_DIVIDE_MAX * CLK_PERIOD_MAX) << PM8XXX_PWM_M_MAX)
-
/* Private data */
struct pm8xxx_pwm_chip;
@@ -345,20 +342,12 @@
if (period_us < ((unsigned)(-1) / NSEC_PER_USEC)) {
period_n = (period_us * NSEC_PER_USEC) >> 6;
n = 6;
- } else if (period_us < (274 * USEC_PER_SEC)) { /* overflow threshold */
- period_n = (period_us >> 6) * NSEC_PER_USEC;
- if (period_n >= MAX_MPT) {
- n = 9;
- period_n >>= 3;
- } else {
- n = 6;
- }
} else {
period_n = (period_us >> 9) * NSEC_PER_USEC;
n = 9;
}
- min_err = MAX_MPT;
+ min_err = (unsigned)(-1);
best_m = 0;
best_clk = 0;
best_div = 0;