Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: release correct region in error path

The misc_register() error path always released an I/O port region,
even if the region was memory-mapped (only mips uses memory-mapped RTC,
as far as I can see).

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Bjorn Helgaas and committed by
Linus Torvalds
4c06be10 c06a018f

+11 -9
+11 -9
drivers/char/rtc.c
··· 918 918 }; 919 919 #endif 920 920 921 + static void rtc_release_region(void) 922 + { 923 + if (RTC_IOMAPPED) 924 + release_region(RTC_PORT(0), RTC_IO_EXTENT); 925 + else 926 + release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); 927 + } 928 + 921 929 static int __init rtc_init(void) 922 930 { 923 931 #ifdef CONFIG_PROC_FS ··· 1000 992 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ 1001 993 rtc_has_irq = 0; 1002 994 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); 1003 - if (RTC_IOMAPPED) 1004 - release_region(RTC_PORT(0), RTC_IO_EXTENT); 1005 - else 1006 - release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); 995 + rtc_release_region(); 1007 996 return -EIO; 1008 997 } 1009 998 hpet_rtc_timer_init(); ··· 1014 1009 free_irq(RTC_IRQ, NULL); 1015 1010 rtc_has_irq = 0; 1016 1011 #endif 1017 - release_region(RTC_PORT(0), RTC_IO_EXTENT); 1012 + rtc_release_region(); 1018 1013 return -ENODEV; 1019 1014 } 1020 1015 ··· 1096 1091 if (rtc_has_irq) 1097 1092 free_irq (rtc_irq, &rtc_port); 1098 1093 #else 1099 - if (RTC_IOMAPPED) 1100 - release_region(RTC_PORT(0), RTC_IO_EXTENT); 1101 - else 1102 - release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); 1094 + rtc_release_region(); 1103 1095 #ifdef RTC_IRQ 1104 1096 if (rtc_has_irq) 1105 1097 free_irq (RTC_IRQ, NULL);