| From cebbert@redhat.com Tue Nov 4 14:29:45 2008 |
| From: Bjorn Helgaas <bjorn.helgaas@hp.com> |
| Date: Sun, 26 Oct 2008 18:56:04 -0400 |
| Subject: rtc-cmos: look for PNP RTC first, then for platform RTC |
| To: stable@kernel.org |
| Cc: David Brownell <dbrownell@users.sourceforge.net>, Bjorn Helgaas <bjorn.helgaas@hp.com> |
| Message-ID: <20081026185604.7c631e52@redhat.com> |
| |
| |
| From: Bjorn Helgaas <bjorn.helgaas@hp.com> |
| |
| commit 72f22b1eb6ca5e4676a632a04d40d46cb61d4562 upstream |
| |
| rtc-cmos: look for PNP RTC first, then for platform RTC |
| |
| We shouldn't rely on "pnp_platform_devices" to tell us whether there |
| is a PNP RTC device. |
| |
| I introduced "pnp_platform_devices", but I think it was a mistake. |
| All it tells us is whether we found any PNPBIOS or PNPACPI devices. |
| Many machines have some PNP devices, but do not describe the RTC |
| via PNP. On those machines, we need to do the platform driver probe |
| to find the RTC. |
| |
| We should just register the PNP driver and see whether it claims anything. |
| If we don't find a PNP RTC, fall back to the platform driver probe. |
| |
| This (in conjunction with the arch/x86/kernel/rtc.c patch to add |
| a platform RTC device when PNP doesn't have one) should resolve |
| these issues: |
| |
| http://bugzilla.kernel.org/show_bug.cgi?id=11580 |
| https://bugzilla.redhat.com/show_bug.cgi?id=451188 |
| |
| Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> |
| Acked-by: Rafael J. Wysocki <rjw@sisk.pl> |
| Acked-by: David Brownell <dbrownell@users.sourceforge.net> |
| Reported-by: Rik Theys <rik.theys@esat.kuleuven.be> |
| Reported-by: shr_msn@yahoo.com.tw |
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
| Cc: Chuck Ebbert <cebbert@redhat.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| |
| --- |
| drivers/rtc/rtc-cmos.c | 33 ++++++++++++++++++--------------- |
| 1 file changed, 18 insertions(+), 15 deletions(-) |
| |
| --- a/drivers/rtc/rtc-cmos.c |
| +++ b/drivers/rtc/rtc-cmos.c |
| @@ -1030,29 +1030,32 @@ static struct platform_driver cmos_platf |
| |
| static int __init cmos_init(void) |
| { |
| + int retval = 0; |
| + |
| +#ifdef CONFIG_PNP |
| + pnp_register_driver(&cmos_pnp_driver); |
| +#endif |
| + |
| + if (!cmos_rtc.dev) |
| + retval = platform_driver_probe(&cmos_platform_driver, |
| + cmos_platform_probe); |
| + |
| + if (retval == 0) |
| + return 0; |
| + |
| #ifdef CONFIG_PNP |
| - if (pnp_platform_devices) |
| - return pnp_register_driver(&cmos_pnp_driver); |
| - else |
| - return platform_driver_probe(&cmos_platform_driver, |
| - cmos_platform_probe); |
| -#else |
| - return platform_driver_probe(&cmos_platform_driver, |
| - cmos_platform_probe); |
| -#endif /* CONFIG_PNP */ |
| + pnp_unregister_driver(&cmos_pnp_driver); |
| +#endif |
| + return retval; |
| } |
| module_init(cmos_init); |
| |
| static void __exit cmos_exit(void) |
| { |
| #ifdef CONFIG_PNP |
| - if (pnp_platform_devices) |
| - pnp_unregister_driver(&cmos_pnp_driver); |
| - else |
| - platform_driver_unregister(&cmos_platform_driver); |
| -#else |
| + pnp_unregister_driver(&cmos_pnp_driver); |
| +#endif |
| platform_driver_unregister(&cmos_platform_driver); |
| -#endif /* CONFIG_PNP */ |
| } |
| module_exit(cmos_exit); |
| |