]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: simplify set_bitmap in ioport_32.c
authorThomas Gleixner <tglx@linutronix.de>
Wed, 30 Jan 2008 12:30:23 +0000 (13:30 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:30:23 +0000 (13:30 +0100)
Simplify set_bitmap(). This is not in a hotpath and we really can use the
straight forward loop through those bits. A similar implementation is used
in the 64 bit code as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/ioport_32.c

index 4ed48dc8df1e76fa925f15e11febe5ebc79481fa..c5a64011764f222c6ec8a2f4d2af7003b72e86d9 100644 (file)
 #include <linux/syscalls.h>
 
 /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
-static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
+static void set_bitmap(unsigned long *bitmap, unsigned int base,
+                      unsigned int extent, int new_value)
 {
-       unsigned long mask;
-       unsigned long *bitmap_base = bitmap + (base / BITS_PER_LONG);
-       unsigned int low_index = base & (BITS_PER_LONG-1);
-       int length = low_index + extent;
-
-       if (low_index != 0) {
-               mask = (~0UL << low_index);
-               if (length < BITS_PER_LONG)
-                       mask &= ~(~0UL << length);
-               if (new_value)
-                       *bitmap_base++ |= mask;
-               else
-                       *bitmap_base++ &= ~mask;
-               length -= BITS_PER_LONG;
-       }
-
-       mask = (new_value ? ~0UL : 0UL);
-       while (length >= BITS_PER_LONG) {
-               *bitmap_base++ = mask;
-               length -= BITS_PER_LONG;
-       }
+       unsigned int i;
 
-       if (length > 0) {
-               mask = ~(~0UL << length);
+       for (i = base; i < base + extent; i++) {
                if (new_value)
-                       *bitmap_base++ |= mask;
+                       __set_bit(i, bitmap);
                else
-                       *bitmap_base++ &= ~mask;
+                       __clear_bit(i, bitmap);
        }
 }