From: Ninad Naik <ninadnaik07@gmail.com>
To: claudiu.beznea@tuxon.dev, andrei.simion@microchip.com,
lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
me@brighamcampbell.com, Ninad Naik <ninadnaik07@gmail.com>
Subject: [PATCH] regulator: mcp16502: Convert to dev_err_probe() in mcp16502_probe()
Date: Wed, 15 Jul 2026 00:52:28 +0530 [thread overview]
Message-ID: <20260714192228.1639768-1-ninadnaik07@gmail.com> (raw)
The mcp16502_probe() currently uses dev_err() for logging errors.
However, functions like devm_regmap_init_i2c, devm_gpiod_get_optional
and devm_regulator_register can return -EPROBE_DEFER. Using dev_err()
in these situations can cause unnecessary error spam in dmesg.
As a result, convert to dev_err_probe(). It also simplifies the print
and return operations into single statement. The 'ret' variable is no
longer required and has been removed.
Originally detected by Coccinelle with this warning "Consider using
%pe to print PTR_ERR()"
Compile-tested only.
Signed-off-by: Ninad Naik <ninadnaik07@gmail.com>
---
drivers/regulator/mcp16502.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/regulator/mcp16502.c b/drivers/regulator/mcp16502.c
index b34ae0bbba6f..fea0f6a2f21b 100644
--- a/drivers/regulator/mcp16502.c
+++ b/drivers/regulator/mcp16502.c
@@ -508,7 +508,7 @@ static int mcp16502_probe(struct i2c_client *client)
struct device *dev;
struct mcp16502 *mcp;
struct regmap *rmap;
- int i, ret;
+ int i;
dev = &client->dev;
config.dev = dev;
@@ -518,30 +518,23 @@ static int mcp16502_probe(struct i2c_client *client)
return -ENOMEM;
rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
- if (IS_ERR(rmap)) {
- ret = PTR_ERR(rmap);
- dev_err(dev, "regmap init failed: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(rmap))
+ return dev_err_probe(dev, PTR_ERR(rmap), "regmap init failed\n");
i2c_set_clientdata(client, mcp);
config.regmap = rmap;
config.driver_data = mcp;
mcp->lpm = devm_gpiod_get_optional(dev, "lpm", GPIOD_OUT_LOW);
- if (IS_ERR(mcp->lpm)) {
- dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm));
- return PTR_ERR(mcp->lpm);
- }
+ if (IS_ERR(mcp->lpm))
+ return dev_err_probe(dev, PTR_ERR(mcp->lpm), "failed to get lpm pin\n");
for (i = 0; i < NUM_REGULATORS; i++) {
rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
- if (IS_ERR(rdev)) {
- dev_err(dev,
- "failed to register %s regulator %ld\n",
- mcp16502_desc[i].name, PTR_ERR(rdev));
- return PTR_ERR(rdev);
- }
+ if (IS_ERR(rdev))
+ return dev_err_probe(dev, PTR_ERR(rdev),
+ "failed to register %s regulator\n",
+ mcp16502_desc[i].name);
}
mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
--
2.55.0
reply other threads:[~2026-07-14 19:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260714192228.1639768-1-ninadnaik07@gmail.com \
--to=ninadnaik07@gmail.com \
--cc=andrei.simion@microchip.com \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=me@brighamcampbell.com \
--cc=skhan@linuxfoundation.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