[SPARC64]: Simplify read_obp_memory().
authorDavid S. Miller <davem@sunset.davemloft.net>
Thu, 15 Mar 2007 07:06:34 +0000 (00:06 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 08:55:23 +0000 (01:55 -0700)
Kick out empty entries as soon as we spot them, and use memmove()
instead of a silly loop to make the operation more clear.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/mm/init.c

index f146071a4b2a383934f24c5a590c2433d0e3ab09..973c4e122f287b1aeeb0a3d44b82531da981aeac 100644 (file)
@@ -122,24 +122,19 @@ static void __init read_obp_memory(const char *property,
                                size = 0UL;
                        base = new_base;
                }
-               regs[i].phys_addr = base;
-               regs[i].reg_size = size;
-       }
-
-       for (i = 0; i < ents; i++) {
-               if (regs[i].reg_size == 0UL) {
-                       int j;
-
-                       for (j = i; j < ents - 1; j++) {
-                               regs[j].phys_addr =
-                                       regs[j+1].phys_addr;
-                               regs[j].reg_size =
-                                       regs[j+1].reg_size;
-                       }
-
-                       ents--;
+               if (size == 0UL) {
+                       /* If it is empty, simply get rid of it.
+                        * This simplifies the logic of the other
+                        * functions that process these arrays.
+                        */
+                       memmove(&regs[i], &regs[i + 1],
+                               (ents - i - 1) * sizeof(regs[0]));
                        i--;
+                       ents--;
+                       continue;
                }
+               regs[i].phys_addr = base;
+               regs[i].reg_size = size;
        }
 
        *num_ents = ents;