leds: leds-qpnp: check if flash_wa regulator is obtained before enabling
The flash led requires the use of an optional regulator, "flash_wa_reg".
This regulator is enabled without checking if the regulator is obtained
or not. Hence, a check is made before enabling/disabing the regulator to
ensure that the "flash_wa_reg" is obtained first.
Change-Id: I8fda00274ad3bc21d9ed32d0f3f2ca09e1079f87
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
diff --git a/drivers/leds/leds-qpnp.c b/drivers/leds/leds-qpnp.c
index 2bd13af..8774df6 100755
--- a/drivers/leds/leds-qpnp.c
+++ b/drivers/leds/leds-qpnp.c
@@ -2778,16 +2778,16 @@
if (of_find_property(of_get_parent(node), "flash-wa-supply",
NULL) && (!*reg_set)) {
led->flash_cfg->flash_wa_reg =
- devm_regulator_get(&led->spmi_dev->dev, "flash-wa");
+ devm_regulator_get(&led->spmi_dev->dev, "flash-wa");
if (IS_ERR_OR_NULL(led->flash_cfg->flash_wa_reg)) {
rc = PTR_ERR(led->flash_cfg->flash_wa_reg);
if (rc != EPROBE_DEFER) {
dev_err(&led->spmi_dev->dev,
- "Flash wa regulator get failed(%d)\n",
- rc);
+ "Flash wa regulator get failed(%d)\n",
+ rc);
}
- }
- led->flash_cfg->flash_wa_reg_get = true;
+ } else
+ led->flash_cfg->flash_wa_reg_get = true;
}
if (led->id == QPNP_ID_FLASH1_LED0) {