[LinuxBIOS] r437 - in LinuxBIOSv3: device include/device

svn at openbios.org svn at openbios.org
Sat Jul 7 21:19:44 CEST 2007


Author: uwe
Date: 2007-07-07 21:19:44 +0200 (Sat, 07 Jul 2007)
New Revision: 437

Modified:
   LinuxBIOSv3/device/device.c
   LinuxBIOSv3/device/device_util.c
   LinuxBIOSv3/include/device/device.h
Log:
Drop the round() function, as it is an exact copy of align_up().

Also, make align_up()/align_down() non-static as they are useful
even outside of device/device_util.c.

Signed-off-by: Uwe Hermann <uwe at hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan at coresystems.de>



Modified: LinuxBIOSv3/device/device.c
===================================================================
--- LinuxBIOSv3/device/device.c	2007-07-07 09:34:56 UTC (rev 436)
+++ LinuxBIOSv3/device/device.c	2007-07-07 19:19:44 UTC (rev 437)
@@ -244,22 +244,6 @@
 }
 
 /**
- * Round a number up to an alignment.
- *
- * @param val The starting value.
- * @param roundup Alignment as a power of two.
- * @returns Rounded up number.
- */
-static resource_t round(resource_t val, unsigned long pow)
-{
-	resource_t mask;
-	mask = (1ULL << pow) - 1ULL;
-	val += mask;
-	val &= ~mask;
-	return val;
-}
-
-/**
  * Read the resources on all devices of a given bus.
  *
  * @param bus Bus to read the resources on.
@@ -492,9 +476,9 @@
 				base = 0x3e0;
 			}
 		}
-		if (((round(base, align) + size) - 1) <= resource->limit) {
+		if (((align_up(base, align) + size) - 1) <= resource->limit) {
 			/* Base must be aligned to size. */
-			base = round(base, align);
+			base = align_up(base, align);
 			resource->base = base;
 			resource->flags |= IORESOURCE_ASSIGNED;
 			resource->flags &= ~IORESOURCE_STORED;
@@ -517,7 +501,7 @@
 	 * minimum granularity so we know not to place something else at an
 	 * address positively decoded by the bridge.
 	 */
-	bridge->size = round(base, bridge->gran) - bridge->base;
+	bridge->size = align_up(base, bridge->gran) - bridge->base;
 
 	printk(BIOS_SPEW, "%s compute_allocate_%s: base: %08Lx size: %08Lx align: %d gran: %d done\n", dev_path(bus->dev), (bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags & IORESOURCE_PREFETCH) ? "prefmem" : "mem", base, bridge->size, bridge->align, bridge->gran);
 }

Modified: LinuxBIOSv3/device/device_util.c
===================================================================
--- LinuxBIOSv3/device/device_util.c	2007-07-07 09:34:56 UTC (rev 436)
+++ LinuxBIOSv3/device/device_util.c	2007-07-07 19:19:44 UTC (rev 437)
@@ -496,7 +496,7 @@
  * @param gran Granularity we are aligning the number to.
  * @returns The aligned value.
  */
-static resource_t align_up(resource_t val, unsigned long gran)
+resource_t align_up(resource_t val, unsigned long gran)
 {
 	resource_t mask;
 	mask = (1ULL << gran) - 1ULL;
@@ -512,7 +512,7 @@
  * @param gran Granularity we are aligning the number to.
  * @returns The aligned value.
  */
-static resource_t align_down(resource_t val, unsigned long gran)
+resource_t align_down(resource_t val, unsigned long gran)
 {
 	resource_t mask;
 	mask = (1ULL << gran) - 1ULL;

Modified: LinuxBIOSv3/include/device/device.h
===================================================================
--- LinuxBIOSv3/include/device/device.h	2007-07-07 09:34:56 UTC (rev 436)
+++ LinuxBIOSv3/include/device/device.h	2007-07-07 19:19:44 UTC (rev 437)
@@ -257,6 +257,9 @@
 #define DEVICE_IO_ALIGN 16 
 #define DEVICE_MEM_ALIGN 4096
 
+resource_t align_up(resource_t val, unsigned long gran);
+resource_t align_down(resource_t val, unsigned long gran);
+
 extern struct device_operations default_dev_ops_root;
 
 extern int id_eq(struct device_id *id1, struct device_id *id2);





More information about the coreboot mailing list