mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@kernel.org>,
	 Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	 Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 3/5] regulator: adp5055: use of_property_read_[u32|s32]_default()
Date: Mon, 19 Jan 2026 10:02:56 +0800	[thread overview]
Message-ID: <20260119-add_dt_default-v1-3-db4787ea7a9e@nxp.com> (raw)
In-Reply-To: <20260119-add_dt_default-v1-0-db4787ea7a9e@nxp.com>

From: Peng Fan <peng.fan@nxp.com>

Switch to of_property_read_[u32|s32]_default() to reduce boilerplate and
make the "optional with default" intent explicit when parsing the DVS upper
and lower limits from DT.

While at it, fix dev_err_probe() calls with a proper error code: -EINVAL.

No functional changes apart from the error-path fix.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/regulator/adp5055-regulator.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/regulator/adp5055-regulator.c b/drivers/regulator/adp5055-regulator.c
index 4b004a6b2f84e8201228e7f542d83903031e00b7..e4a6d4c15772e54537ab00bc82ce05a5b0e7dc4d 100644
--- a/drivers/regulator/adp5055-regulator.c
+++ b/drivers/regulator/adp5055-regulator.c
@@ -218,25 +218,17 @@ static int adp5055_of_parse_cb(struct device_node *np,
 		adp5055->en_mode_software = true;
 	}
 
-	ret = of_property_read_u32(np, "adi,dvs-limit-upper-microvolt", &pval);
-	if (ret)
-		adp5055->dvs_limit_upper[id] = 192000;
-	else
-		adp5055->dvs_limit_upper[id] = pval;
-
-	if (adp5055->dvs_limit_upper[id] > 192000 || adp5055->dvs_limit_upper[id] < 12000)
-		return dev_err_probe(config->dev, adp5055->dvs_limit_upper[id],
-			"Out of range - dvs-limit-upper-microvolt value.");
-
-	ret = of_property_read_u32(np, "adi,dvs-limit-lower-microvolt", &pval);
-	if (ret)
-		adp5055->dvs_limit_lower[id] = -190500;
-	else
-		adp5055->dvs_limit_lower[id] = pval;
-
-	if (adp5055->dvs_limit_lower[id] > -10500 || adp5055->dvs_limit_lower[id] < -190500)
-		return dev_err_probe(config->dev, adp5055->dvs_limit_lower[id],
-			"Out of range - dvs-limit-lower-microvolt value.");
+	pval = of_property_read_u32_default(np, "adi,dvs-limit-upper-microvolt", 192000);
+	if (pval > 192000 || pval < 12000)
+		return dev_err_probe(config->dev, -EINVAL,
+				     "Out of range - dvs-limit-upper-microvolt value.");
+	adp5055->dvs_limit_upper[id] = pval;
+
+	pval = of_property_read_s32_default(np, "adi,dvs-limit-lower-microvolt", -190500);
+	if (pval > -10500 || pval < -190500)
+		return dev_err_probe(config->dev, -EINVAL,
+				     "Out of range - dvs-limit-lower-microvolt value.");
+	adp5055->dvs_limit_lower[id] = pval;
 
 	for (i = 0; i < 4; i++) {
 		ret = of_property_match_string(np, "adi,fast-transient",

-- 
2.37.1


  parent reply	other threads:[~2026-01-19  2:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19  2:02 [PATCH 0/5] of: Introduce *_read_*_default helpers and convert regulator drivers Peng Fan (OSS)
2026-01-19  2:02 ` [PATCH 1/5] of: Add of_property_read_[u32,s32]_default Peng Fan (OSS)
2026-01-20 22:21   ` Rob Herring
2026-01-23  6:58     ` Peng Fan
2026-01-19  2:02 ` [PATCH 2/5] regulator: of: Use of_property_read_u32_default() Peng Fan (OSS)
2026-01-19  2:02 ` Peng Fan (OSS) [this message]
2026-01-19  2:02 ` [PATCH 4/5] regulator: max77620: Use of_property_read_u32_default() for DT parsing Peng Fan (OSS)
2026-01-19  2:02 ` [PATCH 5/5] regulator: fan53555: " Peng Fan (OSS)

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=20260119-add_dt_default-v1-3-db4787ea7a9e@nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=alexisczezar.torreno@analog.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=robh@kernel.org \
    --cc=saravanak@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 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®