diff options
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 349a1013603f..d2198f64ad4e 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -217,6 +217,7 @@ int platform_device_add_data(struct platform_device *pdev, const void *data, | |||
217 | if (d) { | 217 | if (d) { |
218 | memcpy(d, data, size); | 218 | memcpy(d, data, size); |
219 | pdev->dev.platform_data = d; | 219 | pdev->dev.platform_data = d; |
220 | pdev->platform_data = d; | ||
220 | } | 221 | } |
221 | return d ? 0 : -ENOMEM; | 222 | return d ? 0 : -ENOMEM; |
222 | } | 223 | } |
@@ -246,6 +247,21 @@ int platform_device_add(struct platform_device *pdev) | |||
246 | else | 247 | else |
247 | dev_set_name(&pdev->dev, pdev->name); | 248 | dev_set_name(&pdev->dev, pdev->name); |
248 | 249 | ||
250 | /* We will remove platform_data field from struct device | ||
251 | * if all platform devices pass its platform specific data | ||
252 | * from platform_device. The conversion is going to be a | ||
253 | * long time, so we allow the two cases coexist to make | ||
254 | * this kind of fix more easily*/ | ||
255 | if (pdev->platform_data && pdev->dev.platform_data) { | ||
256 | printk(KERN_ERR | ||
257 | "%s: use which platform_data?\n", | ||
258 | dev_name(&pdev->dev)); | ||
259 | } else if (pdev->platform_data) { | ||
260 | pdev->dev.platform_data = pdev->platform_data; | ||
261 | } else if (pdev->dev.platform_data) { | ||
262 | pdev->platform_data = pdev->dev.platform_data; | ||
263 | } | ||
264 | |||
249 | for (i = 0; i < pdev->num_resources; i++) { | 265 | for (i = 0; i < pdev->num_resources; i++) { |
250 | struct resource *p, *r = &pdev->resource[i]; | 266 | struct resource *p, *r = &pdev->resource[i]; |
251 | 267 | ||
@@ -584,10 +600,25 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
584 | { | 600 | { |
585 | struct platform_device *pdev = to_platform_device(dev); | 601 | struct platform_device *pdev = to_platform_device(dev); |
586 | 602 | ||
587 | add_uevent_var(env, "MODALIAS=platform:%s", pdev->name); | 603 | add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, |
604 | (pdev->id_entry) ? pdev->id_entry->name : pdev->name); | ||
588 | return 0; | 605 | return 0; |
589 | } | 606 | } |
590 | 607 | ||
608 | static const struct platform_device_id *platform_match_id( | ||
609 | struct platform_device_id *id, | ||
610 | struct platform_device *pdev) | ||
611 | { | ||
612 | while (id->name[0]) { | ||
613 | if (strcmp(pdev->name, id->name) == 0) { | ||
614 | pdev->id_entry = id; | ||
615 | return id; | ||
616 | } | ||
617 | id++; | ||
618 | } | ||
619 | return NULL; | ||
620 | } | ||
621 | |||
591 | /** | 622 | /** |
592 | * platform_match - bind platform device to platform driver. | 623 | * platform_match - bind platform device to platform driver. |
593 | * @dev: device. | 624 | * @dev: device. |
@@ -603,9 +634,14 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
603 | */ | 634 | */ |
604 | static int platform_match(struct device *dev, struct device_driver *drv) | 635 | static int platform_match(struct device *dev, struct device_driver *drv) |
605 | { | 636 | { |
606 | struct platform_device *pdev; | 637 | struct platform_device *pdev = to_platform_device(dev); |
638 | struct platform_driver *pdrv = to_platform_driver(drv); | ||
607 | 639 | ||
608 | pdev = container_of(dev, struct platform_device, dev); | 640 | /* match against the id table first */ |
641 | if (pdrv->id_table) | ||
642 | return platform_match_id(pdrv->id_table, pdev) != NULL; | ||
643 | |||
644 | /* fall-back to driver name match */ | ||
609 | return (strcmp(pdev->name, drv->name) == 0); | 645 | return (strcmp(pdev->name, drv->name) == 0); |
610 | } | 646 | } |
611 | 647 | ||
@@ -623,26 +659,24 @@ static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) | |||
623 | 659 | ||
624 | static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) | 660 | static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) |
625 | { | 661 | { |
626 | struct platform_driver *drv = to_platform_driver(dev->driver); | 662 | struct platform_driver *pdrv = to_platform_driver(dev->driver); |
627 | struct platform_device *pdev; | 663 | struct platform_device *pdev = to_platform_device(dev); |
628 | int ret = 0; | 664 | int ret = 0; |
629 | 665 | ||
630 | pdev = container_of(dev, struct platform_device, dev); | 666 | if (dev->driver && pdrv->suspend_late) |
631 | if (dev->driver && drv->suspend_late) | 667 | ret = pdrv->suspend_late(pdev, mesg); |
632 | ret = drv->suspend_late(pdev, mesg); | ||
633 | 668 | ||
634 | return ret; | 669 | return ret; |
635 | } | 670 | } |
636 | 671 | ||
637 | static int platform_legacy_resume_early(struct device *dev) | 672 | static int platform_legacy_resume_early(struct device *dev) |
638 | { | 673 | { |
639 | struct platform_driver *drv = to_platform_driver(dev->driver); | 674 | struct platform_driver *pdrv = to_platform_driver(dev->driver); |
640 | struct platform_device *pdev; | 675 | struct platform_device *pdev = to_platform_device(dev); |
641 | int ret = 0; | 676 | int ret = 0; |
642 | 677 | ||
643 | pdev = container_of(dev, struct platform_device, dev); | 678 | if (dev->driver && pdrv->resume_early) |
644 | if (dev->driver && drv->resume_early) | 679 | ret = pdrv->resume_early(pdev); |
645 | ret = drv->resume_early(pdev); | ||
646 | 680 | ||
647 | return ret; | 681 | return ret; |
648 | } | 682 | } |