aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-10-13 01:18:36 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-10-13 01:18:36 -0400
commit4783f393de3077211c14675a0e57c8a02e9190b0 (patch)
tree6c37d8664eb072fd026db3706481d771da4495ca /drivers/regulator
parent9f5f9ffe50e90ed73040d2100db8bfc341cee352 (diff)
parent5b8544c38e6fde6968645afd46ff681492192b86 (diff)
Merge remote branch 'kumar/merge' into next
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/88pm8607.c4
-rw-r--r--drivers/regulator/ab3100.c5
-rw-r--r--drivers/regulator/ab8500.c9
-rw-r--r--drivers/regulator/ad5398.c13
-rw-r--r--drivers/regulator/core.c6
-rw-r--r--drivers/regulator/isl6271a-regulator.c4
-rw-r--r--drivers/regulator/max1586.c12
-rw-r--r--drivers/regulator/max8649.c2
-rw-r--r--drivers/regulator/max8998.c8
-rw-r--r--drivers/regulator/tps6507x-regulator.c6
-rw-r--r--drivers/regulator/tps6586x-regulator.c4
-rw-r--r--drivers/regulator/wm831x-ldo.c7
-rw-r--r--drivers/regulator/wm8350-regulator.c2
13 files changed, 37 insertions, 45 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 7d149a8d8d9b..2ce2eb71d0f5 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -215,7 +215,7 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
215 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 215 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
216 int ret = -EINVAL; 216 int ret = -EINVAL;
217 217
218 if (info->vol_table && (index < (2 << info->vol_nbits))) { 218 if (info->vol_table && (index < (1 << info->vol_nbits))) {
219 ret = info->vol_table[index]; 219 ret = info->vol_table[index];
220 if (info->slope_double) 220 if (info->slope_double)
221 ret <<= 1; 221 ret <<= 1;
@@ -233,7 +233,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
233 max_uV = max_uV >> 1; 233 max_uV = max_uV >> 1;
234 } 234 }
235 if (info->vol_table) { 235 if (info->vol_table) {
236 for (i = 0; i < (2 << info->vol_nbits); i++) { 236 for (i = 0; i < (1 << info->vol_nbits); i++) {
237 if (!info->vol_table[i]) 237 if (!info->vol_table[i])
238 break; 238 break;
239 if ((min_uV <= info->vol_table[i]) 239 if ((min_uV <= info->vol_table[i])
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index 11790990277a..b349266a43de 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -634,12 +634,9 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
634 "%s: failed to register regulator %s err %d\n", 634 "%s: failed to register regulator %s err %d\n",
635 __func__, ab3100_regulator_desc[i].name, 635 __func__, ab3100_regulator_desc[i].name,
636 err); 636 err);
637 i--;
638 /* remove the already registered regulators */ 637 /* remove the already registered regulators */
639 while (i > 0) { 638 while (--i >= 0)
640 regulator_unregister(ab3100_regulators[i].rdev); 639 regulator_unregister(ab3100_regulators[i].rdev);
641 i--;
642 }
643 return err; 640 return err;
644 } 641 }
645 642
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index dc3f1a491675..28c7ae67cec9 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -157,7 +157,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
157 if (info->fixed_uV) 157 if (info->fixed_uV)
158 return info->fixed_uV; 158 return info->fixed_uV;
159 159
160 if (selector > info->voltages_len) 160 if (selector >= info->voltages_len)
161 return -EINVAL; 161 return -EINVAL;
162 162
163 return info->supported_voltages[selector]; 163 return info->supported_voltages[selector];
@@ -344,13 +344,14 @@ static inline struct ab8500_regulator_info *find_regulator_info(int id)
344static __devinit int ab8500_regulator_probe(struct platform_device *pdev) 344static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
345{ 345{
346 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 346 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
347 struct ab8500_platform_data *pdata = dev_get_platdata(ab8500->dev); 347 struct ab8500_platform_data *pdata;
348 int i, err; 348 int i, err;
349 349
350 if (!ab8500) { 350 if (!ab8500) {
351 dev_err(&pdev->dev, "null mfd parent\n"); 351 dev_err(&pdev->dev, "null mfd parent\n");
352 return -EINVAL; 352 return -EINVAL;
353 } 353 }
354 pdata = dev_get_platdata(ab8500->dev);
354 355
355 /* register all regulators */ 356 /* register all regulators */
356 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { 357 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) {
@@ -368,11 +369,9 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
368 dev_err(&pdev->dev, "failed to register regulator %s\n", 369 dev_err(&pdev->dev, "failed to register regulator %s\n",
369 info->desc.name); 370 info->desc.name);
370 /* when we fail, un-register all earlier regulators */ 371 /* when we fail, un-register all earlier regulators */
371 i--; 372 while (--i >= 0) {
372 while (i > 0) {
373 info = &ab8500_regulator_info[i]; 373 info = &ab8500_regulator_info[i];
374 regulator_unregister(info->regulator); 374 regulator_unregister(info->regulator);
375 i--;
376 } 375 }
377 return err; 376 return err;
378 } 377 }
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index d59d2f2314af..a4be41614eeb 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -25,7 +25,7 @@ struct ad5398_chip_info {
25 unsigned int current_level; 25 unsigned int current_level;
26 unsigned int current_mask; 26 unsigned int current_mask;
27 unsigned int current_offset; 27 unsigned int current_offset;
28 struct regulator_dev rdev; 28 struct regulator_dev *rdev;
29}; 29};
30 30
31static int ad5398_calc_current(struct ad5398_chip_info *chip, 31static int ad5398_calc_current(struct ad5398_chip_info *chip,
@@ -211,7 +211,6 @@ MODULE_DEVICE_TABLE(i2c, ad5398_id);
211static int __devinit ad5398_probe(struct i2c_client *client, 211static int __devinit ad5398_probe(struct i2c_client *client,
212 const struct i2c_device_id *id) 212 const struct i2c_device_id *id)
213{ 213{
214 struct regulator_dev *rdev;
215 struct regulator_init_data *init_data = client->dev.platform_data; 214 struct regulator_init_data *init_data = client->dev.platform_data;
216 struct ad5398_chip_info *chip; 215 struct ad5398_chip_info *chip;
217 const struct ad5398_current_data_format *df = 216 const struct ad5398_current_data_format *df =
@@ -233,9 +232,10 @@ static int __devinit ad5398_probe(struct i2c_client *client,
233 chip->current_offset = df->current_offset; 232 chip->current_offset = df->current_offset;
234 chip->current_mask = (chip->current_level - 1) << chip->current_offset; 233 chip->current_mask = (chip->current_level - 1) << chip->current_offset;
235 234
236 rdev = regulator_register(&ad5398_reg, &client->dev, init_data, chip); 235 chip->rdev = regulator_register(&ad5398_reg, &client->dev,
237 if (IS_ERR(rdev)) { 236 init_data, chip);
238 ret = PTR_ERR(rdev); 237 if (IS_ERR(chip->rdev)) {
238 ret = PTR_ERR(chip->rdev);
239 dev_err(&client->dev, "failed to register %s %s\n", 239 dev_err(&client->dev, "failed to register %s %s\n",
240 id->name, ad5398_reg.name); 240 id->name, ad5398_reg.name);
241 goto err; 241 goto err;
@@ -254,9 +254,8 @@ static int __devexit ad5398_remove(struct i2c_client *client)
254{ 254{
255 struct ad5398_chip_info *chip = i2c_get_clientdata(client); 255 struct ad5398_chip_info *chip = i2c_get_clientdata(client);
256 256
257 regulator_unregister(&chip->rdev); 257 regulator_unregister(chip->rdev);
258 kfree(chip); 258 kfree(chip);
259 i2c_set_clientdata(client, NULL);
260 259
261 return 0; 260 return 0;
262} 261}
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 422a709d271d..cc8b337b9119 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -700,7 +700,7 @@ static void print_constraints(struct regulator_dev *rdev)
700 constraints->min_uA != constraints->max_uA) { 700 constraints->min_uA != constraints->max_uA) {
701 ret = _regulator_get_current_limit(rdev); 701 ret = _regulator_get_current_limit(rdev);
702 if (ret > 0) 702 if (ret > 0)
703 count += sprintf(buf + count, "at %d uA ", ret / 1000); 703 count += sprintf(buf + count, "at %d mA ", ret / 1000);
704 } 704 }
705 705
706 if (constraints->valid_modes_mask & REGULATOR_MODE_FAST) 706 if (constraints->valid_modes_mask & REGULATOR_MODE_FAST)
@@ -2302,8 +2302,10 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
2302 dev_set_name(&rdev->dev, "regulator.%d", 2302 dev_set_name(&rdev->dev, "regulator.%d",
2303 atomic_inc_return(&regulator_no) - 1); 2303 atomic_inc_return(&regulator_no) - 1);
2304 ret = device_register(&rdev->dev); 2304 ret = device_register(&rdev->dev);
2305 if (ret != 0) 2305 if (ret != 0) {
2306 put_device(&rdev->dev);
2306 goto clean; 2307 goto clean;
2308 }
2307 2309
2308 dev_set_drvdata(&rdev->dev, rdev); 2310 dev_set_drvdata(&rdev->dev, rdev);
2309 2311
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index e49d2bd393f2..b8cc6389a541 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -165,7 +165,7 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c,
165 mutex_init(&pmic->mtx); 165 mutex_init(&pmic->mtx);
166 166
167 for (i = 0; i < 3; i++) { 167 for (i = 0; i < 3; i++) {
168 pmic->rdev[i] = regulator_register(&isl_rd[0], &i2c->dev, 168 pmic->rdev[i] = regulator_register(&isl_rd[i], &i2c->dev,
169 init_data, pmic); 169 init_data, pmic);
170 if (IS_ERR(pmic->rdev[i])) { 170 if (IS_ERR(pmic->rdev[i])) {
171 dev_err(&i2c->dev, "failed to register %s\n", id->name); 171 dev_err(&i2c->dev, "failed to register %s\n", id->name);
@@ -191,8 +191,6 @@ static int __devexit isl6271a_remove(struct i2c_client *i2c)
191 struct isl_pmic *pmic = i2c_get_clientdata(i2c); 191 struct isl_pmic *pmic = i2c_get_clientdata(i2c);
192 int i; 192 int i;
193 193
194 i2c_set_clientdata(i2c, NULL);
195
196 for (i = 0; i < 3; i++) 194 for (i = 0; i < 3; i++)
197 regulator_unregister(pmic->rdev[i]); 195 regulator_unregister(pmic->rdev[i]);
198 196
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 8867c2710a6d..559cfa271a44 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -121,14 +121,14 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV)
121 if (max_uV < MAX1586_V6_MIN_UV || max_uV > MAX1586_V6_MAX_UV) 121 if (max_uV < MAX1586_V6_MIN_UV || max_uV > MAX1586_V6_MAX_UV)
122 return -EINVAL; 122 return -EINVAL;
123 123
124 if (min_uV >= 3000000)
125 selector = 3;
126 if (min_uV < 3000000)
127 selector = 2;
128 if (min_uV < 2500000)
129 selector = 1;
130 if (min_uV < 1800000) 124 if (min_uV < 1800000)
131 selector = 0; 125 selector = 0;
126 else if (min_uV < 2500000)
127 selector = 1;
128 else if (min_uV < 3000000)
129 selector = 2;
130 else if (min_uV >= 3000000)
131 selector = 3;
132 132
133 if (max1586_v6_calc_voltage(selector) > max_uV) 133 if (max1586_v6_calc_voltage(selector) > max_uV)
134 return -EINVAL; 134 return -EINVAL;
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 4520ace3f7e7..6b60a9c0366b 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -330,7 +330,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
330 /* set external clock frequency */ 330 /* set external clock frequency */
331 info->extclk_freq = pdata->extclk_freq; 331 info->extclk_freq = pdata->extclk_freq;
332 max8649_set_bits(info->i2c, MAX8649_SYNC, MAX8649_EXT_MASK, 332 max8649_set_bits(info->i2c, MAX8649_SYNC, MAX8649_EXT_MASK,
333 info->extclk_freq); 333 info->extclk_freq << 6);
334 } 334 }
335 335
336 if (pdata->ramp_timing) { 336 if (pdata->ramp_timing) {
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index ab67298799f9..a1baf1fbe004 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -549,7 +549,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
549 if (!max8998) 549 if (!max8998)
550 return -ENOMEM; 550 return -ENOMEM;
551 551
552 size = sizeof(struct regulator_dev *) * (pdata->num_regulators + 1); 552 size = sizeof(struct regulator_dev *) * pdata->num_regulators;
553 max8998->rdev = kzalloc(size, GFP_KERNEL); 553 max8998->rdev = kzalloc(size, GFP_KERNEL);
554 if (!max8998->rdev) { 554 if (!max8998->rdev) {
555 kfree(max8998); 555 kfree(max8998);
@@ -557,7 +557,9 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
557 } 557 }
558 558
559 rdev = max8998->rdev; 559 rdev = max8998->rdev;
560 max8998->dev = &pdev->dev;
560 max8998->iodev = iodev; 561 max8998->iodev = iodev;
562 max8998->num_regulators = pdata->num_regulators;
561 platform_set_drvdata(pdev, max8998); 563 platform_set_drvdata(pdev, max8998);
562 564
563 for (i = 0; i < pdata->num_regulators; i++) { 565 for (i = 0; i < pdata->num_regulators; i++) {
@@ -583,7 +585,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
583 585
584 return 0; 586 return 0;
585err: 587err:
586 for (i = 0; i <= max8998->num_regulators; i++) 588 for (i = 0; i < max8998->num_regulators; i++)
587 if (rdev[i]) 589 if (rdev[i])
588 regulator_unregister(rdev[i]); 590 regulator_unregister(rdev[i]);
589 591
@@ -599,7 +601,7 @@ static int __devexit max8998_pmic_remove(struct platform_device *pdev)
599 struct regulator_dev **rdev = max8998->rdev; 601 struct regulator_dev **rdev = max8998->rdev;
600 int i; 602 int i;
601 603
602 for (i = 0; i <= max8998->num_regulators; i++) 604 for (i = 0; i < max8998->num_regulators; i++)
603 if (rdev[i]) 605 if (rdev[i])
604 regulator_unregister(rdev[i]); 606 regulator_unregister(rdev[i]);
605 607
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index c239f42aa4a3..020f5878d7ff 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -626,12 +626,6 @@ fail:
626 return error; 626 return error;
627} 627}
628 628
629/**
630 * tps6507x_remove - TPS6507x driver i2c remove handler
631 * @client: i2c driver client device structure
632 *
633 * Unregister TPS driver as an i2c client device driver
634 */
635static int __devexit tps6507x_pmic_remove(struct platform_device *pdev) 629static int __devexit tps6507x_pmic_remove(struct platform_device *pdev)
636{ 630{
637 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); 631 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 8cff1413a147..51237fbb1bbb 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -133,7 +133,7 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
133 mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; 133 mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift;
134 val = (val & mask) >> ri->volt_shift; 134 val = (val & mask) >> ri->volt_shift;
135 135
136 if (val > ri->desc.n_voltages) 136 if (val >= ri->desc.n_voltages)
137 BUG(); 137 BUG();
138 138
139 return ri->voltages[val] * 1000; 139 return ri->voltages[val] * 1000;
@@ -150,7 +150,7 @@ static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev,
150 if (ret) 150 if (ret)
151 return ret; 151 return ret;
152 152
153 return tps6586x_set_bits(parent, ri->go_reg, ri->go_bit); 153 return tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit);
154} 154}
155 155
156static int tps6586x_regulator_enable(struct regulator_dev *rdev) 156static int tps6586x_regulator_enable(struct regulator_dev *rdev)
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index e686cdb61b97..9edf8f692341 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -215,8 +215,7 @@ static int wm831x_gp_ldo_set_mode(struct regulator_dev *rdev,
215 215
216 case REGULATOR_MODE_IDLE: 216 case REGULATOR_MODE_IDLE:
217 ret = wm831x_set_bits(wm831x, ctrl_reg, 217 ret = wm831x_set_bits(wm831x, ctrl_reg,
218 WM831X_LDO1_LP_MODE, 218 WM831X_LDO1_LP_MODE, 0);
219 WM831X_LDO1_LP_MODE);
220 if (ret < 0) 219 if (ret < 0)
221 return ret; 220 return ret;
222 221
@@ -225,10 +224,12 @@ static int wm831x_gp_ldo_set_mode(struct regulator_dev *rdev,
225 WM831X_LDO1_ON_MODE); 224 WM831X_LDO1_ON_MODE);
226 if (ret < 0) 225 if (ret < 0)
227 return ret; 226 return ret;
227 break;
228 228
229 case REGULATOR_MODE_STANDBY: 229 case REGULATOR_MODE_STANDBY:
230 ret = wm831x_set_bits(wm831x, ctrl_reg, 230 ret = wm831x_set_bits(wm831x, ctrl_reg,
231 WM831X_LDO1_LP_MODE, 0); 231 WM831X_LDO1_LP_MODE,
232 WM831X_LDO1_LP_MODE);
232 if (ret < 0) 233 if (ret < 0)
233 return ret; 234 return ret;
234 235
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 0e6ed7db9364..fe4b8a8a9dfd 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1129,7 +1129,7 @@ static unsigned int wm8350_dcdc_get_mode(struct regulator_dev *rdev)
1129 mode = REGULATOR_MODE_NORMAL; 1129 mode = REGULATOR_MODE_NORMAL;
1130 } else if (!active && !sleep) 1130 } else if (!active && !sleep)
1131 mode = REGULATOR_MODE_IDLE; 1131 mode = REGULATOR_MODE_IDLE;
1132 else if (!sleep) 1132 else if (sleep)
1133 mode = REGULATOR_MODE_STANDBY; 1133 mode = REGULATOR_MODE_STANDBY;
1134 1134
1135 return mode; 1135 return mode;