Commit 6d4faf3b authored by Dan Murphy's avatar Dan Murphy Committed by Jacek Anaszewski
Browse files

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: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarDan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent 4016ba85
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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;