x86: Use bitmap library functions
authorAkinobu Mita <akinobu.mita@gmail.com>
Wed, 16 Feb 2011 14:48:35 +0000 (23:48 +0900)
committerIngo Molnar <mingo@elte.hu>
Thu, 17 Feb 2011 13:59:22 +0000 (14:59 +0100)
Use bitmap_set()/bitmap_clear() to fill/zero a region of a
bitmap instead of doing set_bit()/clear_bit() each bit.

This change has been tested with ioperm() and there's no
change in behavior.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
LKML-Reference: <1297867715-20394-1-git-send-email-akinobu.mita@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/ioport.c

index 8eec0ec59af2a6545c074b330ca9d9565a7a3a70..8c968974253de19660b91f6da2b80f64e909c537 100644 (file)
 #include <linux/slab.h>
 #include <linux/thread_info.h>
 #include <linux/syscalls.h>
+#include <linux/bitmap.h>
 #include <asm/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)
-{
-       unsigned int i;
-
-       for (i = base; i < base + extent; i++) {
-               if (new_value)
-                       __set_bit(i, bitmap);
-               else
-                       __clear_bit(i, bitmap);
-       }
-}
-
 /*
  * this changes the io permissions bitmap in the current task.
  */
@@ -69,7 +56,10 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
         */
        tss = &per_cpu(init_tss, get_cpu());
 
-       set_bitmap(t->io_bitmap_ptr, from, num, !turn_on);
+       if (turn_on)
+               bitmap_clear(t->io_bitmap_ptr, from, num);
+       else
+               bitmap_set(t->io_bitmap_ptr, from, num);
 
        /*
         * Search for a (possibly new) maximum. This is simple and stupid,
This page took 0.025161 seconds and 5 git commands to generate.