* platform_device_add_data(pdev, NULL, 0)
@ 2009-10-23 20:26 Uwe Kleine-König
2009-10-26 16:48 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2009-10-23 20:26 UTC (permalink / raw)
To: linux-kernel
Cc: Russell King, Greg Kroah-Hartman, Andrew Morton, Samuel Ortiz,
Mark Brown
Hello,
mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do
allocate platform_devices.
It contains:
ret = platform_device_add_data(pdev,
cell->platform_data, cell->data_size);
If cell->data_size is 0 (and so likely cell->platform_data == NULL),
still pdev->dev.platform_data get assigned ZERO_SIZE_PTR.
IMHO the result should better be that pdev->dev.platform_data ends being
NULL, too. Agreed?
If yes, where is the right place to fix that, mfd_add_device() or
platform_device_add_data()?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: platform_device_add_data(pdev, NULL, 0)
2009-10-23 20:26 platform_device_add_data(pdev, NULL, 0) Uwe Kleine-König
@ 2009-10-26 16:48 ` Greg KH
2009-10-26 21:19 ` Uwe Kleine-König
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2009-10-26 16:48 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, Russell King, Andrew Morton, Samuel Ortiz,
Mark Brown
On Fri, Oct 23, 2009 at 10:26:22PM +0200, Uwe Kleine-König wrote:
> Hello,
>
> mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do
> allocate platform_devices.
>
> It contains:
>
> ret = platform_device_add_data(pdev,
> cell->platform_data, cell->data_size);
>
> If cell->data_size is 0 (and so likely cell->platform_data == NULL),
> still pdev->dev.platform_data get assigned ZERO_SIZE_PTR.
>
> IMHO the result should better be that pdev->dev.platform_data ends being
> NULL, too. Agreed?
Why? Is this causing problems somewhere?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: platform_device_add_data(pdev, NULL, 0)
2009-10-26 16:48 ` Greg KH
@ 2009-10-26 21:19 ` Uwe Kleine-König
2009-10-26 21:21 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2009-10-26 21:19 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, Russell King, Andrew Morton, Samuel Ortiz,
Mark Brown
Hi Greg,
On Mon, Oct 26, 2009 at 09:48:07AM -0700, Greg KH wrote:
> On Fri, Oct 23, 2009 at 10:26:22PM +0200, Uwe Kleine-König wrote:
> > Hello,
> >
> > mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do
> > allocate platform_devices.
> >
> > It contains:
> >
> > ret = platform_device_add_data(pdev,
> > cell->platform_data, cell->data_size);
> >
> > If cell->data_size is 0 (and so likely cell->platform_data == NULL),
> > still pdev->dev.platform_data get assigned ZERO_SIZE_PTR.
> >
> > IMHO the result should better be that pdev->dev.platform_data ends being
> > NULL, too. Agreed?
>
> Why? Is this causing problems somewhere?
The "problem" I as follows: I have a driver that doesn't use
platform_data and I want to change that. As both the driver and the
device probably go via different trees and I want to do the following in
the driver:
if (platform_data != NULL)
/* use it */
else
/* use the old data */
OK, I could simply use:
if (platform_data != NULL && platform_data != ZERO_SIZE_PTR)
...
but it feels ugly.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: platform_device_add_data(pdev, NULL, 0)
2009-10-26 21:19 ` Uwe Kleine-König
@ 2009-10-26 21:21 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2009-10-26 21:21 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: linux-kernel, Russell King, Andrew Morton, Samuel Ortiz,
Mark Brown
On Mon, Oct 26, 2009 at 10:19:03PM +0100, Uwe Kleine-König wrote:
> Hi Greg,
>
> On Mon, Oct 26, 2009 at 09:48:07AM -0700, Greg KH wrote:
> > On Fri, Oct 23, 2009 at 10:26:22PM +0200, Uwe Kleine-König wrote:
> > > Hello,
> > >
> > > mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do
> > > allocate platform_devices.
> > >
> > > It contains:
> > >
> > > ret = platform_device_add_data(pdev,
> > > cell->platform_data, cell->data_size);
> > >
> > > If cell->data_size is 0 (and so likely cell->platform_data == NULL),
> > > still pdev->dev.platform_data get assigned ZERO_SIZE_PTR.
> > >
> > > IMHO the result should better be that pdev->dev.platform_data ends being
> > > NULL, too. Agreed?
> >
> > Why? Is this causing problems somewhere?
> The "problem" I as follows: I have a driver that doesn't use
> platform_data and I want to change that. As both the driver and the
> device probably go via different trees and I want to do the following in
> the driver:
>
> if (platform_data != NULL)
> /* use it */
> else
> /* use the old data */
>
> OK, I could simply use:
>
> if (platform_data != NULL && platform_data != ZERO_SIZE_PTR)
> ...
>
> but it feels ugly.
Yes, that would be ugly. How about just sending the driver and device
through the same trees to prevent this from happening?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-26 21:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-23 20:26 platform_device_add_data(pdev, NULL, 0) Uwe Kleine-König
2009-10-26 16:48 ` Greg KH
2009-10-26 21:19 ` Uwe Kleine-König
2009-10-26 21:21 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox