All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robby Cai <robby.cai@nxp.com>
To: lgirdwood@gmail.com, broonie@kernel.org, andreas@kemnade.info
Cc: imx@lists.linux.dev, linux-kernel@vger.kernel.org, robby.cai@nxp.com
Subject: [PATCH] regulator: fp9931: Fix error handling for optional regulator
Date: Thu, 12 Mar 2026 12:01:48 +0800	[thread overview]
Message-ID: <20260312040148.GA4007088@shlinux88> (raw)

If "vin" reg does not exist in the device tree, the regulator framework
returns -ENODEV, which is normal for an optional supply. But the current
code treats -ENODEV as a fatal error, causing the driver probe to fail.
This patch fixes that by handling -ENODEV correctly for optional regulator.

Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Robby Cai <robby.cai@nxp.com>
---
 drivers/regulator/fp9931.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index 7fbcc6327cc63..fa7f32adfb666 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -448,9 +448,13 @@ static int fp9931_probe(struct i2c_client *client)
 				     "failed to allocate regmap!\n");
 
 	data->vin_reg = devm_regulator_get_optional(&client->dev, "vin");
-	if (IS_ERR(data->vin_reg))
-		return dev_err_probe(&client->dev, PTR_ERR(data->vin_reg),
-				     "failed to get vin regulator\n");
+	if (IS_ERR(data->vin_reg)) {
+		if (PTR_ERR(data->vin_reg) != -ENODEV)
+			return dev_err_probe(&client->dev, PTR_ERR(data->vin_reg),
+					     "failed to get vin regulator\n");
+
+		data->vin_reg = NULL;
+	}
 
 	data->pgood_gpio = devm_gpiod_get(&client->dev, "pg", GPIOD_IN);
 	if (IS_ERR(data->pgood_gpio))
-- 
2.37.1


             reply	other threads:[~2026-03-12  4:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12  4:01 Robby Cai [this message]
2026-03-12 17:34 ` [PATCH] regulator: fp9931: Fix error handling for optional regulator Mark Brown
2026-03-12 17:58 ` Andreas Kemnade
2026-03-12 18:00   ` Mark Brown
2026-03-13  0:27     ` Robby Cai
2026-03-13  0:24   ` Robby Cai

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=20260312040148.GA4007088@shlinux88 \
    --to=robby.cai@nxp.com \
    --cc=andreas@kemnade.info \
    --cc=broonie@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.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.