summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lm3532.c
diff options
context:
space:
mode:
authorDan Murphy <dmurphy@ti.com>2019-09-11 13:27:30 -0500
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2019-09-12 20:45:52 +0200
commit6d4faf3b6b6eb3c8a750b2e6659a5b1ff3dd9e75 (patch)
tree7a6d4f89960fa06353f9ed71ab7761f32a06a74f /drivers/leds/leds-lm3532.c
parent4016ba85880b252365d11bc7dc899450f2c73ad7 (diff)
leds: lm3532: Fix optional led-max-microamp prop error handling
Fix the error handling for the led-max-microamp property. Need to check if the property is present and then if it is retrieve the setting and its max boundary Reported-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lm3532.c')
-rw-r--r--drivers/leds/leds-lm3532.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index 62ace6698d25..0507c6575c08 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -601,11 +601,14 @@ static int lm3532_parse_node(struct lm3532_data *priv)
goto child_out;
}
- ret = fwnode_property_read_u32(child, "led-max-microamp",
- &led->full_scale_current);
-
- if (led->full_scale_current > LM3532_FS_CURR_MAX)
- led->full_scale_current = LM3532_FS_CURR_MAX;
+ if (fwnode_property_present(child, "led-max-microamp") &&
+ fwnode_property_read_u32(child, "led-max-microamp",
+ &led->full_scale_current))
+ dev_err(&priv->client->dev,
+ "Failed getting led-max-microamp\n");
+ else
+ led->full_scale_current = min(led->full_scale_current,
+ LM3532_FS_CURR_MAX);
if (led->mode == LM3532_BL_MODE_ALS) {
led->mode = LM3532_ALS_CTRL;