* [PATCH] power: supply: Use dev_err_probe() for probe errors
@ 2026-12-05 15:26 Sumeet Pawnikar
2026-12-05 17:12 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Sumeet Pawnikar @ 2026-12-05 15:26 UTC (permalink / raw)
To: sre, wens, t.schramm, linux-pm; +Cc: linux-kernel, sumeet4linux
Use dev_err_probe() when registering the power supply in the
AXP20x battery driver and when initializing the CW2015 regmap.
This preserves the returned error while avoiding printing a raw
error pointer with %ld and handles deferred probing consistently.
Signed-off-by: Sumeet Pawnikar <sumeet4linux@gmail.com>
---
drivers/power/supply/axp20x_battery.c | 8 +++-----
drivers/power/supply/cw2015_battery.c | 8 +++-----
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index 4af1a209c9cf..4b5e41564a80 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -1118,11 +1118,9 @@ static int axp20x_power_probe(struct platform_device *pdev)
axp20x_batt->batt = devm_power_supply_register(&pdev->dev,
axp20x_batt->data->bat_ps_desc,
&psy_cfg);
- if (IS_ERR(axp20x_batt->batt)) {
- dev_err(&pdev->dev, "failed to register power supply: %ld\n",
- PTR_ERR(axp20x_batt->batt));
- return PTR_ERR(axp20x_batt->batt);
- }
+ if (IS_ERR(axp20x_batt->batt))
+ return dev_err_probe(&pdev->dev, PTR_ERR(axp20x_batt->batt),
+ "failed to register power supply\n");
if (!power_supply_get_battery_info(axp20x_batt->batt, &info)) {
axp20x_batt->data->set_bat_info(pdev, axp20x_batt, info);
diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 9fab56756dcf..f618c76cc55c 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -657,11 +657,9 @@ static int cw_bat_probe(struct i2c_client *client)
}
cw_bat->regmap = devm_regmap_init_i2c(client, &cw2015_regmap_config);
- if (IS_ERR(cw_bat->regmap)) {
- dev_err(cw_bat->dev, "Failed to allocate regmap: %ld\n",
- PTR_ERR(cw_bat->regmap));
- return PTR_ERR(cw_bat->regmap);
- }
+ if (IS_ERR(cw_bat->regmap))
+ return dev_err_probe(cw_bat->dev, PTR_ERR(cw_bat->regmap),
+ "Failed to allocate regmap\n");
ret = cw_init(cw_bat);
if (ret) {
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] power: supply: Use dev_err_probe() for probe errors
2026-12-05 15:26 [PATCH] power: supply: Use dev_err_probe() for probe errors Sumeet Pawnikar
@ 2026-12-05 17:12 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-12-05 17:12 UTC (permalink / raw)
To: Sumeet Pawnikar; +Cc: wens, t.schramm, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
Hi,
On Sat, Dec 05, 2026 at 08:56:26PM +0530, Sumeet Pawnikar wrote:
> Use dev_err_probe() when registering the power supply in the
> AXP20x battery driver and when initializing the CW2015 regmap.
>
> This preserves the returned error while avoiding printing a raw
> error pointer with %ld and handles deferred probing consistently.
>
> Signed-off-by: Sumeet Pawnikar <sumeet4linux@gmail.com>
> ---
> drivers/power/supply/axp20x_battery.c | 8 +++-----
> drivers/power/supply/cw2015_battery.c | 8 +++-----
> 2 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
> index 9fab56756dcf..f618c76cc55c 100644
> --- a/drivers/power/supply/cw2015_battery.c
> +++ b/drivers/power/supply/cw2015_battery.c
> @@ -657,11 +657,9 @@ static int cw_bat_probe(struct i2c_client *client)
> }
>
> cw_bat->regmap = devm_regmap_init_i2c(client, &cw2015_regmap_config);
> - if (IS_ERR(cw_bat->regmap)) {
> - dev_err(cw_bat->dev, "Failed to allocate regmap: %ld\n",
> - PTR_ERR(cw_bat->regmap));
> - return PTR_ERR(cw_bat->regmap);
> - }
> + if (IS_ERR(cw_bat->regmap))
> + return dev_err_probe(cw_bat->dev, PTR_ERR(cw_bat->regmap),
> + "Failed to allocate regmap\n");
-ENOMEM shouldn't print anything, just drop this error message. Also
split this into two patches.
Greetings,
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 15:26 [PATCH] power: supply: Use dev_err_probe() for probe errors Sumeet Pawnikar
2026-12-05 17:12 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox