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/char/tpm | |
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/char/tpm')
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 28 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis.c | 28 |
2 files changed, 38 insertions, 18 deletions
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index d0e7926eb486..c64a1bc65349 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -168,12 +168,22 @@ static void atml_plat_remove(void) | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | static struct device_driver atml_drv = { | 171 | static int tpm_atml_suspend(struct platform_device *dev, pm_message_t msg) |
172 | .name = "tpm_atmel", | 172 | { |
173 | .bus = &platform_bus_type, | 173 | return tpm_pm_suspend(&dev->dev, msg); |
174 | .owner = THIS_MODULE, | 174 | } |
175 | .suspend = tpm_pm_suspend, | 175 | |
176 | .resume = tpm_pm_resume, | 176 | static int tpm_atml_resume(struct platform_device *dev) |
177 | { | ||
178 | return tpm_pm_resume(&dev->dev); | ||
179 | } | ||
180 | static struct platform_driver atml_drv = { | ||
181 | .driver = { | ||
182 | .name = "tpm_atmel", | ||
183 | .owner = THIS_MODULE, | ||
184 | }, | ||
185 | .suspend = tpm_atml_suspend, | ||
186 | .resume = tpm_atml_resume, | ||
177 | }; | 187 | }; |
178 | 188 | ||
179 | static int __init init_atmel(void) | 189 | static int __init init_atmel(void) |
@@ -184,7 +194,7 @@ static int __init init_atmel(void) | |||
184 | unsigned long base; | 194 | unsigned long base; |
185 | struct tpm_chip *chip; | 195 | struct tpm_chip *chip; |
186 | 196 | ||
187 | rc = driver_register(&atml_drv); | 197 | rc = platform_driver_register(&atml_drv); |
188 | if (rc) | 198 | if (rc) |
189 | return rc; | 199 | return rc; |
190 | 200 | ||
@@ -223,13 +233,13 @@ err_rel_reg: | |||
223 | atmel_release_region(base, | 233 | atmel_release_region(base, |
224 | region_size); | 234 | region_size); |
225 | err_unreg_drv: | 235 | err_unreg_drv: |
226 | driver_unregister(&atml_drv); | 236 | platform_driver_unregister(&atml_drv); |
227 | return rc; | 237 | return rc; |
228 | } | 238 | } |
229 | 239 | ||
230 | static void __exit cleanup_atmel(void) | 240 | static void __exit cleanup_atmel(void) |
231 | { | 241 | { |
232 | driver_unregister(&atml_drv); | 242 | platform_driver_unregister(&atml_drv); |
233 | atml_plat_remove(); | 243 | atml_plat_remove(); |
234 | } | 244 | } |
235 | 245 | ||
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 717af7ad1bdf..aec1931608aa 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c | |||
@@ -654,12 +654,22 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id, | |||
654 | sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); | 654 | sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); |
655 | MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); | 655 | MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); |
656 | 656 | ||
657 | static struct device_driver tis_drv = { | 657 | static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg) |
658 | .name = "tpm_tis", | 658 | { |
659 | .bus = &platform_bus_type, | 659 | return tpm_pm_suspend(&dev->dev, msg); |
660 | .owner = THIS_MODULE, | 660 | } |
661 | .suspend = tpm_pm_suspend, | 661 | |
662 | .resume = tpm_pm_resume, | 662 | static int tpm_tis_resume(struct platform_device *dev) |
663 | { | ||
664 | return tpm_pm_resume(&dev->dev); | ||
665 | } | ||
666 | static struct platform_driver tis_drv = { | ||
667 | .driver = { | ||
668 | .name = "tpm_tis", | ||
669 | .owner = THIS_MODULE, | ||
670 | }, | ||
671 | .suspend = tpm_tis_suspend, | ||
672 | .resume = tpm_tis_resume, | ||
663 | }; | 673 | }; |
664 | 674 | ||
665 | static struct platform_device *pdev; | 675 | static struct platform_device *pdev; |
@@ -672,14 +682,14 @@ static int __init init_tis(void) | |||
672 | int rc; | 682 | int rc; |
673 | 683 | ||
674 | if (force) { | 684 | if (force) { |
675 | rc = driver_register(&tis_drv); | 685 | rc = platform_driver_register(&tis_drv); |
676 | if (rc < 0) | 686 | if (rc < 0) |
677 | return rc; | 687 | return rc; |
678 | if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0))) | 688 | if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0))) |
679 | return PTR_ERR(pdev); | 689 | return PTR_ERR(pdev); |
680 | if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) { | 690 | if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) { |
681 | platform_device_unregister(pdev); | 691 | platform_device_unregister(pdev); |
682 | driver_unregister(&tis_drv); | 692 | platform_driver_unregister(&tis_drv); |
683 | } | 693 | } |
684 | return rc; | 694 | return rc; |
685 | } | 695 | } |
@@ -711,7 +721,7 @@ static void __exit cleanup_tis(void) | |||
711 | 721 | ||
712 | if (force) { | 722 | if (force) { |
713 | platform_device_unregister(pdev); | 723 | platform_device_unregister(pdev); |
714 | driver_unregister(&tis_drv); | 724 | platform_driver_unregister(&tis_drv); |
715 | } else | 725 | } else |
716 | pnp_unregister_driver(&tis_pnp_driver); | 726 | pnp_unregister_driver(&tis_pnp_driver); |
717 | } | 727 | } |