Skip to content

Commit 7dda20c

Browse files
robherringbroonie
authored andcommitted
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. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230310144721.1544756-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4eb6678 commit 7dda20c

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/regulator/bd71815-regulator.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ static int buck12_set_hw_dvs_levels(struct device_node *np,
201201

202202
data = container_of(desc, struct bd71815_regulator, desc);
203203

204-
if (of_find_property(np, "rohm,dvs-run-voltage", NULL) ||
205-
of_find_property(np, "rohm,dvs-suspend-voltage", NULL) ||
206-
of_find_property(np, "rohm,dvs-lpsr-voltage", NULL) ||
207-
of_find_property(np, "rohm,dvs-snvs-voltage", NULL)) {
204+
if (of_property_present(np, "rohm,dvs-run-voltage") ||
205+
of_property_present(np, "rohm,dvs-suspend-voltage") ||
206+
of_property_present(np, "rohm,dvs-lpsr-voltage") ||
207+
of_property_present(np, "rohm,dvs-snvs-voltage")) {
208208
ret = regmap_read(cfg->regmap, desc->vsel_reg, &val);
209209
if (ret)
210210
return ret;

drivers/regulator/fixed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ of_get_fixed_voltage_config(struct device *dev,
151151
of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
152152
of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay);
153153

154-
if (of_find_property(np, "vin-supply", NULL))
154+
if (of_property_present(np, "vin-supply"))
155155
config->input_supply = "vin";
156156

157157
return config;

drivers/regulator/gpio-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
220220
regtype);
221221
}
222222

223-
if (of_find_property(np, "vin-supply", NULL))
223+
if (of_property_present(np, "vin-supply"))
224224
config->input_supply = "vin";
225225

226226
return config;

drivers/regulator/pwm-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
334334

335335
memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(drvdata->desc));
336336

337-
if (of_find_property(np, "voltage-table", NULL))
337+
if (of_property_present(np, "voltage-table"))
338338
ret = pwm_regulator_init_table(pdev, drvdata);
339339
else
340340
ret = pwm_regulator_init_continuous(pdev, drvdata);

0 commit comments

Comments
 (0)