diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
commit | 3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 (patch) | |
tree | d8825be54cefb6ad6707478d719c8e30605bee7b /arch/arm/common | |
parent | 00d3dcdd96646be6059cc21f2efa94c4edc1eda5 (diff) |
[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually
remove the use of the device_driver function pointer methods for
platform device drivers.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/arm/common')
-rw-r--r-- | arch/arm/common/locomo.c | 38 | ||||
-rw-r--r-- | arch/arm/common/sa1111.c | 42 | ||||
-rw-r--r-- | arch/arm/common/scoop.c | 30 |
3 files changed, 55 insertions, 55 deletions
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index ad55680726ed..557e52c1c869 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c | |||
@@ -550,9 +550,9 @@ struct locomo_save_data { | |||
550 | u16 LCM_SPIMD; | 550 | u16 LCM_SPIMD; |
551 | }; | 551 | }; |
552 | 552 | ||
553 | static int locomo_suspend(struct device *dev, pm_message_t state) | 553 | static int locomo_suspend(struct platform_device *dev, pm_message_t state) |
554 | { | 554 | { |
555 | struct locomo *lchip = dev_get_drvdata(dev); | 555 | struct locomo *lchip = platform_get_drvdata(dev); |
556 | struct locomo_save_data *save; | 556 | struct locomo_save_data *save; |
557 | unsigned long flags; | 557 | unsigned long flags; |
558 | 558 | ||
@@ -560,7 +560,7 @@ static int locomo_suspend(struct device *dev, pm_message_t state) | |||
560 | if (!save) | 560 | if (!save) |
561 | return -ENOMEM; | 561 | return -ENOMEM; |
562 | 562 | ||
563 | dev->power.saved_state = (void *) save; | 563 | dev->dev.power.saved_state = (void *) save; |
564 | 564 | ||
565 | spin_lock_irqsave(&lchip->lock, flags); | 565 | spin_lock_irqsave(&lchip->lock, flags); |
566 | 566 | ||
@@ -594,14 +594,14 @@ static int locomo_suspend(struct device *dev, pm_message_t state) | |||
594 | return 0; | 594 | return 0; |
595 | } | 595 | } |
596 | 596 | ||
597 | static int locomo_resume(struct device *dev) | 597 | static int locomo_resume(struct platform_device *dev) |
598 | { | 598 | { |
599 | struct locomo *lchip = dev_get_drvdata(dev); | 599 | struct locomo *lchip = platform_get_drvdata(dev); |
600 | struct locomo_save_data *save; | 600 | struct locomo_save_data *save; |
601 | unsigned long r; | 601 | unsigned long r; |
602 | unsigned long flags; | 602 | unsigned long flags; |
603 | 603 | ||
604 | save = (struct locomo_save_data *) dev->power.saved_state; | 604 | save = (struct locomo_save_data *) dev->dev.power.saved_state; |
605 | if (!save) | 605 | if (!save) |
606 | return 0; | 606 | return 0; |
607 | 607 | ||
@@ -760,27 +760,26 @@ static void __locomo_remove(struct locomo *lchip) | |||
760 | kfree(lchip); | 760 | kfree(lchip); |
761 | } | 761 | } |
762 | 762 | ||
763 | static int locomo_probe(struct device *dev) | 763 | static int locomo_probe(struct platform_device *dev) |
764 | { | 764 | { |
765 | struct platform_device *pdev = to_platform_device(dev); | ||
766 | struct resource *mem; | 765 | struct resource *mem; |
767 | int irq; | 766 | int irq; |
768 | 767 | ||
769 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 768 | mem = platform_get_resource(dev, IORESOURCE_MEM, 0); |
770 | if (!mem) | 769 | if (!mem) |
771 | return -EINVAL; | 770 | return -EINVAL; |
772 | irq = platform_get_irq(pdev, 0); | 771 | irq = platform_get_irq(dev, 0); |
773 | 772 | ||
774 | return __locomo_probe(dev, mem, irq); | 773 | return __locomo_probe(&dev->dev, mem, irq); |
775 | } | 774 | } |
776 | 775 | ||
777 | static int locomo_remove(struct device *dev) | 776 | static int locomo_remove(struct platform_device *dev) |
778 | { | 777 | { |
779 | struct locomo *lchip = dev_get_drvdata(dev); | 778 | struct locomo *lchip = platform__get_drvdata(dev); |
780 | 779 | ||
781 | if (lchip) { | 780 | if (lchip) { |
782 | __locomo_remove(lchip); | 781 | __locomo_remove(lchip); |
783 | dev_set_drvdata(dev, NULL); | 782 | platform_set_drvdata(dev, NULL); |
784 | } | 783 | } |
785 | 784 | ||
786 | return 0; | 785 | return 0; |
@@ -792,15 +791,16 @@ static int locomo_remove(struct device *dev) | |||
792 | * the per-machine level, and then have this driver pick | 791 | * the per-machine level, and then have this driver pick |
793 | * up the registered devices. | 792 | * up the registered devices. |
794 | */ | 793 | */ |
795 | static struct device_driver locomo_device_driver = { | 794 | static struct platform_driver locomo_device_driver = { |
796 | .name = "locomo", | ||
797 | .bus = &platform_bus_type, | ||
798 | .probe = locomo_probe, | 795 | .probe = locomo_probe, |
799 | .remove = locomo_remove, | 796 | .remove = locomo_remove, |
800 | #ifdef CONFIG_PM | 797 | #ifdef CONFIG_PM |
801 | .suspend = locomo_suspend, | 798 | .suspend = locomo_suspend, |
802 | .resume = locomo_resume, | 799 | .resume = locomo_resume, |
803 | #endif | 800 | #endif |
801 | .driver = { | ||
802 | .name = "locomo", | ||
803 | }, | ||
804 | }; | 804 | }; |
805 | 805 | ||
806 | /* | 806 | /* |
@@ -1126,13 +1126,13 @@ static int __init locomo_init(void) | |||
1126 | { | 1126 | { |
1127 | int ret = bus_register(&locomo_bus_type); | 1127 | int ret = bus_register(&locomo_bus_type); |
1128 | if (ret == 0) | 1128 | if (ret == 0) |
1129 | driver_register(&locomo_device_driver); | 1129 | platform_driver_register(&locomo_device_driver); |
1130 | return ret; | 1130 | return ret; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | static void __exit locomo_exit(void) | 1133 | static void __exit locomo_exit(void) |
1134 | { | 1134 | { |
1135 | driver_unregister(&locomo_device_driver); | 1135 | platform_driver_unregister(&locomo_device_driver); |
1136 | bus_unregister(&locomo_bus_type); | 1136 | bus_unregister(&locomo_bus_type); |
1137 | } | 1137 | } |
1138 | 1138 | ||
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 174aa86ee816..7b07acb03f3b 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c | |||
@@ -801,9 +801,9 @@ struct sa1111_save_data { | |||
801 | 801 | ||
802 | #ifdef CONFIG_PM | 802 | #ifdef CONFIG_PM |
803 | 803 | ||
804 | static int sa1111_suspend(struct device *dev, pm_message_t state) | 804 | static int sa1111_suspend(struct platform_device *dev, pm_message_t state) |
805 | { | 805 | { |
806 | struct sa1111 *sachip = dev_get_drvdata(dev); | 806 | struct sa1111 *sachip = platform_get_drvdata(dev); |
807 | struct sa1111_save_data *save; | 807 | struct sa1111_save_data *save; |
808 | unsigned long flags; | 808 | unsigned long flags; |
809 | unsigned int val; | 809 | unsigned int val; |
@@ -812,7 +812,7 @@ static int sa1111_suspend(struct device *dev, pm_message_t state) | |||
812 | save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); | 812 | save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); |
813 | if (!save) | 813 | if (!save) |
814 | return -ENOMEM; | 814 | return -ENOMEM; |
815 | dev->power.saved_state = save; | 815 | dev->dev.power.saved_state = save; |
816 | 816 | ||
817 | spin_lock_irqsave(&sachip->lock, flags); | 817 | spin_lock_irqsave(&sachip->lock, flags); |
818 | 818 | ||
@@ -859,14 +859,14 @@ static int sa1111_suspend(struct device *dev, pm_message_t state) | |||
859 | * restored by their respective drivers, and must be called | 859 | * restored by their respective drivers, and must be called |
860 | * via LDM after this function. | 860 | * via LDM after this function. |
861 | */ | 861 | */ |
862 | static int sa1111_resume(struct device *dev) | 862 | static int sa1111_resume(struct platform_device *dev) |
863 | { | 863 | { |
864 | struct sa1111 *sachip = dev_get_drvdata(dev); | 864 | struct sa1111 *sachip = platform_get_drvdata(dev); |
865 | struct sa1111_save_data *save; | 865 | struct sa1111_save_data *save; |
866 | unsigned long flags, id; | 866 | unsigned long flags, id; |
867 | void __iomem *base; | 867 | void __iomem *base; |
868 | 868 | ||
869 | save = (struct sa1111_save_data *)dev->power.saved_state; | 869 | save = (struct sa1111_save_data *)dev->dev.power.saved_state; |
870 | if (!save) | 870 | if (!save) |
871 | return 0; | 871 | return 0; |
872 | 872 | ||
@@ -879,7 +879,7 @@ static int sa1111_resume(struct device *dev) | |||
879 | id = sa1111_readl(sachip->base + SA1111_SKID); | 879 | id = sa1111_readl(sachip->base + SA1111_SKID); |
880 | if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { | 880 | if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { |
881 | __sa1111_remove(sachip); | 881 | __sa1111_remove(sachip); |
882 | dev_set_drvdata(dev, NULL); | 882 | platform_set_drvdata(dev, NULL); |
883 | kfree(save); | 883 | kfree(save); |
884 | return 0; | 884 | return 0; |
885 | } | 885 | } |
@@ -911,7 +911,7 @@ static int sa1111_resume(struct device *dev) | |||
911 | 911 | ||
912 | spin_unlock_irqrestore(&sachip->lock, flags); | 912 | spin_unlock_irqrestore(&sachip->lock, flags); |
913 | 913 | ||
914 | dev->power.saved_state = NULL; | 914 | dev->dev.power.saved_state = NULL; |
915 | kfree(save); | 915 | kfree(save); |
916 | 916 | ||
917 | return 0; | 917 | return 0; |
@@ -922,9 +922,8 @@ static int sa1111_resume(struct device *dev) | |||
922 | #define sa1111_resume NULL | 922 | #define sa1111_resume NULL |
923 | #endif | 923 | #endif |
924 | 924 | ||
925 | static int sa1111_probe(struct device *dev) | 925 | static int sa1111_probe(struct platform_device *pdev) |
926 | { | 926 | { |
927 | struct platform_device *pdev = to_platform_device(dev); | ||
928 | struct resource *mem; | 927 | struct resource *mem; |
929 | int irq; | 928 | int irq; |
930 | 929 | ||
@@ -933,20 +932,20 @@ static int sa1111_probe(struct device *dev) | |||
933 | return -EINVAL; | 932 | return -EINVAL; |
934 | irq = platform_get_irq(pdev, 0); | 933 | irq = platform_get_irq(pdev, 0); |
935 | 934 | ||
936 | return __sa1111_probe(dev, mem, irq); | 935 | return __sa1111_probe(&pdev->dev, mem, irq); |
937 | } | 936 | } |
938 | 937 | ||
939 | static int sa1111_remove(struct device *dev) | 938 | static int sa1111_remove(struct platform_device *pdev) |
940 | { | 939 | { |
941 | struct sa1111 *sachip = dev_get_drvdata(dev); | 940 | struct sa1111 *sachip = platform_get_drvdata(pdev); |
942 | 941 | ||
943 | if (sachip) { | 942 | if (sachip) { |
944 | __sa1111_remove(sachip); | 943 | __sa1111_remove(sachip); |
945 | dev_set_drvdata(dev, NULL); | 944 | platform_set_drvdata(pdev, NULL); |
946 | 945 | ||
947 | #ifdef CONFIG_PM | 946 | #ifdef CONFIG_PM |
948 | kfree(dev->power.saved_state); | 947 | kfree(pdev->dev.power.saved_state); |
949 | dev->power.saved_state = NULL; | 948 | pdev->dev.power.saved_state = NULL; |
950 | #endif | 949 | #endif |
951 | } | 950 | } |
952 | 951 | ||
@@ -962,13 +961,14 @@ static int sa1111_remove(struct device *dev) | |||
962 | * We also need to handle the SDRAM configuration for | 961 | * We also need to handle the SDRAM configuration for |
963 | * PXA250/SA1110 machine classes. | 962 | * PXA250/SA1110 machine classes. |
964 | */ | 963 | */ |
965 | static struct device_driver sa1111_device_driver = { | 964 | static struct platform_driver sa1111_device_driver = { |
966 | .name = "sa1111", | ||
967 | .bus = &platform_bus_type, | ||
968 | .probe = sa1111_probe, | 965 | .probe = sa1111_probe, |
969 | .remove = sa1111_remove, | 966 | .remove = sa1111_remove, |
970 | .suspend = sa1111_suspend, | 967 | .suspend = sa1111_suspend, |
971 | .resume = sa1111_resume, | 968 | .resume = sa1111_resume, |
969 | .driver = { | ||
970 | .name = "sa1111", | ||
971 | }, | ||
972 | }; | 972 | }; |
973 | 973 | ||
974 | /* | 974 | /* |
@@ -1256,13 +1256,13 @@ static int __init sa1111_init(void) | |||
1256 | { | 1256 | { |
1257 | int ret = bus_register(&sa1111_bus_type); | 1257 | int ret = bus_register(&sa1111_bus_type); |
1258 | if (ret == 0) | 1258 | if (ret == 0) |
1259 | driver_register(&sa1111_device_driver); | 1259 | platform_driver_register(&sa1111_device_driver); |
1260 | return ret; | 1260 | return ret; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | static void __exit sa1111_exit(void) | 1263 | static void __exit sa1111_exit(void) |
1264 | { | 1264 | { |
1265 | driver_unregister(&sa1111_device_driver); | 1265 | platform_driver_unregister(&sa1111_device_driver); |
1266 | bus_unregister(&sa1111_bus_type); | 1266 | bus_unregister(&sa1111_bus_type); |
1267 | } | 1267 | } |
1268 | 1268 | ||
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index c7fdf390cef9..32924c6714fe 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c | |||
@@ -98,9 +98,9 @@ static void check_scoop_reg(struct scoop_dev *sdev) | |||
98 | } | 98 | } |
99 | 99 | ||
100 | #ifdef CONFIG_PM | 100 | #ifdef CONFIG_PM |
101 | static int scoop_suspend(struct device *dev, pm_message_t state) | 101 | static int scoop_suspend(struct platform_device *dev, pm_message_t state) |
102 | { | 102 | { |
103 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 103 | struct scoop_dev *sdev = platform_get_drvdata(dev); |
104 | 104 | ||
105 | check_scoop_reg(sdev); | 105 | check_scoop_reg(sdev); |
106 | sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR); | 106 | sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR); |
@@ -109,9 +109,9 @@ static int scoop_suspend(struct device *dev, pm_message_t state) | |||
109 | return 0; | 109 | return 0; |
110 | } | 110 | } |
111 | 111 | ||
112 | static int scoop_resume(struct device *dev) | 112 | static int scoop_resume(struct platform_device *dev) |
113 | { | 113 | { |
114 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 114 | struct scoop_dev *sdev = platform_get_drvdata(dev); |
115 | 115 | ||
116 | check_scoop_reg(sdev); | 116 | check_scoop_reg(sdev); |
117 | SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr; | 117 | SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr; |
@@ -123,11 +123,10 @@ static int scoop_resume(struct device *dev) | |||
123 | #define scoop_resume NULL | 123 | #define scoop_resume NULL |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | int __init scoop_probe(struct device *dev) | 126 | int __init scoop_probe(struct platform_device *pdev) |
127 | { | 127 | { |
128 | struct scoop_dev *devptr; | 128 | struct scoop_dev *devptr; |
129 | struct scoop_config *inf; | 129 | struct scoop_config *inf; |
130 | struct platform_device *pdev = to_platform_device(dev); | ||
131 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 130 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
132 | 131 | ||
133 | if (!mem) | 132 | if (!mem) |
@@ -141,7 +140,7 @@ int __init scoop_probe(struct device *dev) | |||
141 | memset(devptr, 0, sizeof(struct scoop_dev)); | 140 | memset(devptr, 0, sizeof(struct scoop_dev)); |
142 | spin_lock_init(&devptr->scoop_lock); | 141 | spin_lock_init(&devptr->scoop_lock); |
143 | 142 | ||
144 | inf = dev->platform_data; | 143 | inf = pdev->dev.platform_data; |
145 | devptr->base = ioremap(mem->start, mem->end - mem->start + 1); | 144 | devptr->base = ioremap(mem->start, mem->end - mem->start + 1); |
146 | 145 | ||
147 | if (!devptr->base) { | 146 | if (!devptr->base) { |
@@ -149,7 +148,7 @@ int __init scoop_probe(struct device *dev) | |||
149 | return -ENOMEM; | 148 | return -ENOMEM; |
150 | } | 149 | } |
151 | 150 | ||
152 | dev_set_drvdata(dev, devptr); | 151 | platform_set_drvdata(pdev, devptr); |
153 | 152 | ||
154 | printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); | 153 | printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); |
155 | 154 | ||
@@ -164,29 +163,30 @@ int __init scoop_probe(struct device *dev) | |||
164 | return 0; | 163 | return 0; |
165 | } | 164 | } |
166 | 165 | ||
167 | static int scoop_remove(struct device *dev) | 166 | static int scoop_remove(struct platform_device *pdev) |
168 | { | 167 | { |
169 | struct scoop_dev *sdev = dev_get_drvdata(dev); | 168 | struct scoop_dev *sdev = platform_get_drvdata(pdev); |
170 | if (sdev) { | 169 | if (sdev) { |
171 | iounmap(sdev->base); | 170 | iounmap(sdev->base); |
172 | kfree(sdev); | 171 | kfree(sdev); |
173 | dev_set_drvdata(dev, NULL); | 172 | platform_set_drvdata(pdev, NULL); |
174 | } | 173 | } |
175 | return 0; | 174 | return 0; |
176 | } | 175 | } |
177 | 176 | ||
178 | static struct device_driver scoop_driver = { | 177 | static struct platform_driver scoop_driver = { |
179 | .name = "sharp-scoop", | ||
180 | .bus = &platform_bus_type, | ||
181 | .probe = scoop_probe, | 178 | .probe = scoop_probe, |
182 | .remove = scoop_remove, | 179 | .remove = scoop_remove, |
183 | .suspend = scoop_suspend, | 180 | .suspend = scoop_suspend, |
184 | .resume = scoop_resume, | 181 | .resume = scoop_resume, |
182 | .driver = { | ||
183 | .name = "sharp-scoop", | ||
184 | }, | ||
185 | }; | 185 | }; |
186 | 186 | ||
187 | int __init scoop_init(void) | 187 | int __init scoop_init(void) |
188 | { | 188 | { |
189 | return driver_register(&scoop_driver); | 189 | return platform_driver_register(&scoop_driver); |
190 | } | 190 | } |
191 | 191 | ||
192 | subsys_initcall(scoop_init); | 192 | subsys_initcall(scoop_init); |