Skip to content

Commit

Permalink
regulator: Pass regulator init data as explict argument when registering
Browse files Browse the repository at this point in the history
Rather than having the regulator init data read from the platform_data
member of the struct device that is registered for the regulator make
the init data an explict argument passed in when registering. This
allows drivers to use the platform data for their own purposes if they
wish.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Mark Brown authored and Liam Girdwood committed Mar 31, 2009
1 parent b136fb4 commit 0527100
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/regulator/bq24022.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int __init bq24022_probe(struct platform_device *pdev)
ret = gpio_direction_output(pdata->gpio_iset2, 0);
ret = gpio_direction_output(pdata->gpio_nce, 1);

bq24022 = regulator_register(&bq24022_desc, &pdev->dev, pdata);
bq24022 = regulator_register(&bq24022_desc, &pdev->dev, NULL, pdata);
if (IS_ERR(bq24022)) {
dev_dbg(&pdev->dev, "couldn't register regulator\n");
ret = PTR_ERR(bq24022);
Expand Down
5 changes: 3 additions & 2 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1879,17 +1879,18 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
* regulator_register - register regulator
* @regulator_desc: regulator to register
* @dev: struct device for the regulator
* @init_data: platform provided init data, passed through by driver
* @driver_data: private regulator data
*
* Called by regulator drivers to register a regulator.
* Returns 0 on success.
*/
struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
struct device *dev, void *driver_data)
struct device *dev, struct regulator_init_data *init_data,
void *driver_data)
{
static atomic_t regulator_no = ATOMIC_INIT(0);
struct regulator_dev *rdev;
struct regulator_init_data *init_data = dev->platform_data;
int ret, i;

if (regulator_desc == NULL)
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/da903x.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev)
if (ri->desc.id == DA9030_ID_LDO1 || ri->desc.id == DA9030_ID_LDO15)
ri->desc.ops = &da9030_regulator_ldo1_15_ops;

rdev = regulator_register(&ri->desc, &pdev->dev, ri);
rdev = regulator_register(&ri->desc, &pdev->dev,
pdev->dev.platform_data, ri);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
ri->desc.name);
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/pcf50633-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
/* Already set by core driver */
pcf = platform_get_drvdata(pdev);

rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
pdev->dev.platform_data, pcf);
if (IS_ERR(rdev))
return PTR_ERR(rdev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/wm8350-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,9 @@ static int wm8350_regulator_probe(struct platform_device *pdev)
break;
}


/* register regulator */
rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev,
pdev->dev.platform_data,
dev_get_drvdata(&pdev->dev));
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register %s\n",
Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/wm8400-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev;

rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
pdev->dev.driver_data);
pdev->dev.platform_data, pdev->dev.driver_data);

if (IS_ERR(rdev))
return PTR_ERR(rdev);
Expand Down
3 changes: 2 additions & 1 deletion include/linux/regulator/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ struct regulator_desc {
};

struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
struct device *dev, void *driver_data);
struct device *dev, struct regulator_init_data *init_data,
void *driver_data);
void regulator_unregister(struct regulator_dev *rdev);

int regulator_notifier_call_chain(struct regulator_dev *rdev,
Expand Down

0 comments on commit 0527100

Please sign in to comment.