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 4/5] regulator: max77620: Use of_property_read_u32_default() for DT parsing
Date: Mon, 19 Jan 2026 10:02:57 +0800 [thread overview]
Message-ID: <20260119-add_dt_default-v1-4-db4787ea7a9e@nxp.com> (raw)
In-Reply-To: <20260119-add_dt_default-v1-0-db4787ea7a9e@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
Switch max77620_of_parse_cb() to of_property_read_u32_default() to simplify
device tree property parsing and remove duplicated error handling.
Properties that previously defaulted to -1 now explicitly use -1U,
preserving the original semantics.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/regulator/max77620-regulator.c | 40 ++++++++++++++--------------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
index 7bc87d8e9f686651067b443c06d0791557e1d1e6..6ba3c2a995198234c0aef5dfe445ef291e8be2dd 100644
--- a/drivers/regulator/max77620-regulator.c
+++ b/drivers/regulator/max77620-regulator.c
@@ -605,38 +605,30 @@ static int max77620_of_parse_cb(struct device_node *np,
{
struct max77620_regulator *pmic = config->driver_data;
struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[desc->id];
- u32 pval;
- int ret;
- ret = of_property_read_u32(np, "maxim,active-fps-source", &pval);
- rpdata->active_fps_src = (!ret) ? pval : MAX77620_FPS_SRC_DEF;
+ rpdata->active_fps_src =
+ of_property_read_u32_default(np, "maxim,active-fps-source", MAX77620_FPS_SRC_DEF);
- ret = of_property_read_u32(np, "maxim,active-fps-power-up-slot", &pval);
- rpdata->active_fps_pu_slot = (!ret) ? pval : -1;
+ rpdata->active_fps_pu_slot =
+ of_property_read_u32_default(np, "maxim,active-fps-power-up-slot", -1U);
- ret = of_property_read_u32(
- np, "maxim,active-fps-power-down-slot", &pval);
- rpdata->active_fps_pd_slot = (!ret) ? pval : -1;
+ rpdata->active_fps_pd_slot =
+ of_property_read_u32_default(np, "maxim,active-fps-power-down-slot", -1U);
- ret = of_property_read_u32(np, "maxim,suspend-fps-source", &pval);
- rpdata->suspend_fps_src = (!ret) ? pval : -1;
+ rpdata->suspend_fps_src =
+ of_property_read_u32_default(np, "maxim,suspend-fps-source", -1U);
- ret = of_property_read_u32(
- np, "maxim,suspend-fps-power-up-slot", &pval);
- rpdata->suspend_fps_pu_slot = (!ret) ? pval : -1;
+ rpdata->suspend_fps_pu_slot =
+ of_property_read_u32_default(np, "maxim,suspend-fps-power-up-slot", -1U);
- ret = of_property_read_u32(
- np, "maxim,suspend-fps-power-down-slot", &pval);
- rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
+ rpdata->suspend_fps_pd_slot =
+ of_property_read_u32_default(np, "maxim,suspend-fps-power-down-slot", -1U);
- ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
- if (!ret)
- rpdata->power_ok = pval;
- else
- rpdata->power_ok = -1;
+ rpdata->power_ok =
+ of_property_read_u32_default(np, "maxim,power-ok-control", -1U);
- ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
- rpdata->ramp_rate_setting = (!ret) ? pval : 0;
+ rpdata->ramp_rate_setting =
+ of_property_read_u32_default(np, "maxim,ramp-rate-setting", 0);
return max77620_init_pmic(pmic, desc->id);
}
--
2.37.1
next prev 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 ` [PATCH 3/5] regulator: adp5055: use of_property_read_[u32|s32]_default() Peng Fan (OSS)
2026-01-19 2:02 ` Peng Fan (OSS) [this message]
2026-01-19 2:02 ` [PATCH 5/5] regulator: fan53555: Use of_property_read_u32_default() for DT parsing 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-4-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®