aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bvme6000_scsi.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/scsi/bvme6000_scsi.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/scsi/bvme6000_scsi.c')
-rw-r--r--drivers/scsi/bvme6000_scsi.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
index d858f3d41274..9e9a82b03f2d 100644
--- a/drivers/scsi/bvme6000_scsi.c
+++ b/drivers/scsi/bvme6000_scsi.c
@@ -34,7 +34,7 @@ static struct scsi_host_template bvme6000_scsi_driver_template = {
34static struct platform_device *bvme6000_scsi_device; 34static struct platform_device *bvme6000_scsi_device;
35 35
36static __devinit int 36static __devinit int
37bvme6000_probe(struct device *dev) 37bvme6000_probe(struct platform_device *dev)
38{ 38{
39 struct Scsi_Host *host; 39 struct Scsi_Host *host;
40 struct NCR_700_Host_Parameters *hostdata; 40 struct NCR_700_Host_Parameters *hostdata;
@@ -73,7 +73,7 @@ bvme6000_probe(struct device *dev)
73 goto out_put_host; 73 goto out_put_host;
74 } 74 }
75 75
76 dev_set_drvdata(dev, host); 76 platform_set_drvdata(dev, host);
77 scsi_scan_host(host); 77 scsi_scan_host(host);
78 78
79 return 0; 79 return 0;
@@ -87,9 +87,9 @@ bvme6000_probe(struct device *dev)
87} 87}
88 88
89static __devexit int 89static __devexit int
90bvme6000_device_remove(struct device *dev) 90bvme6000_device_remove(struct platform_device *dev)
91{ 91{
92 struct Scsi_Host *host = dev_get_drvdata(dev); 92 struct Scsi_Host *host = platform_get_drvdata(dev);
93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
94 94
95 scsi_remove_host(host); 95 scsi_remove_host(host);
@@ -100,25 +100,27 @@ bvme6000_device_remove(struct device *dev)
100 return 0; 100 return 0;
101} 101}
102 102
103static struct device_driver bvme6000_scsi_driver = { 103static struct platform_driver bvme6000_scsi_driver = {
104 .name = "bvme6000-scsi", 104 .driver = {
105 .bus = &platform_bus_type, 105 .name = "bvme6000-scsi",
106 .probe = bvme6000_probe, 106 .owner = THIS_MODULE,
107 .remove = __devexit_p(bvme6000_device_remove), 107 },
108 .probe = bvme6000_probe,
109 .remove = __devexit_p(bvme6000_device_remove),
108}; 110};
109 111
110static int __init bvme6000_scsi_init(void) 112static int __init bvme6000_scsi_init(void)
111{ 113{
112 int err; 114 int err;
113 115
114 err = driver_register(&bvme6000_scsi_driver); 116 err = platform_driver_register(&bvme6000_scsi_driver);
115 if (err) 117 if (err)
116 return err; 118 return err;
117 119
118 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi", 120 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
119 -1, NULL, 0); 121 -1, NULL, 0);
120 if (IS_ERR(bvme6000_scsi_device)) { 122 if (IS_ERR(bvme6000_scsi_device)) {
121 driver_unregister(&bvme6000_scsi_driver); 123 platform_driver_unregister(&bvme6000_scsi_driver);
122 return PTR_ERR(bvme6000_scsi_device); 124 return PTR_ERR(bvme6000_scsi_device);
123 } 125 }
124 126
@@ -128,7 +130,7 @@ static int __init bvme6000_scsi_init(void)
128static void __exit bvme6000_scsi_exit(void) 130static void __exit bvme6000_scsi_exit(void)
129{ 131{
130 platform_device_unregister(bvme6000_scsi_device); 132 platform_device_unregister(bvme6000_scsi_device);
131 driver_unregister(&bvme6000_scsi_driver); 133 platform_driver_unregister(&bvme6000_scsi_driver);
132} 134}
133 135
134module_init(bvme6000_scsi_init); 136module_init(bvme6000_scsi_init);