Skip to content

Commit

Permalink
driver core: fix passing platform_data
Browse files Browse the repository at this point in the history
We will remove platform_data field from struct device until
all platform devices pass its specific data from platfom_device
and all platform drivers use platform specific data passed by
platform_device->platform_data. This kind of conversion will
need a long time, for thousands of files is affected.

To make the conversion easily, we allow platform specific data
passed by struct device or struct platform_device and platform
driver may use it from struct device or struct platform_device.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Ming Lei authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent 006f457 commit ce21c7b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,20 @@ int platform_device_add(struct platform_device *pdev)
else
dev_set_name(&pdev->dev, pdev->name);

pdev->platform_data = pdev->dev.platform_data;
/* We will remove platform_data field from struct device
* if all platform devices pass its platform specific data
* from platform_device. The conversion is going to be a
* long time, so we allow the two cases coexist to make
* this kind of fix more easily*/
if (pdev->platform_data && pdev->dev.platform_data) {
printk(KERN_ERR
"%s: use which platform_data?\n",
dev_name(&pdev->dev));
} else if (pdev->platform_data) {
pdev->dev.platform_data = pdev->platform_data;
} else if (pdev->dev.platform_data) {
pdev->platform_data = pdev->dev.platform_data;
}

for (i = 0; i < pdev->num_resources; i++) {
struct resource *p, *r = &pdev->resource[i];
Expand Down

0 comments on commit ce21c7b

Please sign in to comment.