provide rtc_cmos platform device

Recently (around 2.6.25) I've noticed that RTC no longer works for me. It
turned out this is because I use pnpacpi=off kernel option to work around
the parport_pc bugs. I always did so, but RTC used to work fine in the
past, and now it have regressed.

The patch fixes the problem by creating the platform device for the RTC
when PNP is disabled. This may also help running the PNP-enabled kernel
on an older PCs.

Signed-off-by: Stas Sergeev <stsp@aknet.ru>
Cc: David Brownell <david-b@pacbell.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Stas Sergeev and committed by Linus Torvalds 1da2e3d6 643b52b9

+50 -15
+34
arch/x86/kernel/rtc.c
··· 4 #include <linux/acpi.h> 5 #include <linux/bcd.h> 6 #include <linux/mc146818rtc.h> 7 8 #include <asm/time.h> 9 #include <asm/vsyscall.h> ··· 199 } 200 EXPORT_SYMBOL(native_read_tsc); 201
··· 4 #include <linux/acpi.h> 5 #include <linux/bcd.h> 6 #include <linux/mc146818rtc.h> 7 + #include <linux/platform_device.h> 8 + #include <linux/pnp.h> 9 10 #include <asm/time.h> 11 #include <asm/vsyscall.h> ··· 197 } 198 EXPORT_SYMBOL(native_read_tsc); 199 200 + 201 + static struct resource rtc_resources[] = { 202 + [0] = { 203 + .start = RTC_PORT(0), 204 + .end = RTC_PORT(1), 205 + .flags = IORESOURCE_IO, 206 + }, 207 + [1] = { 208 + .start = RTC_IRQ, 209 + .end = RTC_IRQ, 210 + .flags = IORESOURCE_IRQ, 211 + } 212 + }; 213 + 214 + static struct platform_device rtc_device = { 215 + .name = "rtc_cmos", 216 + .id = -1, 217 + .resource = rtc_resources, 218 + .num_resources = ARRAY_SIZE(rtc_resources), 219 + }; 220 + 221 + static __init int add_rtc_cmos(void) 222 + { 223 + #ifdef CONFIG_PNP 224 + if (!pnp_platform_devices) 225 + platform_device_register(&rtc_device); 226 + #else 227 + platform_device_register(&rtc_device); 228 + #endif /* CONFIG_PNP */ 229 + return 0; 230 + } 231 + device_initcall(add_rtc_cmos);
+16 -15
drivers/rtc/rtc-cmos.c
··· 905 .resume = cmos_pnp_resume, 906 }; 907 908 - static int __init cmos_init(void) 909 - { 910 - return pnp_register_driver(&cmos_pnp_driver); 911 - } 912 - module_init(cmos_init); 913 - 914 - static void __exit cmos_exit(void) 915 - { 916 - pnp_unregister_driver(&cmos_pnp_driver); 917 - } 918 - module_exit(cmos_exit); 919 - 920 - #else /* no PNP */ 921 922 /*----------------------------------------------------------------*/ 923 ··· 946 947 static int __init cmos_init(void) 948 { 949 return platform_driver_probe(&cmos_platform_driver, 950 cmos_platform_probe); 951 } 952 module_init(cmos_init); 953 954 static void __exit cmos_exit(void) 955 { 956 platform_driver_unregister(&cmos_platform_driver); 957 } 958 module_exit(cmos_exit); 959 960 - 961 - #endif /* !PNP */ 962 963 MODULE_AUTHOR("David Brownell"); 964 MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
··· 905 .resume = cmos_pnp_resume, 906 }; 907 908 + #endif /* CONFIG_PNP */ 909 910 /*----------------------------------------------------------------*/ 911 ··· 958 959 static int __init cmos_init(void) 960 { 961 + #ifdef CONFIG_PNP 962 + if (pnp_platform_devices) 963 + return pnp_register_driver(&cmos_pnp_driver); 964 + else 965 + return platform_driver_probe(&cmos_platform_driver, 966 + cmos_platform_probe); 967 + #else 968 return platform_driver_probe(&cmos_platform_driver, 969 cmos_platform_probe); 970 + #endif /* CONFIG_PNP */ 971 } 972 module_init(cmos_init); 973 974 static void __exit cmos_exit(void) 975 { 976 + #ifdef CONFIG_PNP 977 + if (pnp_platform_devices) 978 + pnp_unregister_driver(&cmos_pnp_driver); 979 + else 980 + platform_driver_unregister(&cmos_platform_driver); 981 + #else 982 platform_driver_unregister(&cmos_platform_driver); 983 + #endif /* CONFIG_PNP */ 984 } 985 module_exit(cmos_exit); 986 987 988 MODULE_AUTHOR("David Brownell"); 989 MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");