lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260119-add_dt_default-v1-2-db4787ea7a9e@nxp.com>
Date: Mon, 19 Jan 2026 10:02:55 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...nel.org>, 
 Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>, 
 Alexis Czezar Torreno <alexisczezar.torreno@...log.com>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Peng Fan <peng.fan@....com>
Subject: [PATCH 2/5] regulator: of: Use of_property_read_u32_default()

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

Convert open-coded patterns that read optional DT properties and fallback
to defaults into the new of_property_read_u32_default() helper. Keep the
existing behaviour while reducing boilerplate code.

No functional changes.

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

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 33463926a2a6c10ccfd9aa59d31c0b0c3635833e..83b8a1db8f99c1eefee73ad1e7f234b2280076dc 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -178,12 +178,9 @@ static int of_get_regulation_constraints(struct device *dev,
 	if (!ret)
 		constraints->enable_time = pval;
 
-	ret = of_property_read_u32(np, "regulator-uv-less-critical-window-ms", &pval);
-	if (!ret)
-		constraints->uv_less_critical_window_ms = pval;
-	else
-		constraints->uv_less_critical_window_ms =
-				REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS;
+	constraints->uv_less_critical_window_ms =
+		of_property_read_u32_default(np, "regulator-uv-less-critical-window-ms",
+					     REGULATOR_DEF_UV_LESS_CRITICAL_WINDOW_MS);
 
 	constraints->soft_start = of_property_read_bool(np,
 					"regulator-soft-start");
@@ -313,11 +310,10 @@ static int of_get_regulation_constraints(struct device *dev,
 				"regulator-suspend-max-microvolt", &pval))
 			suspend_state->max_uV = pval;
 
-		if (!of_property_read_u32(suspend_np,
-					"regulator-suspend-microvolt", &pval))
-			suspend_state->uV = pval;
-		else /* otherwise use min_uV as default suspend voltage */
-			suspend_state->uV = suspend_state->min_uV;
+		/* Use min_uV as default suspend voltage if fail to get property */
+		suspend_state->uV =
+			of_property_read_u32_default(suspend_np, "regulator-suspend-microvolt",
+						     suspend_state->min_uV);
 
 		if (of_property_read_bool(suspend_np,
 					"regulator-changeable-in-suspend"))

-- 
2.37.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