2009-01-19 13:39:29

by Mark Brown

[permalink] [raw]
Subject: [PATCH 1/5] regulator: Pass regulator init data as explict argument when registering

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 <[email protected]>
---
drivers/regulator/bq24022.c | 2 +-
drivers/regulator/core.c | 5 +++--
drivers/regulator/da903x.c | 3 ++-
drivers/regulator/pcf50633-regulator.c | 3 ++-
drivers/regulator/wm8350-regulator.c | 2 +-
drivers/regulator/wm8400-regulator.c | 2 +-
include/linux/regulator/driver.h | 3 ++-
7 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
index 366565a..50129b4 100644
--- a/drivers/regulator/bq24022.c
+++ b/drivers/regulator/bq24022.c
@@ -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);
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0ff95c3..314997b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1874,17 +1874,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)
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index fe77730..72b1549 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -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);
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index 4cc85ec..cd761d8 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -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);

diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 5056e23..510920e 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1333,9 +1333,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",
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 56e23d4..6ed43b0 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -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);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 6e957aa..2254ad9 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -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,
--
1.5.6.5


2009-01-19 13:37:45

by Mark Brown

[permalink] [raw]
Subject: [PATCH 4/5] regulator: Make fixed voltage regulators visible in Kconfig

This allows users to enable or disable support for these regulators at
build time as they can for other regulators rather than having platforms
force the regulators to be built in.

Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/Kconfig | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index e7e0cf1..85a1f40 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -29,8 +29,12 @@ config REGULATOR_DEBUG
Say yes here to enable debugging support.

config REGULATOR_FIXED_VOLTAGE
- tristate
+ tristate "Fixed voltage regulator support"
default n
+ help
+ This driver provides support for fixed voltage regulators,
+ useful for systems which use a combination of software
+ managed regulators and simple non-configurable regulators.

config REGULATOR_VIRTUAL_CONSUMER
tristate "Virtual regulator consumer support"
--
1.5.6.5

2009-01-19 13:38:00

by Mark Brown

[permalink] [raw]
Subject: [PATCH 2/5] regulator: Allow init data to be supplied for bq24022

