提交 4c06be10 编写于 作者: B Bjorn Helgaas 提交者: Linus Torvalds

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: NBjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Acked-by: NRalf Baechle <ralf@linux-mips.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 c06a018f
...@@ -918,6 +918,14 @@ static const struct file_operations rtc_proc_fops = { ...@@ -918,6 +918,14 @@ static const struct file_operations rtc_proc_fops = {
}; };
#endif #endif
static void rtc_release_region(void)
{
if (RTC_IOMAPPED)
release_region(RTC_PORT(0), RTC_IO_EXTENT);
else
release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
}
static int __init rtc_init(void) static int __init rtc_init(void)
{ {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
...@@ -992,10 +1000,7 @@ static int __init rtc_init(void) ...@@ -992,10 +1000,7 @@ static int __init rtc_init(void)
/* Yeah right, seeing as irq 8 doesn't even hit the bus. */ /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
rtc_has_irq = 0; rtc_has_irq = 0;
printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
if (RTC_IOMAPPED) rtc_release_region();
release_region(RTC_PORT(0), RTC_IO_EXTENT);
else
release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
return -EIO; return -EIO;
} }
hpet_rtc_timer_init(); hpet_rtc_timer_init();
...@@ -1009,7 +1014,7 @@ static int __init rtc_init(void) ...@@ -1009,7 +1014,7 @@ static int __init rtc_init(void)
free_irq(RTC_IRQ, NULL); free_irq(RTC_IRQ, NULL);
rtc_has_irq = 0; rtc_has_irq = 0;
#endif #endif
release_region(RTC_PORT(0), RTC_IO_EXTENT); rtc_release_region();
return -ENODEV; return -ENODEV;
} }
...@@ -1091,10 +1096,7 @@ static void __exit rtc_exit (void) ...@@ -1091,10 +1096,7 @@ static void __exit rtc_exit (void)
if (rtc_has_irq) if (rtc_has_irq)
free_irq (rtc_irq, &rtc_port); free_irq (rtc_irq, &rtc_port);
#else #else
if (RTC_IOMAPPED) rtc_release_region();
release_region(RTC_PORT(0), RTC_IO_EXTENT);
else
release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
#ifdef RTC_IRQ #ifdef RTC_IRQ
if (rtc_has_irq) if (rtc_has_irq)
free_irq (RTC_IRQ, NULL); free_irq (RTC_IRQ, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册