Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>, pavel@ucw.cz
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] leds: lm3532: Fix optional led-max-microamp prop error handling
Date: Thu, 12 Sep 2019 20:32:54 +0200
Message-ID: <fe7c340b-65b9-f3eb-eb7a-f359f258ccca@gmail.com> (raw)
In-Reply-To: <20190911182730.22409-1-dmurphy@ti.com>

Hi Dan,

Thank you for the update.

On 9/11/19 8:27 PM, Dan Murphy wrote:
> 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;
> 

Applied.

-- 
Best regards,
Jacek Anaszewski

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 18:27 Dan Murphy
2019-09-12 18:32 ` Jacek Anaszewski [this message]
2019-09-12 19:12   ` Jacek Anaszewski
2019-09-12 19:47     ` Dan Murphy

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe7c340b-65b9-f3eb-eb7a-f359f258ccca@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org linux-leds@archiver.kernel.org
	public-inbox-index linux-leds


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/ public-inbox