Previously it was not possible to do so, making it impossible for
machines to configure the driver.

Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/bq24022.c | 3 ++-
include/linux/regulator/bq24022.h | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
index 50129b4..141f8b6 100644
--- a/drivers/regulator/bq24022.c
+++ b/drivers/regulator/bq24022.c
@@ -105,7 +105,8 @@ 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, NULL, pdata);
+ bq24022 = regulator_register(&bq24022_desc, &pdev->dev,
+ pdata->init_data, pdata);
if (IS_ERR(bq24022)) {
dev_dbg(&pdev->dev, "couldn't register regulator\n");
ret = PTR_ERR(bq24022);
diff --git a/include/linux/regulator/bq24022.h b/include/linux/regulator/bq24022.h
index e84b0a9..a6d0140 100644
--- a/include/linux/regulator/bq24022.h
+++ b/include/linux/regulator/bq24022.h
@@ -10,6 +10,8 @@
*
*/

+struct regulator_init_data;
+
/**
* bq24022_mach_info - platform data for bq24022
* @gpio_nce: GPIO line connected to the nCE pin, used to enable / disable charging
@@ -18,4 +20,5 @@
struct bq24022_mach_info {
int gpio_nce;
int gpio_iset2;
+ struct regulator_init_data *init_data;
};
--
1.5.6.5

2009-01-19 13:38:33

by Mark Brown

[permalink] [raw]
Subject: [PATCH 5/5] regulator: Mark attributes table for virtual regulator static

It's not exported.

Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/virtual.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index 45ebbc2..3d08348 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -260,7 +260,7 @@ static DEVICE_ATTR(min_microamps, 0666, show_min_uA, set_min_uA);
static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA);
static DEVICE_ATTR(mode, 0666, show_mode, set_mode);

-struct device_attribute *attributes[] = {
+static struct device_attribute *attributes[] = {
&dev_attr_min_microvolts,
&dev_attr_max_microvolts,
&dev_attr_min_microamps,
--
1.5.6.5

2009-01-19 13:39:00

by Mark Brown

[permalink] [raw]
Subject: [PATCH 3/5] regulator: Allow init_data to be passed to fixed voltage regulators

Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/fixed.c | 3 ++-
include/linux/regulator/fixed.h | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index d31db3e..23d5546 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -73,7 +73,8 @@ static int regulator_fixed_voltage_probe(struct platform_device *pdev)

drvdata->microvolts = config->microvolts;

- drvdata->dev = regulator_register(&drvdata->desc, drvdata);
+ drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev,
+ config->init_data, drvdata);
if (IS_ERR(drvdata->dev)) {
ret = PTR_ERR(drvdata->dev);
goto err_name;
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index 1387a5d..91b4da3 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -14,9 +14,12 @@
#ifndef __REGULATOR_FIXED_H
#define __REGULATOR_FIXED_H

+struct regulator_init_data;
+
struct fixed_voltage_config {
const char *supply_name;
int microvolts;
+ struct regulator_init_data *init_data;
};

#endif
--
1.5.6.5

2009-01-19 17:25:36

by Philipp Zabel

[permalink] [raw]
Subject: Re: [PATCH 1/5] regulator: Pass regulator init data as explict argument when registering

On Mon, Jan 19, 2009 at 2:37 PM, Mark Brown
<[email protected]> wrote:
> 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.

Good, I had a local patch that would pass bq24022_mach_info in
regulator_init_data->driver_data instead of platform_data.
Now that there is a possibility to pass platform_data, is there still
need for the driver_data field in regulator_init_data and for the
regulator_get_init_drvdata() function?

cheers
Philipp

> Signed-off-by: Mark Brown <[email protected]>
> ---
> drivers/regulator/bq24022.c | 2 +-
> drivers/regulator/core.c | 5 +++--
> drivers/regulator/da903x.c | 3 ++-
> drivers/regulator/pcf50633-regulator.c | 3 ++-
> drivers/regulator/wm8350-regulator.c | 2 +-
> drivers/regulator/wm8400-regulator.c | 2 +-
> include/linux/regulator/driver.h | 3 ++-
> 7 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
> index 366565a..50129b4 100644
> --- a/drivers/regulator/bq24022.c
> +++ b/drivers/regulator/bq24022.c
> @@ -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);
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 0ff95c3..314997b 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1874,17 +1874,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)
> diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
> index fe77730..72b1549 100644
> --- a/drivers/regulator/da903x.c
> +++ b/drivers/regulator/da903x.c
> @@ -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);
> diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
> index 4cc85ec..cd761d8 100644
> --- a/drivers/regulator/pcf50633-regulator.c
> +++ b/drivers/regulator/pcf50633-regulator.c
> @@ -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);
>
> diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
> index 5056e23..510920e 100644
> --- a/drivers/regulator/wm8350-regulator.c
> +++ b/drivers/regulator/wm8350-regulator.c
> @@ -1333,9 +1333,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",
> diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
> index 56e23d4..6ed43b0 100644
> --- a/drivers/regulator/wm8400-regulator.c
> +++ b/drivers/regulator/wm8400-regulator.c
> @@ -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);
> diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
> index 6e957aa..2254ad9 100644
> --- a/include/linux/regulator/driver.h
> +++ b/include/linux/regulator/driver.h
> @@ -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,
> --
> 1.5.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2009-01-19 17:38:00

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/5] regulator: Pass regulator init data as explict argument when registering

On Mon, Jan 19, 2009 at 06:24:50PM +0100, pHilipp Zabel wrote:

> Good, I had a local patch that would pass bq24022_mach_info in
> regulator_init_data->driver_data instead of platform_data.
> Now that there is a possibility to pass platform_data, is there still
> need for the driver_data field in regulator_init_data and for the
> regulator_get_init_drvdata() function?

I'd not expect so, no. The driver doesn't get to see the constraints.

2009-01-20 20:11:10

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH 1/5] regulator: Pass regulator init data as explict argument when registering

On Mon, 2009-01-19 at 13:37 +0000, Mark Brown wrote:
> 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 <[email protected]>
> ---
> drivers/regulator/bq24022.c | 2 +-
> drivers/regulator/core.c | 5 +++--
> drivers/regulator/da903x.c | 3 ++-
> drivers/regulator/pcf50633-regulator.c | 3 ++-
> drivers/regulator/wm8350-regulator.c | 2 +-
> drivers/regulator/wm8400-regulator.c | 2 +-
> include/linux/regulator/driver.h | 3 ++-
> 7 files changed, 12 insertions(+), 8 deletions(-)
>

All applied.

Thanks

Liam