aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/vrc4171_card.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/pcmcia/vrc4171_card.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/pcmcia/vrc4171_card.c')
-rw-r--r--drivers/pcmcia/vrc4171_card.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index b2c41241905..659421d0ca4 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -704,24 +704,37 @@ static int __devinit vrc4171_card_setup(char *options)
704 704
705__setup("vrc4171_card=", vrc4171_card_setup); 705__setup("vrc4171_card=", vrc4171_card_setup);
706 706
707static struct device_driver vrc4171_card_driver = { 707static int vrc4171_card_suspend(struct platform_device *dev,
708 .name = vrc4171_card_name, 708 pm_message_t state)
709 .bus = &platform_bus_type, 709{
710 .suspend = pcmcia_socket_dev_suspend, 710 return pcmcia_socket_dev_suspend(&dev->dev, state);
711 .resume = pcmcia_socket_dev_resume, 711}
712
713static int vrc4171_card_resume(struct platform_device *dev)
714{
715 return pcmcia_socket_dev_resume(&dev->dev);
716}
717
718static struct platform_driver vrc4171_card_driver = {
719 .driver = {
720 .name = vrc4171_card_name,
721 .owner = THIS_MODULE,
722 },
723 .suspend = vrc4171_card_suspend,
724 .resume = vrc4171_card_resume,
712}; 725};
713 726
714static int __devinit vrc4171_card_init(void) 727static int __devinit vrc4171_card_init(void)
715{ 728{
716 int retval; 729 int retval;
717 730
718 retval = driver_register(&vrc4171_card_driver); 731 retval = platform_driver_register(&vrc4171_card_driver);
719 if (retval < 0) 732 if (retval < 0)
720 return retval; 733 return retval;
721 734
722 retval = platform_device_register(&vrc4171_card_device); 735 retval = platform_device_register(&vrc4171_card_device);
723 if (retval < 0) { 736 if (retval < 0) {
724 driver_unregister(&vrc4171_card_driver); 737 platform_driver_unregister(&vrc4171_card_driver);
725 return retval; 738 return retval;
726 } 739 }
727 740
@@ -735,11 +748,12 @@ static int __devinit vrc4171_card_init(void)
735 if (retval < 0) { 748 if (retval < 0) {
736 vrc4171_remove_sockets(); 749 vrc4171_remove_sockets();
737 platform_device_unregister(&vrc4171_card_device); 750 platform_device_unregister(&vrc4171_card_device);
738 driver_unregister(&vrc4171_card_driver); 751 platform_driver_unregister(&vrc4171_card_driver);
739 return retval; 752 return retval;
740 } 753 }
741 754
742 printk(KERN_INFO "%s, connected to IRQ %d\n", vrc4171_card_driver.name, vrc4171_irq); 755 printk(KERN_INFO "%s, connected to IRQ %d\n",
756 vrc4171_card_driver.driver.name, vrc4171_irq);
743 757
744 return 0; 758 return 0;
745} 759}
@@ -749,7 +763,7 @@ static void __devexit vrc4171_card_exit(void)
749 free_irq(vrc4171_irq, vrc4171_sockets); 763 free_irq(vrc4171_irq, vrc4171_sockets);
750 vrc4171_remove_sockets(); 764 vrc4171_remove_sockets();
751 platform_device_unregister(&vrc4171_card_device); 765 platform_device_unregister(&vrc4171_card_device);
752 driver_unregister(&vrc4171_card_driver); 766 platform_driver_unregister(&vrc4171_card_driver);
753} 767}
754 768
755module_init(vrc4171_card_init); 769module_init(vrc4171_card_init);