diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-07 20:26:44 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 20:48:23 -0400 |
commit | 9b558950bb652a85861fef28172e134c367dab1a (patch) | |
tree | 8ceeeef12e076463b8d90306a4402fec65316dec /drivers/regulator/max1586.c | |
parent | 93f5de5c58a863b48a8c44d70c4f7e3d0c7af50e (diff) |
regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear
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.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index a54771e4d960..f67af3c1b963 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -63,28 +63,17 @@ static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 }; | |||
63 | * R24 and R25=100kOhm as described in the data sheet. | 63 | * R24 and R25=100kOhm as described in the data sheet. |
64 | * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm | 64 | * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm |
65 | */ | 65 | */ |
66 | static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, | 66 | static int max1586_v3_set_voltage_sel(struct regulator_dev *rdev, |
67 | unsigned *selector) | 67 | unsigned selector) |
68 | { | 68 | { |
69 | struct max1586_data *max1586 = rdev_get_drvdata(rdev); | 69 | struct max1586_data *max1586 = rdev_get_drvdata(rdev); |
70 | struct i2c_client *client = max1586->client; | 70 | struct i2c_client *client = max1586->client; |
71 | unsigned range_uV = max1586->max_uV - max1586->min_uV; | ||
72 | u8 v3_prog; | 71 | u8 v3_prog; |
73 | 72 | ||
74 | if (min_uV > max1586->max_uV || max_uV < max1586->min_uV) | ||
75 | return -EINVAL; | ||
76 | if (min_uV < max1586->min_uV) | ||
77 | min_uV = max1586->min_uV; | ||
78 | |||
79 | *selector = DIV_ROUND_UP((min_uV - max1586->min_uV) * | ||
80 | MAX1586_V3_MAX_VSEL, range_uV); | ||
81 | if (regulator_list_voltage_linear(rdev, *selector) > max_uV) | ||
82 | return -EINVAL; | ||
83 | |||
84 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", | 73 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", |
85 | regulator_list_voltage_linear(rdev, *selector) / 1000); | 74 | regulator_list_voltage_linear(rdev, selector) / 1000); |
86 | 75 | ||
87 | v3_prog = I2C_V3_SELECT | (u8) *selector; | 76 | v3_prog = I2C_V3_SELECT | (u8) selector; |
88 | return i2c_smbus_write_byte(client, v3_prog); | 77 | return i2c_smbus_write_byte(client, v3_prog); |
89 | } | 78 | } |
90 | 79 | ||
@@ -106,8 +95,9 @@ static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev, | |||
106 | * the set up value. | 95 | * the set up value. |
107 | */ | 96 | */ |
108 | static struct regulator_ops max1586_v3_ops = { | 97 | static struct regulator_ops max1586_v3_ops = { |
109 | .set_voltage = max1586_v3_set, | 98 | .set_voltage_sel = max1586_v3_set_voltage_sel, |
110 | .list_voltage = regulator_list_voltage_linear, | 99 | .list_voltage = regulator_list_voltage_linear, |
100 | .map_voltage = regulator_map_voltage_linear, | ||
111 | }; | 101 | }; |
112 | 102 | ||
113 | static struct regulator_ops max1586_v6_ops = { | 103 | static struct regulator_ops max1586_v6_ops = { |