[PATCH 05/13] request_region fixes for ppc prep_request_io

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



request_region fixes for ppc prep_request_io.


Signed-off-by: Jesper Juhl <[email protected]>
---

 arch/ppc/platforms/prep_setup.c |   51 ++++++++++++++++++++++++++++++++++------
 1 files changed, 44 insertions(+), 7 deletions(-)

--- linux-2.6.16-rc4-mm2-orig/arch/ppc/platforms/prep_setup.c	2006-02-24 19:25:30.000000000 +0100
+++ linux-2.6.16-rc4-mm2/arch/ppc/platforms/prep_setup.c	2006-02-24 21:22:33.000000000 +0100
@@ -1064,20 +1064,57 @@ prep_map_io(void)
 	io_block_mapping(0xf0000000, PREP_ISA_MEM_BASE, 0x08000000, _PAGE_IO);
 }
 
+static inline int
+prep_request_region(unsigned long start, unsigned long n, const char *name)
+{
+	struct resource *region;
+	
+	region = request_region(start, n, name);
+	if (!region) {
+		printk(KERN_WARNING "prep_request_io: could not allocate "
+				    "%s region\n", name);
+		return 0;
+	}
+	return 1;
+}
+
 static int __init
 prep_request_io(void)
 {
-	if (_machine == _MACH_prep) {
+	int tmp;
+
+	if (_machine != _MACH_prep)
+		return 0;
+
 #ifdef CONFIG_NVRAM
-		request_region(PREP_NVRAM_AS0, 0x8, "nvram");
+	tmp = prep_request_region(PREP_NVRAM_AS0, 0x8, "nvram");
+	if (!tmp)
+		goto out_nvram;
 #endif
-		request_region(0x00,0x20,"dma1");
-		request_region(0x40,0x20,"timer");
-		request_region(0x80,0x10,"dma page reg");
-		request_region(0xc0,0x20,"dma2");
-	}
+	tmp = prep_request_region(0x00,0x20,"dma1");
+	if (!tmp)
+		goto out_dma1;
+	tmp = prep_request_region(0x40,0x20,"timer");
+	if (!tmp)
+		goto out_timer;
+	tmp = prep_request_region(0x80,0x10,"dma page reg");
+	if (!tmp)
+		goto out_dma_page;
+	tmp = prep_request_region(0xc0,0x20,"dma2");
+	if (!tmp)
+		goto out_dma2;
 
 	return 0;
+ out_dma2:
+ 	release_region(0x80,0x10);
+ out_dma_page:
+ 	release_region(0x40,0x20);
+ out_timer:
+ 	release_region(0x00,0x20);
+ out_dma1:
+ 	release_region(PREP_NVRAM_AS0, 0x8);
+ out_nvram:
+	return -EBUSY;
 }
 
 device_initcall(prep_request_io);



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux