2011-05-09 00:33:53

by Samuel Ortiz

[permalink] [raw]
Subject: [PATCH 16/19] mfd: Use mfd cell platform_data for tps6105x cells platform bits

With the addition of a platform device mfd_cell pointer, MFD drivers
can go back to passing platform data back to their sub drivers.
This allows for an mfd_cell->mfd_data removal and thus keep the
sub drivers MFD agnostic. This is mostly needed for non MFD aware
sub drivers.

Cc: Mark Brown <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Linus Walleij <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
---
drivers/mfd/tps6105x.c | 3 ++-
drivers/regulator/tps6105x-regulator.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index 46d8205..a293b97 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -183,7 +183,8 @@ static int __devinit tps6105x_probe(struct i2c_client *client,
/* Set up and register the platform devices. */
for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
/* One state holder for all drivers, this is simple */
- tps6105x_cells[i].mfd_data = tps6105x;
+ tps6105x_cells[i].platform_data = tps6105x;
+ tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
}

ret = mfd_add_devices(&client->dev, 0, tps6105x_cells,
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c
index 1661499..4453a2a 100644
--- a/drivers/regulator/tps6105x-regulator.c
+++ b/drivers/regulator/tps6105x-regulator.c
@@ -137,7 +137,7 @@ static struct regulator_desc tps6105x_regulator_desc = {
*/
static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
{
- struct tps6105x *tps6105x = mfd_get_data(pdev);
+ struct tps6105x *tps6105x = pdev->dev.platform_data;
struct tps6105x_platform_data *pdata = tps6105x->pdata;
int ret;

@@ -164,7 +164,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)

static int __devexit tps6105x_regulator_remove(struct platform_device *pdev)
{
- struct tps6105x *tps6105x = platform_get_drvdata(pdev);
+ struct tps6105x *tps6105x = pdev->dev.platform_data;
regulator_unregister(tps6105x->regulator);
return 0;
}
--
1.7.2.3


2011-05-09 07:05:21

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 16/19] mfd: Use mfd cell platform_data for tps6105x cells platform bits

2011/5/9 Samuel Ortiz <[email protected]>:

> With the addition of a platform device mfd_cell pointer, MFD drivers
> can go back to passing platform data back to their sub drivers.
> This allows for an mfd_cell->mfd_data removal and thus keep the
> sub drivers MFD agnostic. This is mostly needed for non MFD aware
> sub drivers.
>
> Cc: Mark Brown <[email protected]>
> Cc: Liam Girdwood <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Signed-off-by: Samuel Ortiz <[email protected]>

I have some question marks on this one...

> --- a/drivers/mfd/tps6105x.c
> +++ b/drivers/mfd/tps6105x.c
> @@ -183,7 +183,8 @@ static int __devinit tps6105x_probe(struct i2c_client *client,
> ? ? ? ?/* Set up and register the platform devices. */
> ? ? ? ?for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
> ? ? ? ? ? ? ? ?/* One state holder for all drivers, this is simple */
> - ? ? ? ? ? ? ? tps6105x_cells[i].mfd_data = tps6105x;
> + ? ? ? ? ? ? ? tps6105x_cells[i].platform_data = tps6105x;
> + ? ? ? ? ? ? ? tps6105x_cells[i].pdata_size = sizeof(*tps6105x);

ACK

> --- a/drivers/regulator/tps6105x-regulator.c
> +++ b/drivers/regulator/tps6105x-regulator.c
> @@ -137,7 +137,7 @@ static struct regulator_desc tps6105x_regulator_desc = {
> ?*/
> ?static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
> ?{
> - ? ? ? struct tps6105x *tps6105x = mfd_get_data(pdev);
> + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;

Can you use platform_get_drvdata(pdev); instead?

> ? ? ? ?struct tps6105x_platform_data *pdata = tps6105x->pdata;
> ? ? ? ?int ret;
>
> @@ -164,7 +164,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
>
> ?static int __devexit tps6105x_regulator_remove(struct platform_device *pdev)
> ?{
> - ? ? ? struct tps6105x *tps6105x = platform_get_drvdata(pdev);
> + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;

And this is a NO-OP, actually a bug in the present code, just leave it
as it is and the other changes removing the mfd->mfd_data fixes the bug...

Yours,
Linus Walleij

2011-05-11 15:49:00

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 16/19] mfd: Use mfd cell platform_data for tps6105x cells platform bits

Hi Linus,

On Mon, May 09, 2011 at 09:05:19AM +0200, Linus Walleij wrote:
> 2011/5/9 Samuel Ortiz <[email protected]>:
>
> > With the addition of a platform device mfd_cell pointer, MFD drivers
> > can go back to passing platform data back to their sub drivers.
> > This allows for an mfd_cell->mfd_data removal and thus keep the
> > sub drivers MFD agnostic. This is mostly needed for non MFD aware
> > sub drivers.
> >
> > Cc: Mark Brown <[email protected]>
> > Cc: Liam Girdwood <[email protected]>
> > Cc: Linus Walleij <[email protected]>
> > Signed-off-by: Samuel Ortiz <[email protected]>
>
> I have some question marks on this one...
>
> > --- a/drivers/mfd/tps6105x.c
> > +++ b/drivers/mfd/tps6105x.c
> > @@ -183,7 +183,8 @@ static int __devinit tps6105x_probe(struct i2c_client *client,
> > ? ? ? ?/* Set up and register the platform devices. */
> > ? ? ? ?for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
> > ? ? ? ? ? ? ? ?/* One state holder for all drivers, this is simple */
> > - ? ? ? ? ? ? ? tps6105x_cells[i].mfd_data = tps6105x;
> > + ? ? ? ? ? ? ? tps6105x_cells[i].platform_data = tps6105x;
> > + ? ? ? ? ? ? ? tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
>
> ACK
>
> > --- a/drivers/regulator/tps6105x-regulator.c
> > +++ b/drivers/regulator/tps6105x-regulator.c
> > @@ -137,7 +137,7 @@ static struct regulator_desc tps6105x_regulator_desc = {
> > ?*/
> > ?static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
> > ?{
> > - ? ? ? struct tps6105x *tps6105x = mfd_get_data(pdev);
> > + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;
>
> Can you use platform_get_drvdata(pdev); instead?
I suppose you mean dev_get_platdata() ?


> > ? ? ? ?struct tps6105x_platform_data *pdata = tps6105x->pdata;
> > ? ? ? ?int ret;
> >
> > @@ -164,7 +164,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
> >
> > ?static int __devexit tps6105x_regulator_remove(struct platform_device *pdev)
> > ?{
> > - ? ? ? struct tps6105x *tps6105x = platform_get_drvdata(pdev);
> > + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;
>
> And this is a NO-OP, actually a bug in the present code, just leave it
> as it is and the other changes removing the mfd->mfd_data fixes the bug...
I agree it's a bug in the current code. But I need to fetch the platform_data
pointer, so here again I would have to call dev_get_platdata().

Cheers,
Samuel.


> Yours,
> Linus Walleij

--
Intel Open Source Technology Centre
http://oss.intel.com/

2011-05-11 17:31:15

by Samuel Ortiz

[permalink] [raw]
Subject: [PATCH v1 16/19] mfd: Use mfd cell platform_data for tps6105x cells platform bits

With the addition of a platform device mfd_cell pointer, MFD drivers
can go back to passing platform data back to their sub drivers.
This allows for an mfd_cell->mfd_data removal and thus keep the
sub drivers MFD agnostic. This is mostly needed for non MFD aware
sub drivers.

Cc: Mark Brown <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Linus Walleij <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
---

v0 -> v1: Use dev_get_platdata instead of accessing the platform_data pointer
directly.

---
drivers/mfd/tps6105x.c | 3 ++-
drivers/regulator/tps6105x-regulator.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index 46d8205..a293b97 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -183,7 +183,8 @@ static int __devinit tps6105x_probe(struct i2c_client *client,
/* Set up and register the platform devices. */
for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
/* One state holder for all drivers, this is simple */
- tps6105x_cells[i].mfd_data = tps6105x;
+ tps6105x_cells[i].platform_data = tps6105x;
+ tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
}

ret = mfd_add_devices(&client->dev, 0, tps6105x_cells,
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c
index 1661499..a4d7f45 100644
--- a/drivers/regulator/tps6105x-regulator.c
+++ b/drivers/regulator/tps6105x-regulator.c
@@ -137,7 +137,7 @@ static struct regulator_desc tps6105x_regulator_desc = {
*/
static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)
{
- struct tps6105x *tps6105x = mfd_get_data(pdev);
+ struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev);
struct tps6105x_platform_data *pdata = tps6105x->pdata;
int ret;

@@ -164,7 +164,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev)

static int __devexit tps6105x_regulator_remove(struct platform_device *pdev)
{
- struct tps6105x *tps6105x = platform_get_drvdata(pdev);
+ struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev);
regulator_unregister(tps6105x->regulator);
return 0;
}
--
1.7.2.3

--
Intel Open Source Technology Centre
http://oss.intel.com/

2011-05-11 19:41:32

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 16/19] mfd: Use mfd cell platform_data for tps6105x cells platform bits

2011/5/11 Samuel Ortiz <[email protected]>:
>> > - ? ? ? struct tps6105x *tps6105x = mfd_get_data(pdev);
>> > + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;
>>
>> Can you use platform_get_drvdata(pdev); instead?
>
> I suppose you mean dev_get_platdata() ?

Yes, sorry.

>> > ?static int __devexit tps6105x_regulator_remove(struct platform_device *pdev)
>> > ?{
>> > - ? ? ? struct tps6105x *tps6105x = platform_get_drvdata(pdev);
>> > + ? ? ? struct tps6105x *tps6105x = pdev->dev.platform_data;
>>
>> And this is a NO-OP, actually a bug in the present code, just leave it
>> as it is and the other changes removing the mfd->mfd_data fixes the bug...
>
> I agree it's a bug in the current code. But I need to fetch the platform_data
> pointer, so here again I would have to call dev_get_platdata().

Yes again, you're right.

I was mainly after using the pretty accessor functions rather than direct
dereferencing, no big deal.

Thanks,
Linus Walleij