[patch 1/2] rtc: release correct region in error path

Previous thread: [patch 2/2] rtc: fallback to requesting only the ports we actually use by Bjorn Helgaas on Tuesday, October 23, 2007 - 4:48 pm. (1 message)

Next thread: [GIT PATCH] final SCSI pieces for the merge window by James Bottomley on Tuesday, October 23, 2007 - 4:58 pm. (15 messages)
To: Alessandro Zummo <a.zummo@...>
Cc: Andrew Morton <akpm@...>, <linux-kernel@...>, <linux-mips@...>
Date: Tuesday, October 23, 2007 - 4:48 pm

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>

Index: w/drivers/char/rtc.c
===================================================================
--- w.orig/drivers/char/rtc.c 2007-10-23 09:59:33.000000000 -0600
+++ w/drivers/char/rtc.c 2007-10-23 14:41:23.000000000 -0600
@@ -918,6 +918,14 @@
};
#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)
{
#ifdef CONFIG_PROC_FS
@@ -992,10 +1000,7 @@
/* Yeah right, seeing as irq 8 doesn't even hit the bus. */
rtc_has_irq = 0;
printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
- if (RTC_IOMAPPED)
- release_region(RTC_PORT(0), RTC_IO_EXTENT);
- else
- release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
+ rtc_release_region();
return -EIO;
}
hpet_rtc_timer_init();
@@ -1009,7 +1014,7 @@
free_irq(RTC_IRQ, NULL);
rtc_has_irq = 0;
#endif
- release_region(RTC_PORT(0), RTC_IO_EXTENT);
+ rtc_release_region();
return -ENODEV;
}

@@ -1091,10 +1096,7 @@
if (rtc_has_irq)
free_irq (rtc_irq, &rtc_port);
#else
- if (RTC_IOMAPPED)
- release_region(RTC_PORT(0), RTC_IO_EXTENT);
- else
- release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
+ rtc_release_region();
#ifdef RTC_IRQ
if (rtc_has_irq)
free_irq (RTC_IRQ, NULL);

--
-

To: Bjorn Helgaas <bjorn.helgaas@...>
Cc: Alessandro Zummo <a.zummo@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, <linux-mips@...>
Date: Wednesday, October 24, 2007 - 11:12 am

Well, MIPS just like other sane architectures has no concept of ioports.
So if there ever is something that's called an ioport on MIPS then it's
really a memory location in a memory address range where other PCish
devices are living, too. So typically those memory addresses are
translated to an actual ioport access by a PCI bridge. There are a few
systems where this concept just apply easily such as DECstations, so
there we simply claim the device such as the RTC in this case is memory
mapped.

Anway:

Acked-by: Ralf Baechle <ralf@linux-mips.org>

Ralf
-

Previous thread: [patch 2/2] rtc: fallback to requesting only the ports we actually use by Bjorn Helgaas on Tuesday, October 23, 2007 - 4:48 pm. (1 message)

Next thread: [GIT PATCH] final SCSI pieces for the merge window by James Bottomley on Tuesday, October 23, 2007 - 4:58 pm. (15 messages)