aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rtc.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-11-14 19:59:56 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-14 21:45:41 -0500
commit4c06be10c790008aa2b2d19df2872ff39990b7bd (patch)
tree859d05beb7800749c6019e4beb61ecd893916dbe /drivers/char/rtc.c
parentc06a018fa5362fa9ed0768bd747c0fab26bc8849 (diff)
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>
Diffstat (limited to 'drivers/char/rtc.c')
-rw-r--r--drivers/char/rtc.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index ec6b65ec69ea..a162e1b3d5d3 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -918,6 +918,14 @@ static const struct file_operations rtc_proc_fops = {
918}; 918};
919#endif 919#endif
920 920
921static 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
921static int __init rtc_init(void) 929static int __init rtc_init(void)
922{ 930{
923#ifdef CONFIG_PROC_FS 931#ifdef CONFIG_PROC_FS
@@ -992,10 +1000,7 @@ no_irq:
992 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ 1000 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
993 rtc_has_irq = 0; 1001 rtc_has_irq = 0;
994 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); 1002 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
995 if (RTC_IOMAPPED) 1003 rtc_release_region();
996 release_region(RTC_PORT(0), RTC_IO_EXTENT);
997 else
998 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
999 return -EIO; 1004 return -EIO;
1000 } 1005 }
1001 hpet_rtc_timer_init(); 1006 hpet_rtc_timer_init();
@@ -1009,7 +1014,7 @@ no_irq:
1009 free_irq(RTC_IRQ, NULL); 1014 free_irq(RTC_IRQ, NULL);
1010 rtc_has_irq = 0; 1015 rtc_has_irq = 0;
1011#endif 1016#endif
1012 release_region(RTC_PORT(0), RTC_IO_EXTENT); 1017 rtc_release_region();
1013 return -ENODEV; 1018 return -ENODEV;
1014 } 1019 }
1015 1020
@@ -1091,10 +1096,7 @@ static void __exit rtc_exit (void)
1091 if (rtc_has_irq) 1096 if (rtc_has_irq)
1092 free_irq (rtc_irq, &rtc_port); 1097 free_irq (rtc_irq, &rtc_port);
1093#else 1098#else
1094 if (RTC_IOMAPPED) 1099 rtc_release_region();
1095 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1096 else
1097 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
1098#ifdef RTC_IRQ 1100#ifdef RTC_IRQ
1099 if (rtc_has_irq) 1101 if (rtc_has_irq)
1100 free_irq (RTC_IRQ, NULL); 1102 free_irq (RTC_IRQ, NULL);