diff options
| author | Olof Johansson <olof@lixom.net> | 2012-11-30 09:12:33 -0800 | 
|---|---|---|
| committer | Olof Johansson <olof@lixom.net> | 2012-11-30 09:12:33 -0800 | 
| commit | 5c1af2a7011bf719807de360cb64c2f610269a38 (patch) | |
| tree | fc4e6657d30c6eb48367c40e50c6b7428f96aaea /arch/mips/lib/bitops.c | |
| parent | ef7848683f4de4903376638b69e6b4ac729b3ead (diff) | |
| parent | 573e5bbe653d01dc0f27e2d97754db9246b501c8 (diff) | |
| download | olio-linux-3.10-5c1af2a7011bf719807de360cb64c2f610269a38.tar.xz olio-linux-3.10-5c1af2a7011bf719807de360cb64c2f610269a38.zip  | |
Merge branch 'next/pm-samsung' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into next/pm
From Kukjin Kim:
* 'next/pm-samsung' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung:
  ARM: EXYNOS: Add flush_cache_all in suspend finisher
  ARM: EXYNOS: Remove scu_enable from cpuidle
  ARM: EXYNOS: Fix soft reboot hang after suspend/resume
  ARM: EXYNOS: Add support for rtc wakeup
  ARM: EXYNOS: fix the hotplug for Cortex-A15
  + Linux 3.7-rc6
Diffstat (limited to 'arch/mips/lib/bitops.c')
| -rw-r--r-- | arch/mips/lib/bitops.c | 179 | 
1 files changed, 179 insertions, 0 deletions
diff --git a/arch/mips/lib/bitops.c b/arch/mips/lib/bitops.c new file mode 100644 index 00000000000..239a9c957b0 --- /dev/null +++ b/arch/mips/lib/bitops.c @@ -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);  |