regulator: Rename set_voltage_sel callback function name to *_sel
Axel Lin [Fri, 9 Mar 2012 02:22:20 +0000 (10:22 +0800)]
This change improves readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Cherry-picked from mainline
94732b97c39859427cf99c34fc9de9750be7e5a5

Change-Id: Ie3eb5462a99cceab40ba0e26e4e3cdb93c5f3f0f
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/90515
Reviewed-by: Automatic_Commit_Validation_User

Rebase-Id: Rffc88b7f8f3cd205f93e6f0a7327f1a8f8a3ff8b

drivers/regulator/tps65910-regulator.c
drivers/regulator/tps65912-regulator.c

index 8de2835..b6edcf6 100644 (file)
@@ -684,8 +684,8 @@ static int tps65911_get_voltage(struct regulator_dev *dev)
        return (LDO_MIN_VOLT + value * step_mv) * 1000;
 }
 
-static int tps65910_set_voltage_dcdc(struct regulator_dev *dev,
-                               unsigned selector)
+static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev,
+                                        unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int id = rdev_get_id(dev), vsel;
@@ -722,7 +722,8 @@ static int tps65910_set_voltage_dcdc(struct regulator_dev *dev,
        return 0;
 }
 
-static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector)
+static int tps65910_set_voltage_sel(struct regulator_dev *dev,
+                                   unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int reg, id = rdev_get_id(dev);
@@ -748,7 +749,8 @@ static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector)
        return -EINVAL;
 }
 
-static int tps65911_set_voltage(struct regulator_dev *dev, unsigned selector)
+static int tps65911_set_voltage_sel(struct regulator_dev *dev,
+                                   unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int reg, id = rdev_get_id(dev);
@@ -866,7 +868,7 @@ static struct regulator_ops tps65910_ops_dcdc = {
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65910_get_voltage_dcdc,
-       .set_voltage_sel        = tps65910_set_voltage_dcdc,
+       .set_voltage_sel        = tps65910_set_voltage_dcdc_sel,
        .list_voltage           = tps65910_list_voltage_dcdc,
 };
 
@@ -887,7 +889,7 @@ static struct regulator_ops tps65910_ops = {
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65910_get_voltage,
-       .set_voltage_sel        = tps65910_set_voltage,
+       .set_voltage_sel        = tps65910_set_voltage_sel,
        .list_voltage           = tps65910_list_voltage,
 };
 
@@ -898,7 +900,7 @@ static struct regulator_ops tps65911_ops = {
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65911_get_voltage,
-       .set_voltage_sel        = tps65911_set_voltage,
+       .set_voltage_sel        = tps65911_set_voltage_sel,
        .list_voltage           = tps65911_list_voltage,
 };
 
index da00d88..83397f5 100644 (file)
@@ -566,8 +566,46 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
        return voltage;
 }
 
-static int tps65912_set_voltage_dcdc(struct regulator_dev *dev,
-                                               unsigned selector)
+static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
+{
+       struct tps65912_reg *pmic = rdev_get_drvdata(dev);
+       struct tps65912 *mfd = pmic->mfd;
+       int id = rdev_get_id(dev);
+       int opvsel = 0, avsel = 0, sr, vsel;
+
+       switch (id) {
+       case TPS65912_REG_DCDC1:
+               opvsel = tps65912_reg_read(mfd, TPS65912_DCDC1_OP);
+               avsel = tps65912_reg_read(mfd, TPS65912_DCDC1_AVS);
+               break;
+       case TPS65912_REG_DCDC2:
+               opvsel = tps65912_reg_read(mfd, TPS65912_DCDC2_OP);
+               avsel = tps65912_reg_read(mfd, TPS65912_DCDC2_AVS);
+               break;
+       case TPS65912_REG_DCDC3:
+               opvsel = tps65912_reg_read(mfd, TPS65912_DCDC3_OP);
+               avsel = tps65912_reg_read(mfd, TPS65912_DCDC3_AVS);
+               break;
+       case TPS65912_REG_DCDC4:
+               opvsel = tps65912_reg_read(mfd, TPS65912_DCDC4_OP);
+               avsel = tps65912_reg_read(mfd, TPS65912_DCDC4_AVS);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       sr = (opvsel & OP_SELREG_MASK) >> OP_SELREG_SHIFT;
+       if (sr)
+               vsel = avsel;
+       else
+               vsel = opvsel;
+       vsel &= 0x3F;
+
+       return tps65912_list_voltage_dcdc(dev, vsel);
+}
+
+static int tps65912_set_voltage_dcdc_sel(struct regulator_dev *dev,
+                                        unsigned selector)
 {
        struct tps65912_reg *pmic = rdev_get_drvdata(dev);
        struct tps65912 *mfd = pmic->mfd;
@@ -596,8 +634,8 @@ static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
        return tps65912_vsel_to_uv_ldo(vsel);
 }
 
-static int tps65912_set_voltage_ldo(struct regulator_dev *dev,
-                                               unsigned selector)
+static int tps65912_set_voltage_ldo_sel(struct regulator_dev *dev,
+                                       unsigned selector)
 {
        struct tps65912_reg *pmic = rdev_get_drvdata(dev);
        struct tps65912 *mfd = pmic->mfd;
@@ -672,7 +710,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
        .set_mode = tps65912_set_mode,
        .get_mode = tps65912_get_mode,
        .get_voltage = tps65912_get_voltage_dcdc,
-       .set_voltage_sel = tps65912_set_voltage_dcdc,
+       .set_voltage_sel = tps65912_set_voltage_dcdc_sel,
        .list_voltage = tps65912_list_voltage_dcdc,
 };
 
@@ -682,7 +720,7 @@ static struct regulator_ops tps65912_ops_ldo = {
        .enable = tps65912_reg_enable,
        .disable = tps65912_reg_disable,
        .get_voltage = tps65912_get_voltage_ldo,
-       .set_voltage_sel = tps65912_set_voltage_ldo,
+       .set_voltage_sel = tps65912_set_voltage_ldo_sel,
        .list_voltage = tps65912_list_voltage_ldo,
 };