Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262154
b: refs/heads/master
c: 39aa9b6
h: refs/heads/master
v: v3
  • Loading branch information
Axel Lin authored and Liam Girdwood committed Jul 22, 2011
1 parent 724db5d commit a1b5d39
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d04156bca629740a661fd0738cd69ba1f08b2b20
refs/heads/master: 39aa9b6e3cb1b2a564d3422eedb7f725179162d3
55 changes: 43 additions & 12 deletions trunk/drivers/regulator/tps65910-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#define TPS65911_REG_LDO7 11
#define TPS65911_REG_LDO8 12

#define TPS65910_NUM_REGULATOR 13
#define TPS65910_SUPPLY_STATE_ENABLED 0x1

/* supported VIO voltages in milivolts */
Expand Down Expand Up @@ -264,11 +263,12 @@ static struct tps_info tps65911_regs[] = {
};

struct tps65910_reg {
struct regulator_desc desc[TPS65910_NUM_REGULATOR];
struct regulator_desc *desc;
struct tps65910 *mfd;
struct regulator_dev *rdev[TPS65910_NUM_REGULATOR];
struct tps_info *info[TPS65910_NUM_REGULATOR];
struct regulator_dev **rdev;
struct tps_info **info;
struct mutex mutex;
int num_regulators;
int mode;
int (*get_ctrl_reg)(int);
};
Expand Down Expand Up @@ -902,10 +902,12 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
switch(tps65910_chip_id(tps65910)) {
case TPS65910:
pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
info = tps65910_regs;
break;
case TPS65911:
pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
info = tps65911_regs;
break;
default:
Expand All @@ -914,7 +916,28 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
return -ENODEV;
}

for (i = 0; i < TPS65910_NUM_REGULATOR; i++, info++, reg_data++) {
pmic->desc = kcalloc(pmic->num_regulators,
sizeof(struct regulator_desc), GFP_KERNEL);
if (!pmic->desc) {
err = -ENOMEM;
goto err_free_pmic;
}

pmic->info = kcalloc(pmic->num_regulators,
sizeof(struct tps_info *), GFP_KERNEL);
if (!pmic->info) {
err = -ENOMEM;
goto err_free_desc;
}

pmic->rdev = kcalloc(pmic->num_regulators,
sizeof(struct regulator_dev *), GFP_KERNEL);
if (!pmic->rdev) {
err = -ENOMEM;
goto err_free_info;
}

for (i = 0; i < pmic->num_regulators; i++, info++, reg_data++) {
/* Register the regulators */
pmic->info[i] = info;

Expand Down Expand Up @@ -946,31 +969,39 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
"failed to register %s regulator\n",
pdev->name);
err = PTR_ERR(rdev);
goto err;
goto err_unregister_regulator;
}

/* Save regulator for cleanup */
pmic->rdev[i] = rdev;
}
return 0;

err:
err_unregister_regulator:
while (--i >= 0)
regulator_unregister(pmic->rdev[i]);

kfree(pmic->rdev);
err_free_info:
kfree(pmic->info);
err_free_desc:
kfree(pmic->desc);
err_free_pmic:
kfree(pmic);
return err;
}

static int __devexit tps65910_remove(struct platform_device *pdev)
{
struct tps65910_reg *tps65910_reg = platform_get_drvdata(pdev);
struct tps65910_reg *pmic = platform_get_drvdata(pdev);
int i;

for (i = 0; i < TPS65910_NUM_REGULATOR; i++)
regulator_unregister(tps65910_reg->rdev[i]);
for (i = 0; i < pmic->num_regulators; i++)
regulator_unregister(pmic->rdev[i]);

kfree(tps65910_reg);
kfree(pmic->rdev);
kfree(pmic->info);
kfree(pmic->desc);
kfree(pmic);
return 0;
}

Expand Down

0 comments on commit a1b5d39

Please sign in to comment.