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/m32r_cfc.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/m32r_cfc.c')
-rw-r--r-- | drivers/pcmcia/m32r_cfc.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 2ab4f22c21de..62b4ecc97c46 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c | |||
@@ -696,13 +696,25 @@ static struct pccard_operations pcc_operations = { | |||
696 | .set_mem_map = pcc_set_mem_map, | 696 | .set_mem_map = pcc_set_mem_map, |
697 | }; | 697 | }; |
698 | 698 | ||
699 | static int cfc_drv_pcmcia_suspend(struct platform_device *dev, | ||
700 | pm_message_t state) | ||
701 | { | ||
702 | return pcmcia_socket_dev_suspend(&dev->dev, state); | ||
703 | } | ||
704 | |||
705 | static int cfc_drv_pcmcia_resume(struct platform_device *dev) | ||
706 | { | ||
707 | return pcmcia_socket_dev_resume(&dev->dev); | ||
708 | } | ||
699 | /*====================================================================*/ | 709 | /*====================================================================*/ |
700 | 710 | ||
701 | static struct device_driver pcc_driver = { | 711 | static struct platform_driver pcc_driver = { |
702 | .name = "cfc", | 712 | .driver = { |
703 | .bus = &platform_bus_type, | 713 | .name = "cfc", |
704 | .suspend = pcmcia_socket_dev_suspend, | 714 | .owner = THIS_MODULE, |
705 | .resume = pcmcia_socket_dev_resume, | 715 | }, |
716 | .suspend = cfc_drv_pcmcia_suspend, | ||
717 | .resume = cfc_drv_pcmcia_resume, | ||
706 | }; | 718 | }; |
707 | 719 | ||
708 | static struct platform_device pcc_device = { | 720 | static struct platform_device pcc_device = { |
@@ -716,13 +728,13 @@ static int __init init_m32r_pcc(void) | |||
716 | { | 728 | { |
717 | int i, ret; | 729 | int i, ret; |
718 | 730 | ||
719 | ret = driver_register(&pcc_driver); | 731 | ret = platform_driver_register(&pcc_driver); |
720 | if (ret) | 732 | if (ret) |
721 | return ret; | 733 | return ret; |
722 | 734 | ||
723 | ret = platform_device_register(&pcc_device); | 735 | ret = platform_device_register(&pcc_device); |
724 | if (ret){ | 736 | if (ret){ |
725 | driver_unregister(&pcc_driver); | 737 | platform_driver_unregister(&pcc_driver); |
726 | return ret; | 738 | return ret; |
727 | } | 739 | } |
728 | 740 | ||
@@ -754,7 +766,7 @@ static int __init init_m32r_pcc(void) | |||
754 | if (pcc_sockets == 0) { | 766 | if (pcc_sockets == 0) { |
755 | printk("socket is not found.\n"); | 767 | printk("socket is not found.\n"); |
756 | platform_device_unregister(&pcc_device); | 768 | platform_device_unregister(&pcc_device); |
757 | driver_unregister(&pcc_driver); | 769 | platform_driver_unregister(&pcc_driver); |
758 | return -ENODEV; | 770 | return -ENODEV; |
759 | } | 771 | } |
760 | 772 | ||
@@ -802,7 +814,7 @@ static void __exit exit_m32r_pcc(void) | |||
802 | if (poll_interval != 0) | 814 | if (poll_interval != 0) |
803 | del_timer_sync(&poll_timer); | 815 | del_timer_sync(&poll_timer); |
804 | 816 | ||
805 | driver_unregister(&pcc_driver); | 817 | platform_driver_unregister(&pcc_driver); |
806 | } /* exit_m32r_pcc */ | 818 | } /* exit_m32r_pcc */ |
807 | 819 | ||
808 | module_init(init_m32r_pcc); | 820 | module_init(init_m32r_pcc); |