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/pcmcia/i82365.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/pcmcia/i82365.c')
-rw-r--r-- | drivers/pcmcia/i82365.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 71653ab84890..40d4953e4b12 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -1238,6 +1238,16 @@ static int pcic_init(struct pcmcia_socket *s) | |||
1238 | return 0; | 1238 | return 0; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | static int i82365_drv_pcmcia_suspend(struct platform_device *dev, | ||
1242 | pm_message_t state) | ||
1243 | { | ||
1244 | return pcmcia_socket_dev_suspend(&dev->dev, state); | ||
1245 | } | ||
1246 | |||
1247 | static int i82365_drv_pcmcia_resume(struct platform_device *dev) | ||
1248 | { | ||
1249 | return pcmcia_socket_dev_resume(&dev->dev); | ||
1250 | } | ||
1241 | static struct pccard_operations pcic_operations = { | 1251 | static struct pccard_operations pcic_operations = { |
1242 | .init = pcic_init, | 1252 | .init = pcic_init, |
1243 | .get_status = pcic_get_status, | 1253 | .get_status = pcic_get_status, |
@@ -1248,11 +1258,13 @@ static struct pccard_operations pcic_operations = { | |||
1248 | 1258 | ||
1249 | /*====================================================================*/ | 1259 | /*====================================================================*/ |
1250 | 1260 | ||
1251 | static struct device_driver i82365_driver = { | 1261 | static struct platform_driver i82365_driver = { |
1252 | .name = "i82365", | 1262 | .driver = { |
1253 | .bus = &platform_bus_type, | 1263 | .name = "i82365", |
1254 | .suspend = pcmcia_socket_dev_suspend, | 1264 | .owner = THIS_MODULE, |
1255 | .resume = pcmcia_socket_dev_resume, | 1265 | }, |
1266 | .suspend = i82365_drv_pcmcia_suspend, | ||
1267 | .resume = i82365_drv_pcmcia_resume, | ||
1256 | }; | 1268 | }; |
1257 | 1269 | ||
1258 | static struct platform_device *i82365_device; | 1270 | static struct platform_device *i82365_device; |
@@ -1261,7 +1273,7 @@ static int __init init_i82365(void) | |||
1261 | { | 1273 | { |
1262 | int i, ret; | 1274 | int i, ret; |
1263 | 1275 | ||
1264 | ret = driver_register(&i82365_driver); | 1276 | ret = platform_driver_register(&i82365_driver); |
1265 | if (ret) | 1277 | if (ret) |
1266 | goto err_out; | 1278 | goto err_out; |
1267 | 1279 | ||
@@ -1337,7 +1349,7 @@ err_dev_unregister: | |||
1337 | pnp_disable_dev(i82365_pnpdev); | 1349 | pnp_disable_dev(i82365_pnpdev); |
1338 | #endif | 1350 | #endif |
1339 | err_driver_unregister: | 1351 | err_driver_unregister: |
1340 | driver_unregister(&i82365_driver); | 1352 | platform_driver_unregister(&i82365_driver); |
1341 | err_out: | 1353 | err_out: |
1342 | return ret; | 1354 | return ret; |
1343 | } /* init_i82365 */ | 1355 | } /* init_i82365 */ |
@@ -1365,7 +1377,7 @@ static void __exit exit_i82365(void) | |||
1365 | if (i82365_pnpdev) | 1377 | if (i82365_pnpdev) |
1366 | pnp_disable_dev(i82365_pnpdev); | 1378 | pnp_disable_dev(i82365_pnpdev); |
1367 | #endif | 1379 | #endif |
1368 | driver_unregister(&i82365_driver); | 1380 | platform_driver_unregister(&i82365_driver); |
1369 | } /* exit_i82365 */ | 1381 | } /* exit_i82365 */ |
1370 | 1382 | ||
1371 | module_init(init_i82365); | 1383 | module_init(init_i82365); |