[PATCH 12/13] regulator: check name in initialization of max8925

From: Haojian Zhuang
Date: Wed Apr 13 2011 - 10:56:35 EST


Check name in initialization of max8925 regulator driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@xxxxxxxxxxx>
Cc: Liam Girdwood <lrg@xxxxxxxxxxxxxxx>
Cc: Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/regulator/max8925-regulator.c | 37 +++++++++++++++-----------------
1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 8ae1475..ce821e4 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -169,7 +169,7 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
#define MAX8925_SDV(_id, min, max, step) \
{ \
.desc = { \
- .name = "SDV" #_id, \
+ .name = "SD" #_id, \
.ops = &max8925_regulator_sdv_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \
@@ -231,39 +231,36 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
};

-static struct max8925_regulator_info * __devinit find_regulator_info(int id)
+static int __devinit max8925_regulator_probe(struct platform_device *pdev)
{
- struct max8925_regulator_info *ri;
+ struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
+ struct max8925_regulator_info *ri = NULL;
+ struct regulator_init_data *pdata;
+ struct regulator_dev *rdev;
int i;

+ pdata = pdev->dev.platform_data;
+ if (pdata == NULL)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
- if (ri->desc.id == id)
- return ri;
+ if (!strcmp(ri->desc.name, pdata->constraints.name))
+ break;
}
- return NULL;
-}
-
-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;
- struct regulator_dev *rdev;
-
- ri = find_regulator_info(pdev->id);
- if (ri == NULL) {
- dev_err(&pdev->dev, "invalid regulator ID specified\n");
+ if (i > ARRAY_SIZE(max8925_regulator_info)) {
+ dev_err(&pdev->dev, "Failed to find regulator %s\n",
+ pdata->constraints.name);
return -EINVAL;
}
ri->i2c = chip->i2c;
ri->chip = chip;

rdev = regulator_register(&ri->desc, &pdev->dev,
- pdata->regulator[pdev->id], ri);
+ pdata, ri);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
- ri->desc.name);
+ ri->desc.name);
return PTR_ERR(rdev);
}

--
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/