diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-01-30 07:30:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:23 -0500 |
commit | f2f58178f497ca56501d44d79982621e19c5007f (patch) | |
tree | 82d040b61a2f2fa1ffe150386a6e60350e3dd573 /arch/x86/kernel/ioport_32.c | |
parent | 3ebc51d7c95425c3b4667fa042576fb1c6e2ea16 (diff) |
x86: simplify set_bitmap in ioport_32.c
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>
Diffstat (limited to 'arch/x86/kernel/ioport_32.c')
-rw-r--r-- | arch/x86/kernel/ioport_32.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/arch/x86/kernel/ioport_32.c b/arch/x86/kernel/ioport_32.c index 4ed48dc8df1e..c5a64011764f 100644 --- a/arch/x86/kernel/ioport_32.c +++ b/arch/x86/kernel/ioport_32.c | |||
@@ -16,36 +16,16 @@ | |||
16 | #include <linux/syscalls.h> | 16 | #include <linux/syscalls.h> |
17 | 17 | ||
18 | /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */ | 18 | /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */ |
19 | static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value) | 19 | static void set_bitmap(unsigned long *bitmap, unsigned int base, |
20 | unsigned int extent, int new_value) | ||
20 | { | 21 | { |
21 | unsigned long mask; | 22 | unsigned int i; |
22 | unsigned long *bitmap_base = bitmap + (base / BITS_PER_LONG); | ||
23 | unsigned int low_index = base & (BITS_PER_LONG-1); | ||
24 | int length = low_index + extent; | ||
25 | |||
26 | if (low_index != 0) { | ||
27 | mask = (~0UL << low_index); | ||
28 | if (length < BITS_PER_LONG) | ||
29 | mask &= ~(~0UL << length); | ||
30 | if (new_value) | ||
31 | *bitmap_base++ |= mask; | ||
32 | else | ||
33 | *bitmap_base++ &= ~mask; | ||
34 | length -= BITS_PER_LONG; | ||
35 | } | ||
36 | |||
37 | mask = (new_value ? ~0UL : 0UL); | ||
38 | while (length >= BITS_PER_LONG) { | ||
39 | *bitmap_base++ = mask; | ||
40 | length -= BITS_PER_LONG; | ||
41 | } | ||
42 | 23 | ||
43 | if (length > 0) { | 24 | for (i = base; i < base + extent; i++) { |
44 | mask = ~(~0UL << length); | ||
45 | if (new_value) | 25 | if (new_value) |
46 | *bitmap_base++ |= mask; | 26 | __set_bit(i, bitmap); |
47 | else | 27 | else |
48 | *bitmap_base++ &= ~mask; | 28 | __clear_bit(i, bitmap); |
49 | } | 29 | } |
50 | } | 30 | } |
51 | 31 | ||