From: "Pali Rohár" <pali@kernel.org>
To: Hermes Zhang <chenhui.zhang@axis.com>
Cc: lars@metafoo.de, Sebastian Reichel <sre@kernel.org>,
kernel@axis.com, Hermes Zhang <chenhuiz@axis.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: bq27xxx: Return the value instead of -ENODATA
Date: Wed, 31 Mar 2021 16:02:38 +0200 [thread overview]
Message-ID: <20210331140238.jl3qprpqhqave4bf@pali> (raw)
In-Reply-To: <20210331135141.8063-1-chenhui.zhang@axis.com>
On Wednesday 31 March 2021 21:51:41 Hermes Zhang wrote:
> From: Hermes Zhang <chenhuiz@axis.com>
>
> It might be better to return value (e.g. 65535) instead of an error
> (e.g. No data available) for the time property.
>
> Normally a common function will handle the read string and parse to
> integer for all the properties, but will have problem when read the
> time property because need to handle the NODATA error as non-error.
> So it will make simple for application which indicate success when
> read a number, otherwise as an error to handle.
>
> Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
> ---
> drivers/power/supply/bq27xxx_battery.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 4c4a7b1c64c5..b75e54aa8ada 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -1655,9 +1655,6 @@ static int bq27xxx_battery_read_time(struct bq27xxx_device_info *di, u8 reg)
> return tval;
> }
>
> - if (tval == 65535)
> - return -ENODATA;
> -
> return tval * 60;
I'm not sure if this is correct change. If value 65535 is special which
indicates that data are not available then driver should not return
(converted) value 65535*60. If -ENODATA is there to indicate that data
are not available then -ENODATA should not be used.
And if there is application which does not handle -ENODATA for state
when data are not available then it is a bug in application.
> }
>
> --
> 2.20.1
>
next prev parent reply other threads:[~2021-03-31 14:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 13:51 Hermes Zhang
2021-03-31 14:02 ` Pali Rohár [this message]
2021-04-01 1:51 ` Hermes Zhang
2021-04-01 8:50 ` Pali Rohár
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=20210331140238.jl3qprpqhqave4bf@pali \
--to=pali@kernel.org \
--cc=chenhui.zhang@axis.com \
--cc=chenhuiz@axis.com \
--cc=kernel@axis.com \
--cc=lars@metafoo.de \
--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
all inboxes | Powered by JetHome®