Commit 844e2d38 authored by Albert Cahalan's avatar Albert Cahalan Committed by Linus Torvalds

[PATCH] reduce diff between x86-64 & i386

This cleans up ioport.c to use BITS_PER_LONG, sizeof, and so on.  This
makes it easier to spot the differences that matter, and thus easier to
find bugs.
parent 10d8f7ec
......@@ -17,32 +17,32 @@
#include <linux/thread_info.h>
/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
static void set_bitmap(unsigned long *bitmap, unsigned long base, unsigned long extent, int new_value)
{
int mask;
unsigned long *bitmap_base = bitmap + (base >> 5);
unsigned short low_index = base & 0x1f;
unsigned long mask;
unsigned long *bitmap_base = bitmap + (base / BITS_PER_LONG);
unsigned long low_index = base & (BITS_PER_LONG-1);
int length = low_index + extent;
if (low_index != 0) {
mask = (~0 << low_index);
if (length < 32)
mask &= ~(~0 << length);
mask = (~0UL << low_index);
if (length < BITS_PER_LONG)
mask &= ~(~0UL << length);
if (new_value)
*bitmap_base++ |= mask;
else
*bitmap_base++ &= ~mask;
length -= 32;
length -= BITS_PER_LONG;
}
mask = (new_value ? ~0 : 0);
while (length >= 32) {
mask = (new_value ? ~0UL : 0UL);
while (length >= BITS_PER_LONG) {
*bitmap_base++ = mask;
length -= 32;
length -= BITS_PER_LONG;
}
if (length > 0) {
mask = ~(~0 << length);
mask = ~(~0UL << length);
if (new_value)
*bitmap_base++ |= mask;
else
......@@ -53,7 +53,7 @@ static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_
/*
* this changes the io permissions bitmap in the current task.
*/
asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
{
struct thread_struct * t = &current->thread;
struct tss_struct * tss;
......@@ -111,7 +111,7 @@ asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
* code.
*/
asmlinkage int sys_iopl(unsigned long unused)
asmlinkage long sys_iopl(unsigned long unused)
{
volatile struct pt_regs * regs = (struct pt_regs *) &unused;
unsigned int level = regs->ebx;
......@@ -124,7 +124,7 @@ asmlinkage int sys_iopl(unsigned long unused)
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
}
regs->eflags = (regs->eflags & 0xffffcfff) | (level << 12);
regs->eflags = (regs->eflags &~ 0x3000UL) | (level << 12);
/* Make sure we return the long way (not sysenter) */
set_thread_flag(TIF_IRET);
return 0;
......
......@@ -21,25 +21,25 @@
static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
{
unsigned long mask;
unsigned long *bitmap_base = bitmap + (base / sizeof(unsigned long));
unsigned short low_index = base & 0x3f;
unsigned long *bitmap_base = bitmap + (base / BITS_PER_LONG);
unsigned long low_index = base & (BITS_PER_LONG-1);
int length = low_index + extent;
if (low_index != 0) {
mask = (~0UL << low_index);
if (length < 64)
if (length < BITS_PER_LONG)
mask &= ~(~0UL << length);
if (new_value)
*bitmap_base++ |= mask;
else
*bitmap_base++ &= ~mask;
length -= 64;
length -= BITS_PER_LONG;
}
mask = (new_value ? ~0UL : 0UL);
while (length >= 64) {
while (length >= BITS_PER_LONG) {
*bitmap_base++ = mask;
length -= 64;
length -= BITS_PER_LONG;
}
if (length > 0) {
......@@ -115,7 +115,7 @@ asmlinkage long sys_iopl(unsigned int level, struct pt_regs regs)
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
}
regs.eflags = (regs.eflags & 0xffffffffffffcfff) | (level << 12);
regs.eflags = (regs.eflags &~ 0x3000UL) | (level << 12);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment