aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/rtc.c36
-rw-r--r--include/linux/mc146818rtc.h3
2 files changed, 33 insertions, 6 deletions
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index a162e1b3d5d3..0c66b802736a 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -918,12 +918,29 @@ static const struct file_operations rtc_proc_fops = {
918}; 918};
919#endif 919#endif
920 920
921static resource_size_t rtc_size;
922
923static struct resource * __init rtc_request_region(resource_size_t size)
924{
925 struct resource *r;
926
927 if (RTC_IOMAPPED)
928 r = request_region(RTC_PORT(0), size, "rtc");
929 else
930 r = request_mem_region(RTC_PORT(0), size, "rtc");
931
932 if (r)
933 rtc_size = size;
934
935 return r;
936}
937
921static void rtc_release_region(void) 938static void rtc_release_region(void)
922{ 939{
923 if (RTC_IOMAPPED) 940 if (RTC_IOMAPPED)
924 release_region(RTC_PORT(0), RTC_IO_EXTENT); 941 release_region(RTC_PORT(0), rtc_size);
925 else 942 else
926 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); 943 release_mem_region(RTC_PORT(0), rtc_size);
927} 944}
928 945
929static int __init rtc_init(void) 946static int __init rtc_init(void)
@@ -976,10 +993,17 @@ found:
976 } 993 }
977no_irq: 994no_irq:
978#else 995#else
979 if (RTC_IOMAPPED) 996 r = rtc_request_region(RTC_IO_EXTENT);
980 r = request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); 997
981 else 998 /*
982 r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); 999 * If we've already requested a smaller range (for example, because
1000 * PNPBIOS or ACPI told us how the device is configured), the request
1001 * above might fail because it's too big.
1002 *
1003 * If so, request just the range we actually use.
1004 */
1005 if (!r)
1006 r = rtc_request_region(RTC_IO_EXTENT_USED);
983 if (!r) { 1007 if (!r) {
984#ifdef RTC_IRQ 1008#ifdef RTC_IRQ
985 rtc_has_irq = 0; 1009 rtc_has_irq = 0;
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
index 580b3f4956ee..2f4e957af656 100644
--- a/include/linux/mc146818rtc.h
+++ b/include/linux/mc146818rtc.h
@@ -109,8 +109,11 @@ struct cmos_rtc_board_info {
109#ifndef ARCH_RTC_LOCATION /* Override by <asm/mc146818rtc.h>? */ 109#ifndef ARCH_RTC_LOCATION /* Override by <asm/mc146818rtc.h>? */
110 110
111#define RTC_IO_EXTENT 0x8 111#define RTC_IO_EXTENT 0x8
112#define RTC_IO_EXTENT_USED 0x2
112#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ 113#define RTC_IOMAPPED 1 /* Default to I/O mapping. */
113 114
115#else
116#define RTC_IO_EXTENT_USED RTC_IO_EXTENT
114#endif /* ARCH_RTC_LOCATION */ 117#endif /* ARCH_RTC_LOCATION */
115 118
116#endif /* _MC146818RTC_H */ 119#endif /* _MC146818RTC_H */