public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] of: Introduce *_read_*_default helpers and convert regulator drivers
@ 2026-01-19  2:02 Peng Fan (OSS)
  2026-01-19  2:02 ` [PATCH 1/5] of: Add of_property_read_[u32,s32]_default Peng Fan (OSS)
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Peng Fan (OSS) @ 2026-01-19  2:02 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Liam Girdwood, Mark Brown,
	Alexis Czezar Torreno
  Cc: devicetree, linux-kernel, Peng Fan

Introduces new helper functions of_property_read_u32_default() and
of_property_read_s32_default() to simplify reading optional Device Tree
properties with well-defined default values.

A common pattern in drivers is to initialize a variable with a default
value and then override it when a DT property is present, or to explicitly
check the return value of of_property_read_*() and fall back to a default.
While correct, this leads to repetitive boilerplate code and obscures the
intent that the property is optional.

The new helpers make this intent explicit by directly expressing
“optional property with default”. They intentionally ignore error codes
and are meant for cases where a missing or invalid property is not
considered fatal and a sensible default exists.

On top of introducing the helpers, this series converts several
regulator drivers to use them, reducing boilerplate while preserving
existing behavior. No functional changes, except for a minor fix in one
error path where dev_err_probe() is now called with a proper error code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (5):
      of: Add of_property_read_[u32,s32]_default
      regulator: of: Use of_property_read_u32_default()
      regulator: adp5055: use of_property_read_[u32|s32]_default()
      regulator: max77620: Use of_property_read_u32_default() for DT parsing
      regulator: fan53555: Use of_property_read_u32_default() for DT parsing

 drivers/regulator/adp5055-regulator.c  | 30 ++++++++++---------------
 drivers/regulator/fan53555.c           |  8 ++-----
 drivers/regulator/max77620-regulator.c | 40 ++++++++++++++--------------------
 drivers/regulator/of_regulator.c       | 18 ++++++---------
 include/linux/of.h                     | 38 ++++++++++++++++++++++++++++++++
 5 files changed, 74 insertions(+), 60 deletions(-)
---
base-commit: 0f853ca2a798ead9d24d39cad99b0966815c582a
change-id: 20260115-add_dt_default-4ca95f2a6cd7

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-23  6:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox