Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: use of_property_read_{bool|u32}()

Use more compact of_property_read_{bool|u32}() calls instead of the
of_{find|get}_property() calls in of_get_regulation_constraints() where
possible (note that of_property_read_{bool|u32}() were already used to read
some properties).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Sergei Shtylyov and committed by
Mark Brown
1e050eab 13b3fde8

+14 -23
+14 -23
drivers/regulator/of_regulator.c
··· 19 19 static void of_get_regulation_constraints(struct device_node *np, 20 20 struct regulator_init_data **init_data) 21 21 { 22 - const __be32 *min_uV, *max_uV, *uV_offset; 23 - const __be32 *min_uA, *max_uA, *ramp_delay; 24 - struct property *prop; 22 + const __be32 *min_uV, *max_uV; 25 23 struct regulation_constraints *constraints = &(*init_data)->constraints; 26 24 int ret; 27 25 u32 pval; ··· 40 42 if (min_uV && max_uV && constraints->min_uV == constraints->max_uV) 41 43 constraints->apply_uV = true; 42 44 43 - uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); 44 - if (uV_offset) 45 - constraints->uV_offset = be32_to_cpu(*uV_offset); 46 - min_uA = of_get_property(np, "regulator-min-microamp", NULL); 47 - if (min_uA) 48 - constraints->min_uA = be32_to_cpu(*min_uA); 49 - max_uA = of_get_property(np, "regulator-max-microamp", NULL); 50 - if (max_uA) 51 - constraints->max_uA = be32_to_cpu(*max_uA); 45 + if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval)) 46 + constraints->uV_offset = pval; 47 + if (!of_property_read_u32(np, "regulator-min-microamp", &pval)) 48 + constraints->min_uA = pval; 49 + if (!of_property_read_u32(np, "regulator-max-microamp", &pval)) 50 + constraints->max_uA = pval; 52 51 53 52 /* Current change possible? */ 54 53 if (constraints->min_uA != constraints->max_uA) 55 54 constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; 56 55 57 - if (of_find_property(np, "regulator-boot-on", NULL)) 58 - constraints->boot_on = true; 59 - 60 - if (of_find_property(np, "regulator-always-on", NULL)) 61 - constraints->always_on = true; 62 - else /* status change should be possible if not always on. */ 56 + constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); 57 + constraints->always_on = of_property_read_bool(np, "regulator-always-on"); 58 + if (!constraints->always_on) /* status change should be possible. */ 63 59 constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; 64 60 65 61 if (of_property_read_bool(np, "regulator-allow-bypass")) 66 62 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; 67 63 68 - prop = of_find_property(np, "regulator-ramp-delay", NULL); 69 - if (prop && prop->value) { 70 - ramp_delay = prop->value; 71 - if (*ramp_delay) 72 - constraints->ramp_delay = be32_to_cpu(*ramp_delay); 64 + ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); 65 + if (!ret) { 66 + if (pval) 67 + constraints->ramp_delay = pval; 73 68 else 74 69 constraints->ramp_disable = true; 75 70 }