UPSTREAM: regulator: of: Use of_property_read_u32() for reading min/max
authorLaxman Dewangan <ldewangan@nvidia.com>
Thu, 10 Mar 2016 12:12:47 +0000 (17:42 +0530)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 6 Mar 2017 10:28:40 +0000 (18:28 +0800)
OF interface provides to read the u32 value via standard interface
of_property_read_u32(). Use this API to read "regulator-min-microvolts"
and "regulator-max-microvolt".

This will make consistent with other property value reads.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit a34785f10d33f70680941da284d7ec3a612aad1a)

Change-Id: I12da714ca47197932e693567e34927a7ddd26f01
Signed-off-by: David Wu <david.wu@rock-chips.com>
drivers/regulator/of_regulator.c

index fe2e33441daef462d05b61419be6fb1331eb087a..6b0aa80b22fd1b4817c65995dfc1424fbb3d0c31 100644 (file)
@@ -28,7 +28,6 @@ static void of_get_regulation_constraints(struct device_node *np,
                                        struct regulator_init_data **init_data,
                                        const struct regulator_desc *desc)
 {
-       const __be32 *min_uV, *max_uV;
        struct regulation_constraints *constraints = &(*init_data)->constraints;
        struct regulator_state *suspend_state;
        struct device_node *suspend_np;
@@ -37,18 +36,18 @@ static void of_get_regulation_constraints(struct device_node *np,
 
        constraints->name = of_get_property(np, "regulator-name", NULL);
 
-       min_uV = of_get_property(np, "regulator-min-microvolt", NULL);
-       if (min_uV)
-               constraints->min_uV = be32_to_cpu(*min_uV);
-       max_uV = of_get_property(np, "regulator-max-microvolt", NULL);
-       if (max_uV)
-               constraints->max_uV = be32_to_cpu(*max_uV);
+       if (!of_property_read_u32(np, "regulator-min-microvolt", &pval))
+               constraints->min_uV = pval;
+
+       if (!of_property_read_u32(np, "regulator-max-microvolt", &pval))
+               constraints->max_uV = pval;
 
        /* Voltage change possible? */
        if (constraints->min_uV != constraints->max_uV)
                constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
        /* Only one voltage?  Then make sure it's set. */
-       if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
+       if (constraints->min_uV && constraints->max_uV &&
+           constraints->min_uV == constraints->max_uV)
                constraints->apply_uV = true;
 
        if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))