OSDN Git Service

leds: qpnp-flash-v2: Modify current code calculation
authorSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Mon, 16 Apr 2018 21:00:12 +0000 (14:00 -0700)
committerSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Thu, 26 Apr 2018 20:07:08 +0000 (13:07 -0700)
Currently, the code calculated for a desired target current and
IRES is rounded up since DIV_ROUND_UP is used in the calculation.
With a higher IRES (12.5 mA), code can be configured to a higher
value. Fix this by using DIV_ROUND_CLOSEST so that the optimal
code can be obtained.

Change-Id: I51c1b15fff3ff2a23cb256f2ae1d341f5271adf2
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
drivers/leds/leds-qpnp-flash-v2.c

index a587759..c90633b 100644 (file)
@@ -319,7 +319,7 @@ static inline int get_current_reg_code(int target_curr_ma, int ires_ua)
        if (!ires_ua || !target_curr_ma || (target_curr_ma < (ires_ua / 1000)))
                return 0;
 
-       return DIV_ROUND_UP(target_curr_ma * 1000, ires_ua) - 1;
+       return DIV_ROUND_CLOSEST(target_curr_ma * 1000, ires_ua) - 1;
 }
 
 static int qpnp_flash_led_read(struct qpnp_flash_led *led, u16 addr, u8 *data)