Skip to contentSkip to conversation

platform_device_add_data(pdev, NULL, 0)

DISCUSSION Uwe Kleine-König 2 participants 4 messages Oct 23, 2009 – Oct 26, 2009

lore
Share & tools
lore
#0 lore raw

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

Signature · 2 lines
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
#1 lore raw
Quoted 7 lines · Uwe Kleine-König

Hello,

mfd_add_device() (defined in drivers/mfd/mfd-core.c) is a wrapper do allocate platform_devices.

It contains:

Quoted 8 lines
	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

#2 lore raw

Hi Greg,

Quoted 11 lines · Greg KH
Quoted 10 lines · Uwe Kleine-König

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);
Quoted 7 lines
Quoted 5 lines

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

Signature · 2 lines
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
#3 lore raw
Quoted 31 lines · Uwe Kleine-König

Hi Greg,

Quoted 11 lines · Greg KH
Quoted 10 lines · Uwe Kleine-König

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);
Quoted 7 lines
Quoted 5 lines

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 */
Quoted 6 lines

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