regulator: Fix desc_id for tps65023/6507x/65910

The desc_id variable should not be a static variable.

The rest of the code assumes the desc_id must less than TPSxxxxx_NUM_REGULATOR.
If we set desc_id to be a static variable, checking the return value of
rdev_get_id() may return error.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Anuj Aggarwal <anuj.aggarwal@ti.com>
Cc: Graeme Gregory <gg@slimlogic.co.uk>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
This commit is contained in:
Axel Lin 2011-05-12 13:47:50 +08:00 committed by Liam Girdwood
parent c01e36dde4
commit 77fa44d0e1
3 changed files with 3 additions and 6 deletions

View File

@ -466,7 +466,6 @@ static struct regulator_ops tps65023_ldo_ops = {
static int __devinit tps_65023_probe(struct i2c_client *client, static int __devinit tps_65023_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
static int desc_id;
const struct tps_info *info = (void *)id->driver_data; const struct tps_info *info = (void *)id->driver_data;
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
struct regulator_dev *rdev; struct regulator_dev *rdev;
@ -499,7 +498,7 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
tps->info[i] = info; tps->info[i] = info;
tps->desc[i].name = info->name; tps->desc[i].name = info->name;
tps->desc[i].id = desc_id++; tps->desc[i].id = i;
tps->desc[i].n_voltages = num_voltages[i]; tps->desc[i].n_voltages = num_voltages[i];
tps->desc[i].ops = (i > TPS65023_DCDC_3 ? tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
&tps65023_ldo_ops : &tps65023_dcdc_ops); &tps65023_ldo_ops : &tps65023_dcdc_ops);

View File

@ -553,7 +553,6 @@ static __devinit
int tps6507x_pmic_probe(struct platform_device *pdev) int tps6507x_pmic_probe(struct platform_device *pdev)
{ {
struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
static int desc_id;
struct tps_info *info = &tps6507x_pmic_regs[0]; struct tps_info *info = &tps6507x_pmic_regs[0];
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
struct regulator_dev *rdev; struct regulator_dev *rdev;
@ -598,7 +597,7 @@ int tps6507x_pmic_probe(struct platform_device *pdev)
} }
tps->desc[i].name = info->name; tps->desc[i].name = info->name;
tps->desc[i].id = desc_id++; tps->desc[i].id = i;
tps->desc[i].n_voltages = num_voltages[i]; tps->desc[i].n_voltages = num_voltages[i];
tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? tps->desc[i].ops = (i > TPS6507X_DCDC_3 ?
&tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops); &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops);

View File

@ -604,7 +604,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct tps65910_reg *pmic; struct tps65910_reg *pmic;
struct tps65910_board *pmic_plat_data; struct tps65910_board *pmic_plat_data;
static int desc_id;
int i, err; int i, err;
pmic_plat_data = dev_get_platdata(tps65910->dev); pmic_plat_data = dev_get_platdata(tps65910->dev);
@ -630,7 +629,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
pmic->info[i] = info; pmic->info[i] = info;
pmic->desc[i].name = info->name; pmic->desc[i].name = info->name;
pmic->desc[i].id = desc_id++; pmic->desc[i].id = i;
pmic->desc[i].n_voltages = info->table_len; pmic->desc[i].n_voltages = info->table_len;
if ((i == TPS65910_REG_VDD1) || (i == TPS65910_REG_VDD2)) if ((i == TPS65910_REG_VDD1) || (i == TPS65910_REG_VDD2))