aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
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
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')
-rw-r--r--drivers/scsi/a4000t.c26
-rw-r--r--drivers/scsi/bvme6000_scsi.c26
-rw-r--r--drivers/scsi/mvme16x_scsi.c26
3 files changed, 42 insertions, 36 deletions
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c
index d4bda2017746..6d25aca7b412 100644
--- a/drivers/scsi/a4000t.c
+++ b/drivers/scsi/a4000t.c
@@ -35,7 +35,7 @@ static struct platform_device *a4000t_scsi_device;
35 35
36#define A4000T_SCSI_ADDR 0xdd0040 36#define A4000T_SCSI_ADDR 0xdd0040
37 37
38static int __devinit a4000t_probe(struct device *dev) 38static int __devinit a4000t_probe(struct platform_device *dev)
39{ 39{
40 struct Scsi_Host *host; 40 struct Scsi_Host *host;
41 struct NCR_700_Host_Parameters *hostdata; 41 struct NCR_700_Host_Parameters *hostdata;
@@ -78,7 +78,7 @@ static int __devinit a4000t_probe(struct device *dev)
78 goto out_put_host; 78 goto out_put_host;
79 } 79 }
80 80
81 dev_set_drvdata(dev, host); 81 platform_set_drvdata(dev, host);
82 scsi_scan_host(host); 82 scsi_scan_host(host);
83 83
84 return 0; 84 return 0;
@@ -93,9 +93,9 @@ static int __devinit a4000t_probe(struct device *dev)
93 return -ENODEV; 93 return -ENODEV;
94} 94}
95 95
96static __devexit int a4000t_device_remove(struct device *dev) 96static __devexit int a4000t_device_remove(struct platform_device *dev)
97{ 97{
98 struct Scsi_Host *host = dev_get_drvdata(dev); 98 struct Scsi_Host *host = platform_get_drvdata(dev);
99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
100 100
101 scsi_remove_host(host); 101 scsi_remove_host(host);
@@ -108,25 +108,27 @@ static __devexit int a4000t_device_remove(struct device *dev)
108 return 0; 108 return 0;
109} 109}
110 110
111static struct device_driver a4000t_scsi_driver = { 111static struct platform_driver a4000t_scsi_driver = {
112 .name = "a4000t-scsi", 112 .driver = {
113 .bus = &platform_bus_type, 113 .name = "a4000t-scsi",
114 .probe = a4000t_probe, 114 .owner = THIS_MODULE,
115 .remove = __devexit_p(a4000t_device_remove), 115 },
116 .probe = a4000t_probe,
117 .remove = __devexit_p(a4000t_device_remove),
116}; 118};
117 119
118static int __init a4000t_scsi_init(void) 120static int __init a4000t_scsi_init(void)
119{ 121{
120 int err; 122 int err;
121 123
122 err = driver_register(&a4000t_scsi_driver); 124 err = platform_driver_register(&a4000t_scsi_driver);
123 if (err) 125 if (err)
124 return err; 126 return err;
125 127
126 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi", 128 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
127 -1, NULL, 0); 129 -1, NULL, 0);
128 if (IS_ERR(a4000t_scsi_device)) { 130 if (IS_ERR(a4000t_scsi_device)) {
129 driver_unregister(&a4000t_scsi_driver); 131 platform_driver_register(&a4000t_scsi_driver);
130 return PTR_ERR(a4000t_scsi_device); 132 return PTR_ERR(a4000t_scsi_device);
131 } 133 }
132 134
@@ -136,7 +138,7 @@ static int __init a4000t_scsi_init(void)
136static void __exit a4000t_scsi_exit(void) 138static void __exit a4000t_scsi_exit(void)
137{ 139{
138 platform_device_unregister(a4000t_scsi_device); 140 platform_device_unregister(a4000t_scsi_device);
139 driver_unregister(&a4000t_scsi_driver); 141 platform_driver_unregister(&a4000t_scsi_driver);
140} 142}
141 143
142module_init(a4000t_scsi_init); 144module_init(a4000t_scsi_init);
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);
diff --git a/drivers/scsi/mvme16x_scsi.c b/drivers/scsi/mvme16x_scsi.c
index b264b499d982..7794fc158b17 100644
--- a/drivers/scsi/mvme16x_scsi.c
+++ b/drivers/scsi/mvme16x_scsi.c
@@ -34,7 +34,7 @@ static struct scsi_host_template mvme16x_scsi_driver_template = {
34static struct platform_device *mvme16x_scsi_device; 34static struct platform_device *mvme16x_scsi_device;
35 35
36static __devinit int 36static __devinit int
37mvme16x_probe(struct device *dev) 37mvme16x_probe(struct platform_device *dev)
38{ 38{
39 struct Scsi_Host * host = NULL; 39 struct Scsi_Host * host = NULL;
40 struct NCR_700_Host_Parameters *hostdata; 40 struct NCR_700_Host_Parameters *hostdata;
@@ -88,7 +88,7 @@ mvme16x_probe(struct device *dev)
88 out_be32(0xfff4202c, v); 88 out_be32(0xfff4202c, v);
89 } 89 }
90 90
91 dev_set_drvdata(dev, host); 91 platform_set_drvdata(dev, host);
92 scsi_scan_host(host); 92 scsi_scan_host(host);
93 93
94 return 0; 94 return 0;
@@ -102,9 +102,9 @@ mvme16x_probe(struct device *dev)
102} 102}
103 103
104static __devexit int 104static __devexit int
105mvme16x_device_remove(struct device *dev) 105mvme16x_device_remove(struct platform_device *dev)
106{ 106{
107 struct Scsi_Host *host = dev_get_drvdata(dev); 107 struct Scsi_Host *host = platform_get_drvdata(dev);
108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
109 109
110 /* Disable scsi chip ints */ 110 /* Disable scsi chip ints */
@@ -123,25 +123,27 @@ mvme16x_device_remove(struct device *dev)
123 return 0; 123 return 0;
124} 124}
125 125
126static struct device_driver mvme16x_scsi_driver = { 126static struct platform_driver mvme16x_scsi_driver = {
127 .name = "mvme16x-scsi", 127 .driver = {
128 .bus = &platform_bus_type, 128 .name = "mvme16x-scsi",
129 .probe = mvme16x_probe, 129 .owner = THIS_MODULE,
130 .remove = __devexit_p(mvme16x_device_remove), 130 },
131 .probe = mvme16x_probe,
132 .remove = __devexit_p(mvme16x_device_remove),
131}; 133};
132 134
133static int __init mvme16x_scsi_init(void) 135static int __init mvme16x_scsi_init(void)
134{ 136{
135 int err; 137 int err;
136 138
137 err = driver_register(&mvme16x_scsi_driver); 139 err = platform_driver_register(&mvme16x_scsi_driver);
138 if (err) 140 if (err)
139 return err; 141 return err;
140 142
141 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi", 143 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi",
142 -1, NULL, 0); 144 -1, NULL, 0);
143 if (IS_ERR(mvme16x_scsi_device)) { 145 if (IS_ERR(mvme16x_scsi_device)) {
144 driver_unregister(&mvme16x_scsi_driver); 146 platform_driver_unregister(&mvme16x_scsi_driver);
145 return PTR_ERR(mvme16x_scsi_device); 147 return PTR_ERR(mvme16x_scsi_device);
146 } 148 }
147 149
@@ -151,7 +153,7 @@ static int __init mvme16x_scsi_init(void)
151static void __exit mvme16x_scsi_exit(void) 153static void __exit mvme16x_scsi_exit(void)
152{ 154{
153 platform_device_unregister(mvme16x_scsi_device); 155 platform_device_unregister(mvme16x_scsi_device);
154 driver_unregister(&mvme16x_scsi_driver); 156 platform_driver_unregister(&mvme16x_scsi_driver);
155} 157}
156 158
157module_init(mvme16x_scsi_init); 159module_init(mvme16x_scsi_init);