aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/sa1100_generic.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2009-02-06 10:40:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:38:25 -0400
commit7a192ec334cab9fafe3a8665a65af398b0e24730 (patch)
treeeea572863500f94d446cfded69835e188dba3447 /drivers/pcmcia/sa1100_generic.c
parent6da2d377bba06c29d0bc41c8dee014164dec82a7 (diff)
platform driver: fix incorrect use of 'platform_bus_type' with 'struct device_driver'
This patch fixes the bug reported in http://bugzilla.kernel.org/show_bug.cgi?id=11681. "Lots of device drivers register a 'struct device_driver' with the '.bus' member set to '&platform_bus_type'. This is wrong, since the platform_bus functions expect the 'struct device_driver' to be wrapped up in a 'struct platform_driver' which provides some additional callbacks (like suspend_late, resume_early). The effect may be that platform_suspend_late() uses bogus data outside the device_driver struct as a pointer pointer to the device driver's suspend_late() function or other hard to reproduce failures."(Lothar Wassmann) Signed-off-by: Ming Lei <tom.leiming@gmail.com> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pcmcia/sa1100_generic.c')
-rw-r--r--drivers/pcmcia/sa1100_generic.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index c5b2a44b4c37..d8da5ac844e9 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -65,7 +65,7 @@ static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
65#endif 65#endif
66}; 66};
67 67
68static int sa11x0_drv_pcmcia_probe(struct device *dev) 68static int sa11x0_drv_pcmcia_probe(struct platform_device *dev)
69{ 69{
70 int i, ret = -ENODEV; 70 int i, ret = -ENODEV;
71 71
@@ -73,7 +73,7 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
73 * Initialise any "on-board" PCMCIA sockets. 73 * Initialise any "on-board" PCMCIA sockets.
74 */ 74 */
75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) { 75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) {
76 ret = sa11x0_pcmcia_hw_init[i](dev); 76 ret = sa11x0_pcmcia_hw_init[i](&dev->dev);
77 if (ret == 0) 77 if (ret == 0)
78 break; 78 break;
79 } 79 }
@@ -81,13 +81,31 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
81 return ret; 81 return ret;
82} 82}
83 83
84static struct device_driver sa11x0_pcmcia_driver = { 84static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
85{
86 return soc_common_drv_pcmcia_remove(&dev->dev);
87}
88
89static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
90 pm_message_t state)
91{
92 return pcmcia_socket_dev_suspend(&dev->dev, state);
93}
94
95static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
96{
97 return pcmcia_socket_dev_resume(&dev->dev);
98}
99
100static struct platform_driver sa11x0_pcmcia_driver = {
101 .driver = {
102 .name = "sa11x0-pcmcia",
103 .owner = THIS_MODULE,
104 },
85 .probe = sa11x0_drv_pcmcia_probe, 105 .probe = sa11x0_drv_pcmcia_probe,
86 .remove = soc_common_drv_pcmcia_remove, 106 .remove = sa11x0_drv_pcmcia_remove,
87 .name = "sa11x0-pcmcia", 107 .suspend = sa11x0_drv_pcmcia_suspend,
88 .bus = &platform_bus_type, 108 .resume = sa11x0_drv_pcmcia_resume,
89 .suspend = pcmcia_socket_dev_suspend,
90 .resume = pcmcia_socket_dev_resume,
91}; 109};
92 110
93/* sa11x0_pcmcia_init() 111/* sa11x0_pcmcia_init()
@@ -100,7 +118,7 @@ static struct device_driver sa11x0_pcmcia_driver = {
100 */ 118 */
101static int __init sa11x0_pcmcia_init(void) 119static int __init sa11x0_pcmcia_init(void)
102{ 120{
103 return driver_register(&sa11x0_pcmcia_driver); 121 return platform_driver_register(&sa11x0_pcmcia_driver);
104} 122}
105 123
106/* sa11x0_pcmcia_exit() 124/* sa11x0_pcmcia_exit()
@@ -110,7 +128,7 @@ static int __init sa11x0_pcmcia_init(void)
110 */ 128 */
111static void __exit sa11x0_pcmcia_exit(void) 129static void __exit sa11x0_pcmcia_exit(void)
112{ 130{
113 driver_unregister(&sa11x0_pcmcia_driver); 131 platform_driver_unregister(&sa11x0_pcmcia_driver);
114} 132}
115 133
116MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); 134MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");