diff options
author | Ming Lei <tom.leiming@gmail.com> | 2009-02-06 10:40:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:25 -0400 |
commit | 7a192ec334cab9fafe3a8665a65af398b0e24730 (patch) | |
tree | eea572863500f94d446cfded69835e188dba3447 /drivers/scsi/mvme16x_scsi.c | |
parent | 6da2d377bba06c29d0bc41c8dee014164dec82a7 (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/mvme16x_scsi.c')
-rw-r--r-- | drivers/scsi/mvme16x_scsi.c | 26 |
1 files changed, 14 insertions, 12 deletions
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 = { | |||
34 | static struct platform_device *mvme16x_scsi_device; | 34 | static struct platform_device *mvme16x_scsi_device; |
35 | 35 | ||
36 | static __devinit int | 36 | static __devinit int |
37 | mvme16x_probe(struct device *dev) | 37 | mvme16x_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 | ||
104 | static __devexit int | 104 | static __devexit int |
105 | mvme16x_device_remove(struct device *dev) | 105 | mvme16x_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 | ||
126 | static struct device_driver mvme16x_scsi_driver = { | 126 | static 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 | ||
133 | static int __init mvme16x_scsi_init(void) | 135 | static 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) | |||
151 | static void __exit mvme16x_scsi_exit(void) | 153 | static 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 | ||
157 | module_init(mvme16x_scsi_init); | 159 | module_init(mvme16x_scsi_init); |