* [PATCH] power: supply: bq25630: Release battery information after setup @ 2026-07-27 9:37 Linmao Li 2026-07-27 12:43 ` Waqar Hameed 0 siblings, 1 reply; 3+ messages in thread From: Linmao Li @ 2026-07-27 9:37 UTC (permalink / raw) To: Sebastian Reichel; +Cc: Waqar Hameed, linux-pm, Linmao Li 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. Release it right after setup, as bq256xx and bq257xx do. Signed-off-by: Linmao Li <lilinmao@kylinos.cn> --- drivers/power/supply/bq25630_charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/bq25630_charger.c b/drivers/power/supply/bq25630_charger.c index 165f8c67b4895..efcdb1f5bc351 100644 --- a/drivers/power/supply/bq25630_charger.c +++ b/drivers/power/supply/bq25630_charger.c @@ -1045,10 +1045,9 @@ static int bq25630_probe(struct i2c_client *client) return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); ret = bq25630_setup(data); - if (ret) - return ret; + power_supply_put_battery_info(data->psy, data->batinfo); - return 0; + return ret; } static const struct of_device_id bq25630_of_match[] = { -- 2.25.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: bq25630: Release battery information after setup 2026-07-27 9:37 [PATCH] power: supply: bq25630: Release battery information after setup Linmao Li @ 2026-07-27 12:43 ` Waqar Hameed 2026-07-27 20:49 ` Sebastian Reichel 0 siblings, 1 reply; 3+ messages in thread From: Waqar Hameed @ 2026-07-27 12:43 UTC (permalink / raw) To: Linmao Li; +Cc: Sebastian Reichel, linux-pm On Mon, Jul 27, 2026 at 17:37 +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. Release it right after setup, as bq256xx > and bq257xx do. > > Signed-off-by: Linmao Li <lilinmao@kylinos.cn> > --- > drivers/power/supply/bq25630_charger.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/power/supply/bq25630_charger.c b/drivers/power/supply/bq25630_charger.c > index 165f8c67b4895..efcdb1f5bc351 100644 > --- a/drivers/power/supply/bq25630_charger.c > +++ b/drivers/power/supply/bq25630_charger.c > @@ -1045,10 +1045,9 @@ static int bq25630_probe(struct i2c_client *client) > return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); > > ret = bq25630_setup(data); > - if (ret) > - return ret; > + power_supply_put_battery_info(data->psy, data->batinfo); > > - return 0; > + return ret; > } > > static const struct of_device_id bq25630_of_match[] = { The initial thought was that `batinfo` could/would be used elsewhere, but as you point out, it's currently not. A better design is then to move the `power_supply_get_battery_info()` into `bq25630_setup()`, in order to scope the `get/put()`. So let's get `batinfo` there, just before using it, and have an error/clean-up-path there as well. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: bq25630: Release battery information after setup 2026-07-27 12:43 ` Waqar Hameed @ 2026-07-27 20:49 ` Sebastian Reichel 0 siblings, 0 replies; 3+ messages in thread From: Sebastian Reichel @ 2026-07-27 20:49 UTC (permalink / raw) To: Waqar Hameed; +Cc: Linmao Li, linux-pm [-- Attachment #1: Type: text/plain, Size: 1950 bytes --] Hi, On Mon, Jul 27, 2026 at 02:43:37PM +0200, Waqar Hameed wrote: > On Mon, Jul 27, 2026 at 17:37 +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. Release it right after setup, as bq256xx > > and bq257xx do. > > > > Signed-off-by: Linmao Li <lilinmao@kylinos.cn> > > --- > > drivers/power/supply/bq25630_charger.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/power/supply/bq25630_charger.c b/drivers/power/supply/bq25630_charger.c > > index 165f8c67b4895..efcdb1f5bc351 100644 > > --- a/drivers/power/supply/bq25630_charger.c > > +++ b/drivers/power/supply/bq25630_charger.c > > @@ -1045,10 +1045,9 @@ static int bq25630_probe(struct i2c_client *client) > > return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); > > > > ret = bq25630_setup(data); > > - if (ret) > > - return ret; > > + power_supply_put_battery_info(data->psy, data->batinfo); > > > > - return 0; > > + return ret; > > } > > > > static const struct of_device_id bq25630_of_match[] = { > > The initial thought was that `batinfo` could/would be used elsewhere, > but as you point out, it's currently not. A better design is then to > move the `power_supply_get_battery_info()` into `bq25630_setup()`, in > order to scope the `get/put()`. So let's get `batinfo` there, just > before using it, and have an error/clean-up-path there as well. Agreed. Keeping an invalid pointer makes no sense. The setup routine is also a good candidate for the new .init callback now available in struct power_supply_desc, so that the registers are initialized before the device is exposed to the system. Greetings, -- Sebastian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-27 20:50 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-27 9:37 [PATCH] power: supply: bq25630: Release battery information after setup Linmao Li 2026-07-27 12:43 ` Waqar Hameed 2026-07-27 20:49 ` Sebastian Reichel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox