From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Frieder Schrempf <frieder.schrempf@kontron.de>,
Robin Gong <yibin.gong@nxp.com>
Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] regulator: pca9450: use dev_err_probe on errors requesting resources
Date: Tue, 17 Dec 2024 09:59:25 +0100 [thread overview]
Message-ID: <20241217-pca9450-dev_err_probe-v1-1-04046092a92d@pengutronix.de> (raw)
Probe functions requesting resources may return -EPROBE_DEFER to
the driver core to instruct it to retry probe at a later time.
This is not unusual and printing an error message unconditionally
is just confusing to users:
nxp-pca9450 0-0025: Failed to register regulator(buck1): -517
Using dev_err_probe remedies this:
The error message will only be shown if the error code is not
-EPROBE_DEFER and if it is, the deferral reason is saved for display
at a later time.
Fixes: 0935ff5f1f0a ("regulator: pca9450: add pca9450 pmic driver")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/regulator/pca9450-regulator.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c
index 9714afe347dcc0205b40243252638dff5f9298ad..8f5ba59f7fe52bee1e467a3e6adf81a6a5476221 100644
--- a/drivers/regulator/pca9450-regulator.c
+++ b/drivers/regulator/pca9450-regulator.c
@@ -953,13 +953,10 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)
config.dev = pca9450->dev;
rdev = devm_regulator_register(pca9450->dev, desc, &config);
- if (IS_ERR(rdev)) {
- ret = PTR_ERR(rdev);
- dev_err(pca9450->dev,
- "Failed to register regulator(%s): %d\n",
- desc->name, ret);
- return ret;
- }
+ if (IS_ERR(rdev))
+ return dev_err_probe(pca9450->dev, PTR_ERR(rdev),
+ "Failed to register regulator(%s)\n",
+ desc->name);
}
if (pca9450->irq) {
@@ -968,9 +965,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)
(IRQF_TRIGGER_FALLING | IRQF_ONESHOT),
"pca9450-irq", pca9450);
if (ret != 0) {
- dev_err(pca9450->dev, "Failed to request IRQ: %d\n",
- pca9450->irq);
- return ret;
+ return dev_err_probe(pca9450->dev, ret,
+ "Failed to request IRQ: %d\n",
+ pca9450->irq);
}
/* Unmask all interrupt except PWRON/WDOG/RSVD */
ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_INT1_MSK,
@@ -1022,10 +1019,10 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)
*/
pca9450->sd_vsel_gpio = gpiod_get_optional(pca9450->dev, "sd-vsel", GPIOD_OUT_HIGH);
- if (IS_ERR(pca9450->sd_vsel_gpio)) {
- dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n");
- return PTR_ERR(pca9450->sd_vsel_gpio);
- }
+ if (IS_ERR(pca9450->sd_vsel_gpio))
+ return dev_err_probe(&i2c->dev,
+ PTR_ERR(pca9450->sd_vsel_gpio),
+ "Failed to get SD_VSEL GPIO\n");
dev_info(&i2c->dev, "%s probed.\n",
type == PCA9450_TYPE_PCA9450A ? "pca9450a" :
---
base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
change-id: 20241217-pca9450-dev_err_probe-778149cae5ee
Best regards,
--
Ahmad Fatoum <a.fatoum@pengutronix.de>
next reply other threads:[~2024-12-17 8:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-17 8:59 Ahmad Fatoum [this message]
2024-12-17 9:04 ` Frieder Schrempf
2024-12-17 9:05 ` Ahmad Fatoum
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=20241217-pca9450-dev_err_probe-v1-1-04046092a92d@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=broonie@kernel.org \
--cc=frieder.schrempf@kontron.de \
--cc=kernel@pengutronix.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yibin.gong@nxp.com \
/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
all inboxes | Powered by JetHome®