Commit 1e050eab authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Mark Brown

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: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 13b3fde8
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
static void of_get_regulation_constraints(struct device_node *np, static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data) struct regulator_init_data **init_data)
{ {
const __be32 *min_uV, *max_uV, *uV_offset; const __be32 *min_uV, *max_uV;
const __be32 *min_uA, *max_uA, *ramp_delay;
struct property *prop;
struct regulation_constraints *constraints = &(*init_data)->constraints; struct regulation_constraints *constraints = &(*init_data)->constraints;
int ret; int ret;
u32 pval; u32 pval;
...@@ -42,36 +40,29 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -42,36 +40,29 @@ static void of_get_regulation_constraints(struct device_node *np,
if (min_uV && max_uV && constraints->min_uV == constraints->max_uV) if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
constraints->apply_uV = true; constraints->apply_uV = true;
uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))
if (uV_offset) constraints->uV_offset = pval;
constraints->uV_offset = be32_to_cpu(*uV_offset); if (!of_property_read_u32(np, "regulator-min-microamp", &pval))
min_uA = of_get_property(np, "regulator-min-microamp", NULL); constraints->min_uA = pval;
if (min_uA) if (!of_property_read_u32(np, "regulator-max-microamp", &pval))
constraints->min_uA = be32_to_cpu(*min_uA); constraints->max_uA = pval;
max_uA = of_get_property(np, "regulator-max-microamp", NULL);
if (max_uA)
constraints->max_uA = be32_to_cpu(*max_uA);
/* Current change possible? */ /* Current change possible? */
if (constraints->min_uA != constraints->max_uA) if (constraints->min_uA != constraints->max_uA)
constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
if (of_find_property(np, "regulator-boot-on", NULL)) constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");
constraints->boot_on = true; constraints->always_on = of_property_read_bool(np, "regulator-always-on");
if (!constraints->always_on) /* status change should be possible. */
if (of_find_property(np, "regulator-always-on", NULL))
constraints->always_on = true;
else /* status change should be possible if not always on. */
constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
if (of_property_read_bool(np, "regulator-allow-bypass")) if (of_property_read_bool(np, "regulator-allow-bypass"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
prop = of_find_property(np, "regulator-ramp-delay", NULL); ret = of_property_read_u32(np, "regulator-ramp-delay", &pval);
if (prop && prop->value) { if (!ret) {
ramp_delay = prop->value; if (pval)
if (*ramp_delay) constraints->ramp_delay = pval;
constraints->ramp_delay = be32_to_cpu(*ramp_delay);
else else
constraints->ramp_disable = true; constraints->ramp_disable = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment