diff options
Diffstat (limited to 'drivers/regulator/lp3971.c')
-rw-r--r-- | drivers/regulator/lp3971.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index f5532ed79272..671a7d1f1f0e 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/regulator/driver.h> | 19 | #include <linux/regulator/driver.h> |
20 | #include <linux/regulator/lp3971.h> | 20 | #include <linux/regulator/lp3971.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | struct lp3971 { | 23 | struct lp3971 { |
23 | struct device *dev; | 24 | struct device *dev; |
@@ -45,7 +46,7 @@ static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val); | |||
45 | LP3971_BUCK2 -> 4 | 46 | LP3971_BUCK2 -> 4 |
46 | LP3971_BUCK3 -> 6 | 47 | LP3971_BUCK3 -> 6 |
47 | */ | 48 | */ |
48 | #define BUCK_VOL_CHANGE_SHIFT(x) (((1 << x) & ~0x01) << 1) | 49 | #define BUCK_VOL_CHANGE_SHIFT(x) (((!!x) << 2) | (x & ~0x01)) |
49 | #define BUCK_VOL_CHANGE_FLAG_GO 0x01 | 50 | #define BUCK_VOL_CHANGE_FLAG_GO 0x01 |
50 | #define BUCK_VOL_CHANGE_FLAG_TARGET 0x02 | 51 | #define BUCK_VOL_CHANGE_FLAG_TARGET 0x02 |
51 | #define BUCK_VOL_CHANGE_FLAG_MASK 0x03 | 52 | #define BUCK_VOL_CHANGE_FLAG_MASK 0x03 |
@@ -187,7 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev, | |||
187 | return -EINVAL; | 188 | return -EINVAL; |
188 | 189 | ||
189 | return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), | 190 | return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), |
190 | LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), val); | 191 | LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), |
192 | val << LDO_VOL_CONTR_SHIFT(ldo)); | ||
191 | } | 193 | } |
192 | 194 | ||
193 | static struct regulator_ops lp3971_ldo_ops = { | 195 | static struct regulator_ops lp3971_ldo_ops = { |
@@ -439,6 +441,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971, | |||
439 | lp3971->num_regulators = pdata->num_regulators; | 441 | lp3971->num_regulators = pdata->num_regulators; |
440 | lp3971->rdev = kcalloc(pdata->num_regulators, | 442 | lp3971->rdev = kcalloc(pdata->num_regulators, |
441 | sizeof(struct regulator_dev *), GFP_KERNEL); | 443 | sizeof(struct regulator_dev *), GFP_KERNEL); |
444 | if (!lp3971->rdev) { | ||
445 | err = -ENOMEM; | ||
446 | goto err_nomem; | ||
447 | } | ||
442 | 448 | ||
443 | /* Instantiate the regulators */ | 449 | /* Instantiate the regulators */ |
444 | for (i = 0; i < pdata->num_regulators; i++) { | 450 | for (i = 0; i < pdata->num_regulators; i++) { |
@@ -461,6 +467,7 @@ error: | |||
461 | regulator_unregister(lp3971->rdev[i]); | 467 | regulator_unregister(lp3971->rdev[i]); |
462 | kfree(lp3971->rdev); | 468 | kfree(lp3971->rdev); |
463 | lp3971->rdev = NULL; | 469 | lp3971->rdev = NULL; |
470 | err_nomem: | ||
464 | return err; | 471 | return err; |
465 | } | 472 | } |
466 | 473 | ||