aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max1586.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-06-04 00:58:24 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-04 06:24:59 -0400
commit0d032731178d78450296bdf0b27562476594c298 (patch)
tree77ad9e34ff7ed401d1776a9562cd6105d0490401 /drivers/regulator/max1586.c
parent96d25221d28646fc2ce0a64a725c67c1ee2f2f0a (diff)
regulator: max1586: Convert max1586_v6_ops to set_voltage_sel
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max1586.c')
-rw-r--r--drivers/regulator/max1586.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index f215195de917..126c7d8f31c6 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -105,33 +105,16 @@ static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
105 return max1586_v3_calc_voltage(max1586, selector); 105 return max1586_v3_calc_voltage(max1586, selector);
106} 106}
107 107
108static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV, 108static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
109 unsigned int *selector) 109 unsigned int selector)
110{ 110{
111 struct i2c_client *client = rdev_get_drvdata(rdev); 111 struct i2c_client *client = rdev_get_drvdata(rdev);
112 u8 v6_prog; 112 u8 v6_prog;
113 113
114 if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV)
115 return -EINVAL;
116 if (max_uV < MAX1586_V6_MIN_UV || max_uV > MAX1586_V6_MAX_UV)
117 return -EINVAL;
118
119 if (min_uV < 1800000)
120 *selector = 0;
121 else if (min_uV < 2500000)
122 *selector = 1;
123 else if (min_uV < 3000000)
124 *selector = 2;
125 else if (min_uV >= 3000000)
126 *selector = 3;
127
128 if (rdev->desc->volt_table[*selector] > max_uV)
129 return -EINVAL;
130
131 dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", 114 dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
132 rdev->desc->volt_table[*selector] / 1000); 115 rdev->desc->volt_table[selector] / 1000);
133 116
134 v6_prog = I2C_V6_SELECT | (u8) *selector; 117 v6_prog = I2C_V6_SELECT | (u8) selector;
135 return i2c_smbus_write_byte(client, v6_prog); 118 return i2c_smbus_write_byte(client, v6_prog);
136} 119}
137 120
@@ -145,7 +128,7 @@ static struct regulator_ops max1586_v3_ops = {
145}; 128};
146 129
147static struct regulator_ops max1586_v6_ops = { 130static struct regulator_ops max1586_v6_ops = {
148 .set_voltage = max1586_v6_set, 131 .set_voltage_sel = max1586_v6_set_voltage_sel,
149 .list_voltage = regulator_list_voltage_table, 132 .list_voltage = regulator_list_voltage_table,
150}; 133};
151 134