Skip to contentSkip to conversation

regulator: Use of_property_present() for testing DT property presence

PATCH In review Rob Herring 3 participants 3 messages Mar 10, 2023 – Mar 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: Use of_property_present() for testing DT property presence

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

---
 drivers/regulator/bd71815-regulator.c | 8 ++++----
 drivers/regulator/fixed.c             | 2 +-
 drivers/regulator/gpio-regulator.c    | 2 +-
 drivers/regulator/pwm-regulator.c     | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/regulator/bd71815-regulator.c +4 -4
index 8b55046eded8..f4eaea732de7 100644
@@ -201,10 +201,10 @@ static int buck12_set_hw_dvs_levels(struct device_node *np,
 
 	data = container_of(desc, struct bd71815_regulator, desc);
 
-	if (of_find_property(np, "rohm,dvs-run-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-suspend-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-lpsr-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-snvs-voltage", NULL)) {
+	if (of_property_present(np, "rohm,dvs-run-voltage") ||
+	    of_property_present(np, "rohm,dvs-suspend-voltage") ||
+	    of_property_present(np, "rohm,dvs-lpsr-voltage") ||
+	    of_property_present(np, "rohm,dvs-snvs-voltage")) {
 		ret = regmap_read(cfg->regmap, desc->vsel_reg, &val);
 		if (ret)
 			return ret;
drivers/regulator/fixed.c +1 -1
index 2a9867abba20..7c3add05be15 100644
@@ -151,7 +151,7 @@ of_get_fixed_voltage_config(struct device *dev,
 	of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
 	of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay);
 
-	if (of_find_property(np, "vin-supply", NULL))
+	if (of_property_present(np, "vin-supply"))
 		config->input_supply = "vin";
 
 	return config;
drivers/regulator/gpio-regulator.c +1 -1
index 95e61a2f43f5..7602d48609df 100644
@@ -220,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
 				 regtype);
 	}
 
-	if (of_find_property(np, "vin-supply", NULL))
+	if (of_property_present(np, "vin-supply"))
 		config->input_supply = "vin";
 
 	return config;
drivers/regulator/pwm-regulator.c +1 -1
index b9eeaff1c661..214ea866742d 100644
@@ -334,7 +334,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
 
 	memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(drvdata->desc));
 
-	if (of_find_property(np, "voltage-table", NULL))
+	if (of_property_present(np, "voltage-table"))
 		ret = pwm_regulator_init_table(pdev, drvdata);
 	else
 		ret = pwm_regulator_init_continuous(pdev, drvdata);
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 8 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

[...]

Applied to

broonie/regulator.git for-next

Thanks!

[1/1] regulator: Use of_property_present() for testing DT property presence

      commit: 7dda20c97fac52948b948e15e1173ee57c66ed35

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rob Herring
Quoted 8 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Quoted 65 lines
---
  drivers/regulator/bd71815-regulator.c | 8 ++++----
  drivers/regulator/fixed.c             | 2 +-
  drivers/regulator/gpio-regulator.c    | 2 +-
  drivers/regulator/pwm-regulator.c     | 2 +-
  4 files changed, 7 insertions(+), 7 deletions(-)
drivers/regulator/bd71815-regulator.c +4 -4
index 8b55046eded8..f4eaea732de7 100644
@@ -201,10 +201,10 @@ static int buck12_set_hw_dvs_levels(struct device_node *np,
 
  	data = container_of(desc, struct bd71815_regulator, desc);
 
-	if (of_find_property(np, "rohm,dvs-run-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-suspend-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-lpsr-voltage", NULL) ||
-	    of_find_property(np, "rohm,dvs-snvs-voltage", NULL)) {
+	if (of_property_present(np, "rohm,dvs-run-voltage") ||
+	    of_property_present(np, "rohm,dvs-suspend-voltage") ||
+	    of_property_present(np, "rohm,dvs-lpsr-voltage") ||
+	    of_property_present(np, "rohm,dvs-snvs-voltage")) {
  		ret = regmap_read(cfg->regmap, desc->vsel_reg, &val);
  		if (ret)
  			return ret;
drivers/regulator/fixed.c +1 -1
index 2a9867abba20..7c3add05be15 100644
@@ -151,7 +151,7 @@ of_get_fixed_voltage_config(struct device *dev,
  	of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
  	of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay);
 
-	if (of_find_property(np, "vin-supply", NULL))
+	if (of_property_present(np, "vin-supply"))
  		config->input_supply = "vin";
 
  	return config;
drivers/regulator/gpio-regulator.c +1 -1
index 95e61a2f43f5..7602d48609df 100644
@@ -220,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
  				 regtype);
  	}
 
-	if (of_find_property(np, "vin-supply", NULL))
+	if (of_property_present(np, "vin-supply"))
  		config->input_supply = "vin";
 
  	return config;
drivers/regulator/pwm-regulator.c +1 -1
index b9eeaff1c661..214ea866742d 100644
@@ -334,7 +334,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
 
  	memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(drvdata->desc));
 
-	if (of_find_property(np, "voltage-table", NULL))
+	if (of_property_present(np, "voltage-table"))
  		ret = pwm_regulator_init_table(pdev, drvdata);
  	else
  		ret = pwm_regulator_init_continuous(pdev, drvdata);
Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~