regulator: 88pm8607: Simplify pm8607_list_voltage implementation
authorAxel Lin <axel.lin@ingics.com>
Tue, 26 Feb 2019 12:40:58 +0000 (20:40 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 26 Feb 2019 16:45:55 +0000 (16:45 +0000)
Set volt_table filed then we can use regulator_list_voltage_table.
Since we have volt_table setting, now we can remove vol_table from
struct pm8607_regulator_info.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/88pm8607.c

index 28f55248eb9033bc2b2d0ee00fd2b39eaee65799..597385d252014dc13a5fe62cbcbab7d2c07b237a 100644 (file)
@@ -27,7 +27,6 @@ struct pm8607_regulator_info {
        struct i2c_client       *i2c;
        struct i2c_client       *i2c_8606;
 
-       unsigned int    *vol_table;
        unsigned int    *vol_suspend;
 
        int     slope_double;
@@ -210,13 +209,15 @@ static const unsigned int LDO14_suspend_table[] = {
 static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
 {
        struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-       int ret = -EINVAL;
+       int ret;
+
+       ret = regulator_list_voltage_table(rdev, index);
+       if (ret < 0)
+               return ret;
+
+       if (info->slope_double)
+               ret <<= 1;
 
-       if (info->vol_table && (index < rdev->desc->n_voltages)) {
-               ret = info->vol_table[index];
-               if (info->slope_double)
-                       ret <<= 1;
-       }
        return ret;
 }
 
@@ -257,6 +258,7 @@ static const struct regulator_ops pm8606_preg_ops = {
                .type   = REGULATOR_VOLTAGE,                            \
                .id     = PM8607_ID_##vreg,                             \
                .owner  = THIS_MODULE,                                  \
+               .volt_table = vreg##_table,                             \
                .n_voltages = ARRAY_SIZE(vreg##_table),                 \
                .vsel_reg = PM8607_##vreg,                              \
                .vsel_mask = ARRAY_SIZE(vreg##_table) - 1,              \
@@ -266,7 +268,6 @@ static const struct regulator_ops pm8606_preg_ops = {
                .enable_mask = 1 << (ebit),                             \
        },                                                              \
        .slope_double   = (0),                                          \
-       .vol_table      = (unsigned int *)&vreg##_table,                \
        .vol_suspend    = (unsigned int *)&vreg##_suspend_table,        \
 }
 
@@ -278,6 +279,7 @@ static const struct regulator_ops pm8606_preg_ops = {
                .type   = REGULATOR_VOLTAGE,                            \
                .id     = PM8607_ID_LDO##_id,                           \
                .owner  = THIS_MODULE,                                  \
+               .volt_table = LDO##_id##_table,                         \
                .n_voltages = ARRAY_SIZE(LDO##_id##_table),             \
                .vsel_reg = PM8607_##vreg,                              \
                .vsel_mask = (ARRAY_SIZE(LDO##_id##_table) - 1) << (shift), \
@@ -285,7 +287,6 @@ static const struct regulator_ops pm8606_preg_ops = {
                .enable_mask = 1 << (ebit),                             \
        },                                                              \
        .slope_double   = (0),                                          \
-       .vol_table      = (unsigned int *)&LDO##_id##_table,            \
        .vol_suspend    = (unsigned int *)&LDO##_id##_suspend_table,    \
 }