aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8925-regulator.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-09-17 00:19:05 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-19 06:39:13 -0400
commit51acdb61185e9c7579366712a415fc929929d3bb (patch)
treec37afd2862d859ba9e9b3ae31e0b0a75b77fb476 /drivers/regulator/max8925-regulator.c
parent63b501e22aa9b22cdfe206a5670aaae646d93021 (diff)
mfd: max8925: Remove array in regulator platform data
Remove array in parent's platform data. Use struct regulator_init_data as regulator device's platform data directly. So a lot of pdata are added into parent's platform data. And voltage out register offset is used as IORESOURCE_REG to distinguish different regualtor devices. Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator/max8925-regulator.c')
-rw-r--r--drivers/regulator/max8925-regulator.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 43dc97ec3932..9bb0be37495f 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -214,37 +214,36 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
214 MAX8925_LDO(20, 750, 3900, 50), 214 MAX8925_LDO(20, 750, 3900, 50),
215}; 215};
216 216
217static struct max8925_regulator_info * __devinit find_regulator_info(int id)
218{
219 struct max8925_regulator_info *ri;
220 int i;
221
222 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
223 ri = &max8925_regulator_info[i];
224 if (ri->desc.id == id)
225 return ri;
226 }
227 return NULL;
228}
229
230static int __devinit max8925_regulator_probe(struct platform_device *pdev) 217static int __devinit max8925_regulator_probe(struct platform_device *pdev)
231{ 218{
232 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 219 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
233 struct max8925_platform_data *pdata = chip->dev->platform_data; 220 struct regulator_init_data *pdata = pdev->dev.platform_data;
234 struct regulator_config config = { }; 221 struct regulator_config config = { };
235 struct max8925_regulator_info *ri; 222 struct max8925_regulator_info *ri;
223 struct resource *res;
236 struct regulator_dev *rdev; 224 struct regulator_dev *rdev;
225 int i;
237 226
238 ri = find_regulator_info(pdev->id); 227 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
239 if (ri == NULL) { 228 if (!res) {
240 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 229 dev_err(&pdev->dev, "No REG resource!\n");
230 return -EINVAL;
231 }
232 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
233 ri = &max8925_regulator_info[i];
234 if (ri->vol_reg == res->start)
235 break;
236 }
237 if (i == ARRAY_SIZE(max8925_regulator_info)) {
238 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
239 (unsigned long long)res->start);
241 return -EINVAL; 240 return -EINVAL;
242 } 241 }
243 ri->i2c = chip->i2c; 242 ri->i2c = chip->i2c;
244 ri->chip = chip; 243 ri->chip = chip;
245 244
246 config.dev = &pdev->dev; 245 config.dev = &pdev->dev;
247 config.init_data = pdata->regulator[pdev->id]; 246 config.init_data = pdata;
248 config.driver_data = ri; 247 config.driver_data = ri;
249 248
250 rdev = regulator_register(&ri->desc, &config); 249 rdev = regulator_register(&ri->desc, &config);