lkml.org 
[lkml]   [2019]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] leds: lm3532: Fix optional led-max-microamp prop error handling
Date
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>
---

v2 - Changed full scale current check to use min function

drivers/leds/leds-lm3532.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index 62ace6698d25..a1742dc1f6fa 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -601,11 +601,15 @@ 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")) {
+ if (fwnode_property_read_u32(child, "led-max-microamp",
+ &led->full_scale_current))
+ dev_err(&priv->client->dev,
+ "Failed getting led-max-microamp\n");
+ else
+ min(led->full_scale_current,
+ LM3532_FS_CURR_MAX);
+ }

if (led->mode == LM3532_BL_MODE_ALS) {
led->mode = LM3532_ALS_CTRL;
--
2.22.0.214.g8dca754b1e
\
 
 \ /
  Last update: 2019-09-11 20:28    [W:0.047 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site