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