From 07b04723a609ec3a62acf1a5ba694c3d625c8354 Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Mon, 21 Aug 2017 19:16:37 -0700 Subject: [PATCH] leds: qpnp-wled: Cap the lower limit of brightness level As per the hardware documentation, operating limits of WLED is from 0.4% to 100%. Cap the lower limit to 0.4% to ensure proper operation. Change-Id: I7ee2684ea2186d4fdda5cea9a4d421b429a6d4fd Signed-off-by: Subbaraman Narayanamurthy --- drivers/leds/leds-qpnp-wled.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/leds/leds-qpnp-wled.c b/drivers/leds/leds-qpnp-wled.c index bfa7d29701da..c85b3e42c8c8 100644 --- a/drivers/leds/leds-qpnp-wled.c +++ b/drivers/leds/leds-qpnp-wled.c @@ -537,6 +537,11 @@ static int qpnp_wled_set_level(struct qpnp_wled *wled, int level) { int i, rc; u8 reg; + u16 low_limit = WLED_MAX_LEVEL_4095 * 4 / 1000; + + /* WLED's lower limit of operation is 0.4% */ + if (level > 0 && level < low_limit) + level = low_limit; /* set brightness registers */ for (i = 0; i < wled->max_strings; i++) {