[PATCH 5/5] regulator: fan53555: Use of_property_read_u32_default() for DT parsing

Peng Fan (OSS) posted 5 patches 3 weeks, 1 day ago
[PATCH 5/5] regulator: fan53555: Use of_property_read_u32_default() for DT parsing
Posted by Peng Fan (OSS) 3 weeks, 1 day ago
From: Peng Fan <peng.fan@nxp.com>

Simplify DT parsing of the optional "fcs,suspend-voltage-selector"
property by using of_property_read_u32_default().

If the property is not specified, default to FAN53555_VSEL_ID_0,
which matches the existing behaviour where the field was zeroed
by devm_kzalloc().

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/regulator/fan53555.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index c282236959b1803e3cba8f4b9cc15e458f6e8436..2e2b5822fc9ed0399056326d838661cb4752f767 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -624,8 +624,6 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
 					      const struct regulator_desc *desc)
 {
 	struct fan53555_platform_data *pdata;
-	int ret;
-	u32 tmp;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
@@ -633,10 +631,8 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
 
 	pdata->regulator = of_get_regulator_init_data(dev, np, desc);
 
-	ret = of_property_read_u32(np, "fcs,suspend-voltage-selector",
-				   &tmp);
-	if (!ret)
-		pdata->sleep_vsel_id = tmp;
+	pdata->sleep_vsel_id = of_property_read_u32_default(np, "fcs,suspend-voltage-selector",
+							    FAN53555_VSEL_ID_0);
 
 	return pdata;
 }

-- 
2.37.1