Skip to content

Commit 5bd73a1

Browse files
robherringbroonie
authored andcommitted
regulator: Use of_property_read_bool() for boolean properties
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. Convert reading boolean properties to to of_property_read_bool(). Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230310144722.1544843-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7dda20c commit 5bd73a1

7 files changed

Lines changed: 17 additions & 36 deletions

File tree

drivers/regulator/lp872x.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ static struct lp872x_platform_data
832832
return ERR_PTR(-ENOMEM);
833833

834834
of_property_read_u8(np, "ti,general-config", &pdata->general_config);
835-
if (of_find_property(np, "ti,update-config", NULL))
836-
pdata->update_config = true;
835+
pdata->update_config = of_property_read_bool(np, "ti,update-config");
837836

838837
pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL);
839838
if (!pdata->dvs)

drivers/regulator/max8997-regulator.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
943943
}
944944
of_node_put(regulators_np);
945945

946-
if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL))
947-
pdata->buck1_gpiodvs = true;
948-
949-
if (of_get_property(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs", NULL))
950-
pdata->buck2_gpiodvs = true;
951-
952-
if (of_get_property(pmic_np, "max8997,pmic-buck5-uses-gpio-dvs", NULL))
953-
pdata->buck5_gpiodvs = true;
946+
pdata->buck1_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs");
947+
pdata->buck2_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs");
948+
pdata->buck5_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck5-uses-gpio-dvs");
954949

955950
if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
956951
pdata->buck5_gpiodvs) {

drivers/regulator/max8998.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,7 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
618618
if (ret)
619619
return -EINVAL;
620620

621-
if (of_find_property(pmic_np, "max8998,pmic-buck-voltage-lock", NULL))
622-
pdata->buck_voltage_lock = true;
621+
pdata->buck_voltage_lock = of_property_read_bool(pmic_np, "max8998,pmic-buck-voltage-lock");
623622

624623
ret = of_property_read_u32(pmic_np,
625624
"max8998,pmic-buck1-default-dvs-idx",

drivers/regulator/s5m8767.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
605605

606606
of_node_put(regulators_np);
607607

608-
if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) {
608+
if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs")) {
609609
pdata->buck2_gpiodvs = true;
610610

611611
if (of_property_read_u32_array(pmic_np,
@@ -616,7 +616,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
616616
}
617617
}
618618

619-
if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) {
619+
if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs")) {
620620
pdata->buck3_gpiodvs = true;
621621

622622
if (of_property_read_u32_array(pmic_np,
@@ -627,7 +627,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
627627
}
628628
}
629629

630-
if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) {
630+
if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs")) {
631631
pdata->buck4_gpiodvs = true;
632632

633633
if (of_property_read_u32_array(pmic_np,
@@ -661,14 +661,9 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
661661
if (ret)
662662
return -EINVAL;
663663

664-
if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL))
665-
pdata->buck2_ramp_enable = true;
666-
667-
if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL))
668-
pdata->buck3_ramp_enable = true;
669-
670-
if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL))
671-
pdata->buck4_ramp_enable = true;
664+
pdata->buck2_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-ramp-enable");
665+
pdata->buck3_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck3-ramp-enable");
666+
pdata->buck4_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck4-ramp-enable");
672667

673668
if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable
674669
|| pdata->buck4_ramp_enable) {

drivers/regulator/stpmic1_regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static int stpmic1_regulator_register(struct platform_device *pdev, int id,
576576
}
577577

578578
/* set mask reset */
579-
if (of_get_property(config.of_node, "st,mask-reset", NULL) &&
579+
if (of_property_read_bool(config.of_node, "st,mask-reset") &&
580580
cfg->mask_reset_reg != 0) {
581581
ret = regmap_update_bits(pmic_dev->regmap,
582582
cfg->mask_reset_reg,

drivers/regulator/tps62360-regulator.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,10 @@ static struct tps62360_regulator_platform_data *
296296
return NULL;
297297
}
298298

299-
if (of_find_property(np, "ti,vsel0-state-high", NULL))
300-
pdata->vsel0_def_state = 1;
301-
302-
if (of_find_property(np, "ti,vsel1-state-high", NULL))
303-
pdata->vsel1_def_state = 1;
304-
305-
if (of_find_property(np, "ti,enable-pull-down", NULL))
306-
pdata->en_internal_pulldn = true;
307-
308-
if (of_find_property(np, "ti,enable-vout-discharge", NULL))
309-
pdata->en_discharge = true;
299+
pdata->vsel0_def_state = of_property_read_bool(np, "ti,vsel0-state-high");
300+
pdata->vsel1_def_state = of_property_read_bool(np, "ti,vsel1-state-high");
301+
pdata->en_internal_pulldn = of_property_read_bool(np, "ti,enable-pull-down");
302+
pdata->en_discharge = of_property_read_bool(np, "ti,enable-vout-discharge");
310303

311304
return pdata;
312305
}

drivers/regulator/twl6030-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ static int twlreg_probe(struct platform_device *pdev)
729729
break;
730730
}
731731

732-
if (of_get_property(np, "ti,retain-on-reset", NULL))
732+
if (of_property_read_bool(np, "ti,retain-on-reset"))
733733
info->flags |= TWL_6030_WARM_RESET;
734734

735735
config.dev = &pdev->dev;

0 commit comments

Comments
 (0)