2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (c) 1994-1997, 99, 2000, 06, 07 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc.
9 #include <linux/bitops.h>
10 #include <linux/bits.h>
11 #include <linux/irqflags.h>
12 #include <linux/export.h>
16 * __mips_set_bit - Atomically set a bit in memory. This is called by
17 * set_bit() if it cannot find a faster solution.
19 * @addr: the address to start counting from
21 void __mips_set_bit(unsigned long nr, volatile unsigned long *addr)
23 volatile unsigned long *a = &addr[BIT_WORD(nr)];
24 unsigned int bit = nr % BITS_PER_LONG;
29 raw_local_irq_save(flags);
31 raw_local_irq_restore(flags);
33 EXPORT_SYMBOL(__mips_set_bit);
37 * __mips_clear_bit - Clears a bit in memory. This is called by clear_bit() if
38 * it cannot find a faster solution.
40 * @addr: Address to start counting from
42 void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr)
44 volatile unsigned long *a = &addr[BIT_WORD(nr)];
45 unsigned int bit = nr % BITS_PER_LONG;
50 raw_local_irq_save(flags);
52 raw_local_irq_restore(flags);
54 EXPORT_SYMBOL(__mips_clear_bit);
58 * __mips_change_bit - Toggle a bit in memory. This is called by change_bit()
59 * if it cannot find a faster solution.
61 * @addr: Address to start counting from
63 void __mips_change_bit(unsigned long nr, volatile unsigned long *addr)
65 volatile unsigned long *a = &addr[BIT_WORD(nr)];
66 unsigned int bit = nr % BITS_PER_LONG;
71 raw_local_irq_save(flags);
73 raw_local_irq_restore(flags);
75 EXPORT_SYMBOL(__mips_change_bit);
79 * __mips_test_and_set_bit_lock - Set a bit and return its old value. This is
80 * called by test_and_set_bit_lock() if it cannot find a faster solution.
82 * @addr: Address to count from
84 int __mips_test_and_set_bit_lock(unsigned long nr,
85 volatile unsigned long *addr)
87 volatile unsigned long *a = &addr[BIT_WORD(nr)];
88 unsigned int bit = nr % BITS_PER_LONG;
94 raw_local_irq_save(flags);
95 res = (mask & *a) != 0;
97 raw_local_irq_restore(flags);
100 EXPORT_SYMBOL(__mips_test_and_set_bit_lock);
104 * __mips_test_and_clear_bit - Clear a bit and return its old value. This is
105 * called by test_and_clear_bit() if it cannot find a faster solution.
107 * @addr: Address to count from
109 int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
111 volatile unsigned long *a = &addr[BIT_WORD(nr)];
112 unsigned int bit = nr % BITS_PER_LONG;
118 raw_local_irq_save(flags);
119 res = (mask & *a) != 0;
121 raw_local_irq_restore(flags);
124 EXPORT_SYMBOL(__mips_test_and_clear_bit);
128 * __mips_test_and_change_bit - Change a bit and return its old value. This is
129 * called by test_and_change_bit() if it cannot find a faster solution.
131 * @addr: Address to count from
133 int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
135 volatile unsigned long *a = &addr[BIT_WORD(nr)];
136 unsigned int bit = nr % BITS_PER_LONG;
142 raw_local_irq_save(flags);
143 res = (mask & *a) != 0;
145 raw_local_irq_restore(flags);
148 EXPORT_SYMBOL(__mips_test_and_change_bit);