Re: [PATCH] power: supply: Use dev_err_probe() for probe errors
From: Sebastian Reichel
Date: Sat Dec 05 2026 - 12:13:08 EST
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@xxxxxxxxx>
> ---
> 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:
signature.asc
Description: PGP signature