forked from luck/tmp_suning_uos_patched
MIPS: Remove irqflags.h dependency from bitops.h
The "else clause" of most functions in bitops.h invoked raw_local_irq_{save,restore}() and in doing so had a dependency on irqflags.h. This fix moves said code to bitops.c, removing the dependency. Signed-off-by: Jim Quinlan <jim2101024@gmail.com> Cc: linux-mips@linux-mips.org Cc: David Daney <ddaney.cavm@gmail.com> Cc: Kevin Cernekee cernekee@gmail.com Cc: Jim Quinlan <jim2101024@gmail.com> Patchwork: https://patchwork.linux-mips.org/patch/4320/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
9de79c5006
commit
92d11594f6
@ -30,6 +30,7 @@
|
||||
* measurement, and debugging facilities.
|
||||
*/
|
||||
|
||||
#include <linux/irqflags.h>
|
||||
#include <asm/octeon/cvmx.h>
|
||||
#include <asm/octeon/cvmx-l2c.h>
|
||||
#include <asm/octeon/cvmx-spinlock.h>
|
||||
|
@ -14,7 +14,6 @@
|
||||
#endif
|
||||
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/irqflags.h>
|
||||
#include <linux/types.h>
|
||||
#include <asm/barrier.h>
|
||||
#include <asm/byteorder.h> /* sigh ... */
|
||||
@ -44,6 +43,24 @@
|
||||
#define smp_mb__before_clear_bit() smp_mb__before_llsc()
|
||||
#define smp_mb__after_clear_bit() smp_llsc_mb()
|
||||
|
||||
|
||||
/*
|
||||
* These are the "slower" versions of the functions and are in bitops.c.
|
||||
* These functions call raw_local_irq_{save,restore}().
|
||||
*/
|
||||
void __mips_set_bit(unsigned long nr, volatile unsigned long *addr);
|
||||
void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr);
|
||||
void __mips_change_bit(unsigned long nr, volatile unsigned long *addr);
|
||||
int __mips_test_and_set_bit(unsigned long nr,
|
||||
volatile unsigned long *addr);
|
||||
int __mips_test_and_set_bit_lock(unsigned long nr,
|
||||
volatile unsigned long *addr);
|
||||
int __mips_test_and_clear_bit(unsigned long nr,
|
||||
volatile unsigned long *addr);
|
||||
int __mips_test_and_change_bit(unsigned long nr,
|
||||
volatile unsigned long *addr);
|
||||
|
||||
|
||||
/*
|
||||
* set_bit - Atomically set a bit in memory
|
||||
* @nr: the bit to set
|
||||
@ -92,17 +109,8 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
: "=&r" (temp), "+m" (*m)
|
||||
: "ir" (1UL << bit));
|
||||
} while (unlikely(!temp));
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
__mips_set_bit(nr, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -153,17 +161,8 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
: "=&r" (temp), "+m" (*m)
|
||||
: "ir" (~(1UL << bit)));
|
||||
} while (unlikely(!temp));
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a &= ~mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
__mips_clear_bit(nr, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -220,17 +219,8 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
: "=&r" (temp), "+m" (*m)
|
||||
: "ir" (1UL << bit));
|
||||
} while (unlikely(!temp));
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a ^= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
__mips_change_bit(nr, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -281,18 +271,8 @@ static inline int test_and_set_bit(unsigned long nr,
|
||||
} while (unlikely(!res));
|
||||
|
||||
res = temp & (1UL << bit);
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
res = __mips_test_and_set_bit(nr, addr);
|
||||
|
||||
smp_llsc_mb();
|
||||
|
||||
@ -345,18 +325,8 @@ static inline int test_and_set_bit_lock(unsigned long nr,
|
||||
} while (unlikely(!res));
|
||||
|
||||
res = temp & (1UL << bit);
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
res = __mips_test_and_set_bit_lock(nr, addr);
|
||||
|
||||
smp_llsc_mb();
|
||||
|
||||
@ -428,18 +398,8 @@ static inline int test_and_clear_bit(unsigned long nr,
|
||||
} while (unlikely(!res));
|
||||
|
||||
res = temp & (1UL << bit);
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a &= ~mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
res = __mips_test_and_clear_bit(nr, addr);
|
||||
|
||||
smp_llsc_mb();
|
||||
|
||||
@ -494,18 +454,8 @@ static inline int test_and_change_bit(unsigned long nr,
|
||||
} while (unlikely(!res));
|
||||
|
||||
res = temp & (1UL << bit);
|
||||
} else {
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a ^= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
} else
|
||||
res = __mips_test_and_change_bit(nr, addr);
|
||||
|
||||
smp_llsc_mb();
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/irqflags.h>
|
||||
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/bug.h>
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Makefile for MIPS-specific library files..
|
||||
#
|
||||
|
||||
lib-y += csum_partial.o delay.o memcpy.o memset.o \
|
||||
lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
|
||||
strlen_user.o strncpy_user.o strnlen_user.o uncached.o
|
||||
|
||||
obj-y += iomap.o
|
||||
|
179
arch/mips/lib/bitops.c
Normal file
179
arch/mips/lib/bitops.c
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (c) 1994-1997, 99, 2000, 06, 07 Ralf Baechle (ralf@linux-mips.org)
|
||||
* Copyright (c) 1999, 2000 Silicon Graphics, Inc.
|
||||
*/
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/irqflags.h>
|
||||
#include <linux/export.h>
|
||||
|
||||
|
||||
/**
|
||||
* __mips_set_bit - Atomically set a bit in memory. This is called by
|
||||
* set_bit() if it cannot find a faster solution.
|
||||
* @nr: the bit to set
|
||||
* @addr: the address to start counting from
|
||||
*/
|
||||
void __mips_set_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_set_bit);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_clear_bit - Clears a bit in memory. This is called by clear_bit() if
|
||||
* it cannot find a faster solution.
|
||||
* @nr: Bit to clear
|
||||
* @addr: Address to start counting from
|
||||
*/
|
||||
void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a &= ~mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_clear_bit);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_change_bit - Toggle a bit in memory. This is called by change_bit()
|
||||
* if it cannot find a faster solution.
|
||||
* @nr: Bit to change
|
||||
* @addr: Address to start counting from
|
||||
*/
|
||||
void __mips_change_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
*a ^= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_change_bit);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_test_and_set_bit - Set a bit and return its old value. This is
|
||||
* called by test_and_set_bit() if it cannot find a faster solution.
|
||||
* @nr: Bit to set
|
||||
* @addr: Address to count from
|
||||
*/
|
||||
int __mips_test_and_set_bit(unsigned long nr,
|
||||
volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
unsigned long res;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_test_and_set_bit);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_test_and_set_bit_lock - Set a bit and return its old value. This is
|
||||
* called by test_and_set_bit_lock() if it cannot find a faster solution.
|
||||
* @nr: Bit to set
|
||||
* @addr: Address to count from
|
||||
*/
|
||||
int __mips_test_and_set_bit_lock(unsigned long nr,
|
||||
volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
unsigned long res;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a |= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_test_and_set_bit_lock);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_test_and_clear_bit - Clear a bit and return its old value. This is
|
||||
* called by test_and_clear_bit() if it cannot find a faster solution.
|
||||
* @nr: Bit to clear
|
||||
* @addr: Address to count from
|
||||
*/
|
||||
int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
unsigned long res;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a &= ~mask;
|
||||
raw_local_irq_restore(flags);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_test_and_clear_bit);
|
||||
|
||||
|
||||
/**
|
||||
* __mips_test_and_change_bit - Change a bit and return its old value. This is
|
||||
* called by test_and_change_bit() if it cannot find a faster solution.
|
||||
* @nr: Bit to change
|
||||
* @addr: Address to count from
|
||||
*/
|
||||
int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
|
||||
{
|
||||
volatile unsigned long *a = addr;
|
||||
unsigned bit = nr & SZLONG_MASK;
|
||||
unsigned long mask;
|
||||
unsigned long flags;
|
||||
unsigned long res;
|
||||
|
||||
a += nr >> SZLONG_LOG;
|
||||
mask = 1UL << bit;
|
||||
raw_local_irq_save(flags);
|
||||
res = (mask & *a);
|
||||
*a ^= mask;
|
||||
raw_local_irq_restore(flags);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(__mips_test_and_change_bit);
|
Loading…
Reference in New Issue
Block a user