Linux Power Management development
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Dzmitry Sankouski <dsankouski@gmail.com>
Cc: Sebastian Reichel <sre@kernel.org>, Lee Jones <lee@kernel.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] power: supply: max77705: Fix error code in max77705_get_health()
Date: Wed, 26 Mar 2025 18:14:13 +0100	[thread overview]
Message-ID: <658c41d0-734b-4397-9687-80b6a219c61c@linaro.org> (raw)
In-Reply-To: <0ea50e87-2b63-4062-8c2a-17537495f481@stanley.mountain>

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@linaro.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).

The EINVAL is when the data could not be read, thus user-space should
ignore 'val'.


Best regards,
Krzysztof

  reply	other threads:[~2025-03-26 17:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21 14:34 [PATCH 0/2] power: supply: max77705: Fix two static checker issues Dan Carpenter
2025-03-21 14:34 ` [PATCH 1/2] power: supply: max77705: Fix workqueue error handling in probe Dan Carpenter
2025-03-22 16:48   ` Krzysztof Kozlowski
2025-03-21 14:34 ` [PATCH 2/2] power: supply: max77705: Fix error code in max77705_get_health() Dan Carpenter
2025-03-26 17:14   ` Krzysztof Kozlowski [this message]
2025-03-26 17:27     ` Dan Carpenter
2025-04-28 22:18 ` (subset) [PATCH 0/2] power: supply: max77705: Fix two static checker issues Sebastian Reichel
2025-04-28 23:30   ` Sebastian Reichel

Reply instructions:

You may reply publicly 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=658c41d0-734b-4397-9687-80b6a219c61c@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dsankouski@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox