diff options
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 130 |
1 files changed, 67 insertions, 63 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index dfcbfe504867..349a1013603f 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -24,7 +24,7 @@ | |||
24 | driver)) | 24 | driver)) |
25 | 25 | ||
26 | struct device platform_bus = { | 26 | struct device platform_bus = { |
27 | .bus_id = "platform", | 27 | .init_name = "platform", |
28 | }; | 28 | }; |
29 | EXPORT_SYMBOL_GPL(platform_bus); | 29 | EXPORT_SYMBOL_GPL(platform_bus); |
30 | 30 | ||
@@ -242,16 +242,15 @@ int platform_device_add(struct platform_device *pdev) | |||
242 | pdev->dev.bus = &platform_bus_type; | 242 | pdev->dev.bus = &platform_bus_type; |
243 | 243 | ||
244 | if (pdev->id != -1) | 244 | if (pdev->id != -1) |
245 | snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%d", pdev->name, | 245 | dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); |
246 | pdev->id); | ||
247 | else | 246 | else |
248 | strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); | 247 | dev_set_name(&pdev->dev, pdev->name); |
249 | 248 | ||
250 | for (i = 0; i < pdev->num_resources; i++) { | 249 | for (i = 0; i < pdev->num_resources; i++) { |
251 | struct resource *p, *r = &pdev->resource[i]; | 250 | struct resource *p, *r = &pdev->resource[i]; |
252 | 251 | ||
253 | if (r->name == NULL) | 252 | if (r->name == NULL) |
254 | r->name = pdev->dev.bus_id; | 253 | r->name = dev_name(&pdev->dev); |
255 | 254 | ||
256 | p = r->parent; | 255 | p = r->parent; |
257 | if (!p) { | 256 | if (!p) { |
@@ -264,14 +263,14 @@ int platform_device_add(struct platform_device *pdev) | |||
264 | if (p && insert_resource(p, r)) { | 263 | if (p && insert_resource(p, r)) { |
265 | printk(KERN_ERR | 264 | printk(KERN_ERR |
266 | "%s: failed to claim resource %d\n", | 265 | "%s: failed to claim resource %d\n", |
267 | pdev->dev.bus_id, i); | 266 | dev_name(&pdev->dev), i); |
268 | ret = -EBUSY; | 267 | ret = -EBUSY; |
269 | goto failed; | 268 | goto failed; |
270 | } | 269 | } |
271 | } | 270 | } |
272 | 271 | ||
273 | pr_debug("Registering platform device '%s'. Parent at %s\n", | 272 | pr_debug("Registering platform device '%s'. Parent at %s\n", |
274 | pdev->dev.bus_id, pdev->dev.parent->bus_id); | 273 | dev_name(&pdev->dev), dev_name(pdev->dev.parent)); |
275 | 274 | ||
276 | ret = device_add(&pdev->dev); | 275 | ret = device_add(&pdev->dev); |
277 | if (ret == 0) | 276 | if (ret == 0) |
@@ -503,8 +502,6 @@ int platform_driver_register(struct platform_driver *drv) | |||
503 | drv->driver.suspend = platform_drv_suspend; | 502 | drv->driver.suspend = platform_drv_suspend; |
504 | if (drv->resume) | 503 | if (drv->resume) |
505 | drv->driver.resume = platform_drv_resume; | 504 | drv->driver.resume = platform_drv_resume; |
506 | if (drv->pm) | ||
507 | drv->driver.pm = &drv->pm->base; | ||
508 | return driver_register(&drv->driver); | 505 | return driver_register(&drv->driver); |
509 | } | 506 | } |
510 | EXPORT_SYMBOL_GPL(platform_driver_register); | 507 | EXPORT_SYMBOL_GPL(platform_driver_register); |
@@ -609,7 +606,7 @@ static int platform_match(struct device *dev, struct device_driver *drv) | |||
609 | struct platform_device *pdev; | 606 | struct platform_device *pdev; |
610 | 607 | ||
611 | pdev = container_of(dev, struct platform_device, dev); | 608 | pdev = container_of(dev, struct platform_device, dev); |
612 | return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); | 609 | return (strcmp(pdev->name, drv->name) == 0); |
613 | } | 610 | } |
614 | 611 | ||
615 | #ifdef CONFIG_PM_SLEEP | 612 | #ifdef CONFIG_PM_SLEEP |
@@ -686,7 +683,10 @@ static int platform_pm_suspend(struct device *dev) | |||
686 | struct device_driver *drv = dev->driver; | 683 | struct device_driver *drv = dev->driver; |
687 | int ret = 0; | 684 | int ret = 0; |
688 | 685 | ||
689 | if (drv && drv->pm) { | 686 | if (!drv) |
687 | return 0; | ||
688 | |||
689 | if (drv->pm) { | ||
690 | if (drv->pm->suspend) | 690 | if (drv->pm->suspend) |
691 | ret = drv->pm->suspend(dev); | 691 | ret = drv->pm->suspend(dev); |
692 | } else { | 692 | } else { |
@@ -698,16 +698,15 @@ static int platform_pm_suspend(struct device *dev) | |||
698 | 698 | ||
699 | static int platform_pm_suspend_noirq(struct device *dev) | 699 | static int platform_pm_suspend_noirq(struct device *dev) |
700 | { | 700 | { |
701 | struct platform_driver *pdrv; | 701 | struct device_driver *drv = dev->driver; |
702 | int ret = 0; | 702 | int ret = 0; |
703 | 703 | ||
704 | if (!dev->driver) | 704 | if (!drv) |
705 | return 0; | 705 | return 0; |
706 | 706 | ||
707 | pdrv = to_platform_driver(dev->driver); | 707 | if (drv->pm) { |
708 | if (pdrv->pm) { | 708 | if (drv->pm->suspend_noirq) |
709 | if (pdrv->pm->suspend_noirq) | 709 | ret = drv->pm->suspend_noirq(dev); |
710 | ret = pdrv->pm->suspend_noirq(dev); | ||
711 | } else { | 710 | } else { |
712 | ret = platform_legacy_suspend_late(dev, PMSG_SUSPEND); | 711 | ret = platform_legacy_suspend_late(dev, PMSG_SUSPEND); |
713 | } | 712 | } |
@@ -720,7 +719,10 @@ static int platform_pm_resume(struct device *dev) | |||
720 | struct device_driver *drv = dev->driver; | 719 | struct device_driver *drv = dev->driver; |
721 | int ret = 0; | 720 | int ret = 0; |
722 | 721 | ||
723 | if (drv && drv->pm) { | 722 | if (!drv) |
723 | return 0; | ||
724 | |||
725 | if (drv->pm) { | ||
724 | if (drv->pm->resume) | 726 | if (drv->pm->resume) |
725 | ret = drv->pm->resume(dev); | 727 | ret = drv->pm->resume(dev); |
726 | } else { | 728 | } else { |
@@ -732,16 +734,15 @@ static int platform_pm_resume(struct device *dev) | |||
732 | 734 | ||
733 | static int platform_pm_resume_noirq(struct device *dev) | 735 | static int platform_pm_resume_noirq(struct device *dev) |
734 | { | 736 | { |
735 | struct platform_driver *pdrv; | 737 | struct device_driver *drv = dev->driver; |
736 | int ret = 0; | 738 | int ret = 0; |
737 | 739 | ||
738 | if (!dev->driver) | 740 | if (!drv) |
739 | return 0; | 741 | return 0; |
740 | 742 | ||
741 | pdrv = to_platform_driver(dev->driver); | 743 | if (drv->pm) { |
742 | if (pdrv->pm) { | 744 | if (drv->pm->resume_noirq) |
743 | if (pdrv->pm->resume_noirq) | 745 | ret = drv->pm->resume_noirq(dev); |
744 | ret = pdrv->pm->resume_noirq(dev); | ||
745 | } else { | 746 | } else { |
746 | ret = platform_legacy_resume_early(dev); | 747 | ret = platform_legacy_resume_early(dev); |
747 | } | 748 | } |
@@ -780,16 +781,15 @@ static int platform_pm_freeze(struct device *dev) | |||
780 | 781 | ||
781 | static int platform_pm_freeze_noirq(struct device *dev) | 782 | static int platform_pm_freeze_noirq(struct device *dev) |
782 | { | 783 | { |
783 | struct platform_driver *pdrv; | 784 | struct device_driver *drv = dev->driver; |
784 | int ret = 0; | 785 | int ret = 0; |
785 | 786 | ||
786 | if (!dev->driver) | 787 | if (!drv) |
787 | return 0; | 788 | return 0; |
788 | 789 | ||
789 | pdrv = to_platform_driver(dev->driver); | 790 | if (drv->pm) { |
790 | if (pdrv->pm) { | 791 | if (drv->pm->freeze_noirq) |
791 | if (pdrv->pm->freeze_noirq) | 792 | ret = drv->pm->freeze_noirq(dev); |
792 | ret = pdrv->pm->freeze_noirq(dev); | ||
793 | } else { | 793 | } else { |
794 | ret = platform_legacy_suspend_late(dev, PMSG_FREEZE); | 794 | ret = platform_legacy_suspend_late(dev, PMSG_FREEZE); |
795 | } | 795 | } |
@@ -802,7 +802,10 @@ static int platform_pm_thaw(struct device *dev) | |||
802 | struct device_driver *drv = dev->driver; | 802 | struct device_driver *drv = dev->driver; |
803 | int ret = 0; | 803 | int ret = 0; |
804 | 804 | ||
805 | if (drv && drv->pm) { | 805 | if (!drv) |
806 | return 0; | ||
807 | |||
808 | if (drv->pm) { | ||
806 | if (drv->pm->thaw) | 809 | if (drv->pm->thaw) |
807 | ret = drv->pm->thaw(dev); | 810 | ret = drv->pm->thaw(dev); |
808 | } else { | 811 | } else { |
@@ -814,16 +817,15 @@ static int platform_pm_thaw(struct device *dev) | |||
814 | 817 | ||
815 | static int platform_pm_thaw_noirq(struct device *dev) | 818 | static int platform_pm_thaw_noirq(struct device *dev) |
816 | { | 819 | { |
817 | struct platform_driver *pdrv; | 820 | struct device_driver *drv = dev->driver; |
818 | int ret = 0; | 821 | int ret = 0; |
819 | 822 | ||
820 | if (!dev->driver) | 823 | if (!drv) |
821 | return 0; | 824 | return 0; |
822 | 825 | ||
823 | pdrv = to_platform_driver(dev->driver); | 826 | if (drv->pm) { |
824 | if (pdrv->pm) { | 827 | if (drv->pm->thaw_noirq) |
825 | if (pdrv->pm->thaw_noirq) | 828 | ret = drv->pm->thaw_noirq(dev); |
826 | ret = pdrv->pm->thaw_noirq(dev); | ||
827 | } else { | 829 | } else { |
828 | ret = platform_legacy_resume_early(dev); | 830 | ret = platform_legacy_resume_early(dev); |
829 | } | 831 | } |
@@ -836,7 +838,10 @@ static int platform_pm_poweroff(struct device *dev) | |||
836 | struct device_driver *drv = dev->driver; | 838 | struct device_driver *drv = dev->driver; |
837 | int ret = 0; | 839 | int ret = 0; |
838 | 840 | ||
839 | if (drv && drv->pm) { | 841 | if (!drv) |
842 | return 0; | ||
843 | |||
844 | if (drv->pm) { | ||
840 | if (drv->pm->poweroff) | 845 | if (drv->pm->poweroff) |
841 | ret = drv->pm->poweroff(dev); | 846 | ret = drv->pm->poweroff(dev); |
842 | } else { | 847 | } else { |
@@ -848,16 +853,15 @@ static int platform_pm_poweroff(struct device *dev) | |||
848 | 853 | ||
849 | static int platform_pm_poweroff_noirq(struct device *dev) | 854 | static int platform_pm_poweroff_noirq(struct device *dev) |
850 | { | 855 | { |
851 | struct platform_driver *pdrv; | 856 | struct device_driver *drv = dev->driver; |
852 | int ret = 0; | 857 | int ret = 0; |
853 | 858 | ||
854 | if (!dev->driver) | 859 | if (!drv) |
855 | return 0; | 860 | return 0; |
856 | 861 | ||
857 | pdrv = to_platform_driver(dev->driver); | 862 | if (drv->pm) { |
858 | if (pdrv->pm) { | 863 | if (drv->pm->poweroff_noirq) |
859 | if (pdrv->pm->poweroff_noirq) | 864 | ret = drv->pm->poweroff_noirq(dev); |
860 | ret = pdrv->pm->poweroff_noirq(dev); | ||
861 | } else { | 865 | } else { |
862 | ret = platform_legacy_suspend_late(dev, PMSG_HIBERNATE); | 866 | ret = platform_legacy_suspend_late(dev, PMSG_HIBERNATE); |
863 | } | 867 | } |
@@ -870,7 +874,10 @@ static int platform_pm_restore(struct device *dev) | |||
870 | struct device_driver *drv = dev->driver; | 874 | struct device_driver *drv = dev->driver; |
871 | int ret = 0; | 875 | int ret = 0; |
872 | 876 | ||
873 | if (drv && drv->pm) { | 877 | if (!drv) |
878 | return 0; | ||
879 | |||
880 | if (drv->pm) { | ||
874 | if (drv->pm->restore) | 881 | if (drv->pm->restore) |
875 | ret = drv->pm->restore(dev); | 882 | ret = drv->pm->restore(dev); |
876 | } else { | 883 | } else { |
@@ -882,16 +889,15 @@ static int platform_pm_restore(struct device *dev) | |||
882 | 889 | ||
883 | static int platform_pm_restore_noirq(struct device *dev) | 890 | static int platform_pm_restore_noirq(struct device *dev) |
884 | { | 891 | { |
885 | struct platform_driver *pdrv; | 892 | struct device_driver *drv = dev->driver; |
886 | int ret = 0; | 893 | int ret = 0; |
887 | 894 | ||
888 | if (!dev->driver) | 895 | if (!drv) |
889 | return 0; | 896 | return 0; |
890 | 897 | ||
891 | pdrv = to_platform_driver(dev->driver); | 898 | if (drv->pm) { |
892 | if (pdrv->pm) { | 899 | if (drv->pm->restore_noirq) |
893 | if (pdrv->pm->restore_noirq) | 900 | ret = drv->pm->restore_noirq(dev); |
894 | ret = pdrv->pm->restore_noirq(dev); | ||
895 | } else { | 901 | } else { |
896 | ret = platform_legacy_resume_early(dev); | 902 | ret = platform_legacy_resume_early(dev); |
897 | } | 903 | } |
@@ -912,17 +918,15 @@ static int platform_pm_restore_noirq(struct device *dev) | |||
912 | 918 | ||
913 | #endif /* !CONFIG_HIBERNATION */ | 919 | #endif /* !CONFIG_HIBERNATION */ |
914 | 920 | ||
915 | static struct pm_ext_ops platform_pm_ops = { | 921 | static struct dev_pm_ops platform_dev_pm_ops = { |
916 | .base = { | 922 | .prepare = platform_pm_prepare, |
917 | .prepare = platform_pm_prepare, | 923 | .complete = platform_pm_complete, |
918 | .complete = platform_pm_complete, | 924 | .suspend = platform_pm_suspend, |
919 | .suspend = platform_pm_suspend, | 925 | .resume = platform_pm_resume, |
920 | .resume = platform_pm_resume, | 926 | .freeze = platform_pm_freeze, |
921 | .freeze = platform_pm_freeze, | 927 | .thaw = platform_pm_thaw, |
922 | .thaw = platform_pm_thaw, | 928 | .poweroff = platform_pm_poweroff, |
923 | .poweroff = platform_pm_poweroff, | 929 | .restore = platform_pm_restore, |
924 | .restore = platform_pm_restore, | ||
925 | }, | ||
926 | .suspend_noirq = platform_pm_suspend_noirq, | 930 | .suspend_noirq = platform_pm_suspend_noirq, |
927 | .resume_noirq = platform_pm_resume_noirq, | 931 | .resume_noirq = platform_pm_resume_noirq, |
928 | .freeze_noirq = platform_pm_freeze_noirq, | 932 | .freeze_noirq = platform_pm_freeze_noirq, |
@@ -931,7 +935,7 @@ static struct pm_ext_ops platform_pm_ops = { | |||
931 | .restore_noirq = platform_pm_restore_noirq, | 935 | .restore_noirq = platform_pm_restore_noirq, |
932 | }; | 936 | }; |
933 | 937 | ||
934 | #define PLATFORM_PM_OPS_PTR &platform_pm_ops | 938 | #define PLATFORM_PM_OPS_PTR (&platform_dev_pm_ops) |
935 | 939 | ||
936 | #else /* !CONFIG_PM_SLEEP */ | 940 | #else /* !CONFIG_PM_SLEEP */ |
937 | 941 | ||