From: Waqar Hameed <waqar.hameed@axis.com>
To: Linmao Li <lilinmao@kylinos.cn>
Cc: Sebastian Reichel <sre@kernel.org>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] power: supply: bq25630: Scope battery information to bq25630_setup()
Date: Wed, 29 Jul 2026 23:07:15 +0200 [thread overview]
Message-ID: <pnd8q6t33p8.a.out@axis.com> (raw)
In-Reply-To: <20260728024558.3611522-2-lilinmao@kylinos.cn> (Linmao Li's message of "Tue, 28 Jul 2026 10:45:57 +0800")
On Tue, Jul 28, 2026 at 10:45 +0800 Linmao Li <lilinmao@kylinos.cn> wrote:
> data->batinfo is only used by bq25630_setup() to program the initial
> charge limits, but power_supply_get_battery_info() allocates it on
> psy->dev, so it stays around for the lifetime of the device. Nothing
> else in the driver uses it.
>
> Get the battery information in bq25630_setup(), just before it is read,
> and release it on every path out of that function. The driver data no
> longer has to carry the pointer.
>
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Much better! However, `git` complains:
$ git am /path/to/patch
error: cannot convert from y to UTF-8
fatal: could not parse patch
LKML also warns about this [1]. I was able to force UTF-8 and workaround
this though... You might want check your setup.
> ---
> drivers/power/supply/bq25630_charger.c | 47 ++++++++++++++------------
> 1 file changed, 25 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/power/supply/bq25630_charger.c b/drivers/power/supply/bq25630_charger.c
> index 165f8c67b489..9b5f524505d3 100644
> --- a/drivers/power/supply/bq25630_charger.c
> +++ b/drivers/power/supply/bq25630_charger.c
> @@ -356,7 +356,6 @@ struct bq25630_data {
> struct regmap_field *regfields[BQ25630_REGF_MAX];
>
> struct power_supply *psy;
> - struct power_supply_battery_info *batinfo;
>
> /* State status from IRQs. */
> u8 statregs[BQ25630_NR_STAT_REGS];
> @@ -668,6 +667,7 @@ static int bq25630_reset(struct bq25630_data *data)
>
> static int bq25630_setup(struct bq25630_data *data)
> {
> + struct power_supply_battery_info *batinfo;
> int ret;
>
> ret = bq25630_reset(data);
> @@ -684,69 +684,77 @@ static int bq25630_setup(struct bq25630_data *data)
> return ret;
> }
>
> + ret = power_supply_get_battery_info(data->psy, &batinfo);
> + if (ret)
> + return dev_err_probe(data->dev, ret,
> + "Could not get battery info\n");
> +
`dev_err_probe()` shouldn't be used here. Yes, it is _currently_ only
used from `probe()`, but that shouldn't be an assumption/"policy".
Better to let caller decide on that. I understand that it was just a
pure copy-paste from `probe()`, but we should change it do `dev_error()`
to match the rest of this function.
[...]
[1] https://lore.kernel.org/lkml/20260728024558.3611522-2-lilinmao@kylinos.cn/
next prev parent reply other threads:[~2026-07-29 21:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 2:45 [PATCH v2 0/2] power: supply: bq25630: Improve hardware setup Linmao Li
2026-07-28 2:45 ` [PATCH v2 1/2] power: supply: bq25630: Scope battery information to bq25630_setup() Linmao Li
2026-07-29 21:07 ` Waqar Hameed [this message]
2026-07-28 2:45 ` [PATCH v2 2/2] power: supply: bq25630: Initialize hardware before exposing the power supply Linmao Li
2026-07-29 21:07 ` Waqar Hameed
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=pnd8q6t33p8.a.out@axis.com \
--to=waqar.hameed@axis.com \
--cc=lilinmao@kylinos.cn \
--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;
as well as URLs for NNTP newsgroup(s).