From: Sumeet Pawnikar <sumeet4linux@gmail.com>
To: sre@kernel.org, wens@kernel.org, t.schramm@manjaro.org,
linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, sumeet4linux@gmail.com
Subject: [PATCH] power: supply: Use dev_err_probe() for probe errors
Date: Sat, 5 Dec 2026 20:56:26 +0530 [thread overview]
Message-ID: <20261205152626.720455-1-sumeet4linux@gmail.com> (raw)
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
next reply other threads:[~2026-12-05 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 15:26 Sumeet Pawnikar [this message]
2026-12-05 17:12 ` [PATCH] power: supply: Use dev_err_probe() for probe errors Sebastian Reichel
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=20261205152626.720455-1-sumeet4linux@gmail.com \
--to=sumeet4linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=t.schramm@manjaro.org \
--cc=wens@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.