From 2e21ea63b32cbf4a2bf082e88b312c304f7353ef Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Mon, 15 Jan 2018 12:40:49 -0800 Subject: [PATCH] leds: qpnp-flash-v2: Update IRES for active LEDs Currently, whenever the switch LED device is triggered, IRES is updated based on the LEDs belonging to that switch LED device. However, this can overwrite IRES configuration if flash and torch LED devices have different IRES since they share the same id. Fix this by checking the active LED status which will be updated based on the brightness level set so that IRES will be updated for the correct LED (flash/torch) device. CRs-Fixed: 2173127 Change-Id: Ic3b5db2f56758ccd68fd80139aeb22f31723130e Signed-off-by: Subbaraman Narayanamurthy --- drivers/leds/leds-qpnp-flash-v2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-qpnp-flash-v2.c b/drivers/leds/leds-qpnp-flash-v2.c index de13d3367648..ec3f68b5d406 100644 --- a/drivers/leds/leds-qpnp-flash-v2.c +++ b/drivers/leds/leds-qpnp-flash-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1103,10 +1103,11 @@ static int qpnp_flash_led_switch_set(struct flash_switch_data *snode, bool on) return rc; } - /* Iterate over all leds for this switch node */ + /* Iterate over all active leds for this switch node */ val = 0; for (i = 0; i < led->num_fnodes; i++) - if (snode->led_mask & BIT(led->fnode[i].id)) + if (led->fnode[i].led_on && + snode->led_mask & BIT(led->fnode[i].id)) val |= led->fnode[i].ires_idx << (led->fnode[i].id * 2); rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_IRES(led->base), -- 2.11.0