lkml.org 
[lkml]   [2019]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator
From
Date
Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> Instead use devm_regulator_get_optional since the regulator
> is optional and check for errors.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
> drivers/leds/leds-lm3692x.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index f394669ad8f2..9972c932d51e 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -333,9 +333,14 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
> return ret;
> }
>
> - led->regulator = devm_regulator_get(&led->client->dev, "vled");
> - if (IS_ERR(led->regulator))
> - led->regulator = NULL;
> + led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
> + if (IS_ERR(led->regulator)) {
> + ret = PTR_ERR(led->regulator);
> + if (ret != -EPROBE_DEFER)
> + dev_err(&led->client->dev,
> + "Failed to get vled regulator: %d\n", ret);
nitpick. Add a new line for readability
> + return ret;
> + }

If the regulator is not set then led->regulator should be set to NULL.

Dan


>
> child = device_get_next_child_node(&led->client->dev, child);
> if (!child) {

\
 
 \ /
  Last update: 2019-09-18 20:40    [W:0.132 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site