[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1c61a172-f623-4698-b753-9c53af9b1275@stanley.mountain>
Date: Wed, 26 Mar 2025 20:27:23 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Cc: Dzmitry Sankouski <dsankouski@...il.com>,
Sebastian Reichel <sre@...nel.org>, Lee Jones <lee@...nel.org>,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] power: supply: max77705: Fix error code in
max77705_get_health()
On Wed, Mar 26, 2025 at 06:14:13PM +0100, Krzysztof Kozlowski wrote:
> On 21/03/2025 15:34, Dan Carpenter wrote:
> > Return -EINVAL if the health is bad. Don't return success.
> >
> > Fixes: a6a494c8e3ce ("power: supply: max77705: Add charger driver for Maxim 77705")
> > Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> > ---
> > drivers/power/supply/max77705_charger.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c
> > index 329b430d0e50..0e347353c41e 100644
> > --- a/drivers/power/supply/max77705_charger.c
> > +++ b/drivers/power/supply/max77705_charger.c
> > @@ -285,7 +285,7 @@ static int max77705_get_health(struct max77705_charger_data *charger, int *val)
> > if (is_online) {
> > ret = max77705_get_vbus_state(regmap, val);
> > if (ret || (*val != POWER_SUPPLY_HEALTH_GOOD))
> > - return ret;
> > + return -EINVAL;
>
>
> I don't think this is right. First, your commit msg should mention why
> returning -EINVAL in such case.
>
> Second, if get_vbus_state succeeded, but 'val' is not good (e.g.
> overvoltage), the callback is supposed to return 0 as success of
> retrieving the data, no? So the user-space can read 'val' and figure out
> whatever it needs to figure out (overvoltage).
>
Yeah. What you're saying makes sense, especially in context. I misread
the code.
regards,
dan carpenter
Powered by blists - more mailing lists