Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/lrg/voltage-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6:
  regulator: fix dangling pointers
  lp3971: Fix BUCK_VOL_CHANGE_SHIFT logic
  lp3971: Fix setting val for LDO2 and LDO4
  regulator: Get rid of lockdep warning
  regulator: handle kcalloc() failure
  Regulators: max8925-regulator - clean up driver data after removal
  • Loading branch information
torvalds committed Mar 24, 2010
2 parents 61964eb + 8b4709e commit 34c1c46
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions drivers/regulator/core.c
Expand Up @@ -1038,6 +1038,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
goto overflow_err;

regulator->dev = dev;
sysfs_attr_init(&regulator->dev_attr.attr);
regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
if (regulator->dev_attr.attr.name == NULL)
goto attr_name_err;
Expand Down
10 changes: 8 additions & 2 deletions drivers/regulator/lp3971.c
Expand Up @@ -45,7 +45,7 @@ static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val);
LP3971_BUCK2 -> 4
LP3971_BUCK3 -> 6
*/
#define BUCK_VOL_CHANGE_SHIFT(x) (((1 << x) & ~0x01) << 1)
#define BUCK_VOL_CHANGE_SHIFT(x) (((!!x) << 2) | (x & ~0x01))
#define BUCK_VOL_CHANGE_FLAG_GO 0x01
#define BUCK_VOL_CHANGE_FLAG_TARGET 0x02
#define BUCK_VOL_CHANGE_FLAG_MASK 0x03
Expand Down Expand Up @@ -187,7 +187,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
return -EINVAL;

return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), val);
LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
val << LDO_VOL_CONTR_SHIFT(ldo));
}

static struct regulator_ops lp3971_ldo_ops = {
Expand Down Expand Up @@ -439,6 +440,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
lp3971->num_regulators = pdata->num_regulators;
lp3971->rdev = kcalloc(pdata->num_regulators,
sizeof(struct regulator_dev *), GFP_KERNEL);
if (!lp3971->rdev) {
err = -ENOMEM;
goto err_nomem;
}

/* Instantiate the regulators */
for (i = 0; i < pdata->num_regulators; i++) {
Expand All @@ -461,6 +466,7 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
regulator_unregister(lp3971->rdev[i]);
kfree(lp3971->rdev);
lp3971->rdev = NULL;
err_nomem:
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/max1586.c
Expand Up @@ -243,8 +243,8 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
for (i = 0; i <= MAX1586_V6; i++)
if (rdev[i])
regulator_unregister(rdev[i]);
kfree(rdev);
i2c_set_clientdata(client, NULL);
kfree(rdev);

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/max8649.c
Expand Up @@ -356,6 +356,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
dev_info(info->dev, "Max8649 regulator device is detected.\n");
return 0;
out:
i2c_set_clientdata(client, NULL);
kfree(info);
return ret;
}
Expand All @@ -367,9 +368,9 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client)
if (info) {
if (info->regulator)
regulator_unregister(info->regulator);
i2c_set_clientdata(client, NULL);
kfree(info);
}
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/max8660.c
Expand Up @@ -470,8 +470,8 @@ static int __devexit max8660_remove(struct i2c_client *client)
for (i = 0; i < MAX8660_V_END; i++)
if (rdev[i])
regulator_unregister(rdev[i]);
kfree(rdev);
i2c_set_clientdata(client, NULL);
kfree(rdev);

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/regulator/max8925-regulator.c
Expand Up @@ -230,7 +230,7 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
};

static inline struct max8925_regulator_info *find_regulator_info(int id)
static struct max8925_regulator_info * __devinit find_regulator_info(int id)
{
struct max8925_regulator_info *ri;
int i;
Expand All @@ -247,7 +247,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct max8925_platform_data *pdata = chip->dev->platform_data;
struct max8925_regulator_info *ri = NULL;
struct max8925_regulator_info *ri;
struct regulator_dev *rdev;

ri = find_regulator_info(pdev->id);
Expand All @@ -274,7 +274,9 @@ static int __devexit max8925_regulator_remove(struct platform_device *pdev)
{
struct regulator_dev *rdev = platform_get_drvdata(pdev);

platform_set_drvdata(pdev, NULL);
regulator_unregister(rdev);

return 0;
}

Expand Down

0 comments on commit 34c1c46

Please sign in to comment.