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/a4000t.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/a4000t.c')
-rw-r--r-- | drivers/scsi/a4000t.c | 26 |
1 files changed, 14 insertions, 12 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 | ||
38 | static int __devinit a4000t_probe(struct device *dev) | 38 | static 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 | ||
96 | static __devexit int a4000t_device_remove(struct device *dev) | 96 | static __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 | ||
111 | static struct device_driver a4000t_scsi_driver = { | 111 | static 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 | ||
118 | static int __init a4000t_scsi_init(void) | 120 | static 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) | |||
136 | static void __exit a4000t_scsi_exit(void) | 138 | static 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 | ||
142 | module_init(a4000t_scsi_init); | 144 | module_init(a4000t_scsi_init); |