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