Re: [PATCH v2 2/5] leds: lm3692x: Don't overwrite return value in error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,
On Fri, Sep 20, 2019 at 06:48:59AM -0500, Dan Murphy wrote:
> Guido
> 
> On 9/20/19 12:27 AM, Guido Günther wrote:
> > The driver currently reports successful initialization on every failure
> > as long as it's able to power off the regulator. Don't check the return
> > value of regulator_disable to avoid that.
> > 
> > Signed-off-by: Guido Günther <agx@xxxxxxxxxxx>
> > ---
> >   drivers/leds/leds-lm3692x.c | 7 ++++---
> >   1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> > index 487228c2bed2..31115655f97b 100644
> > --- a/drivers/leds/leds-lm3692x.c
> > +++ b/drivers/leds/leds-lm3692x.c
> > @@ -198,7 +198,7 @@ static int lm3692x_brightness_set(struct led_classdev *led_cdev,
> >   static int lm3692x_init(struct lm3692x_led *led)
> >   {
> >   	int enable_state;
> > -	int ret;
> > +	int ret, ret2;
> >   	if (led->regulator) {
> >   		ret = regulator_enable(led->regulator);
> > @@ -313,14 +313,15 @@ static int lm3692x_init(struct lm3692x_led *led)
> >   		gpiod_direction_output(led->enable_gpio, 0);
> >   	if (led->regulator) {
> > -		ret = regulator_disable(led->regulator);
> > -		if (ret)
> > +		ret2 = regulator_disable(led->regulator);
> > +		if (ret2)
> >   			dev_err(&led->client->dev,
> >   				"Failed to disable regulator\n");
> 
> s/ret2/reg_ret
> 
> Like you did in patch 1 log the error code as well.
> 
> If regulator_disabled failed you might want to send that error code but
> either error returned is fine.

Changed in v3 - i opted to return the original error code since this is
likely what upper layers care about and only printk the regulator
failure one.
Thanks for the review,
 -- Guido

> 
> Dan
> 
> 
> >   	}
> >   	return ret;
> >   }
> > +
> >   static int lm3692x_probe_dt(struct lm3692x_led *led)
> >   {
> >   	struct fwnode_handle *child = NULL;
> 



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux