Skip to content

Commit d6ffe60

Browse files
Mikulas Patockatorvalds
authored andcommitted
provide arch_test_bit_acquire for architectures that define test_bit
Some architectures define their own arch_test_bit and they also need arch_test_bit_acquire, otherwise they won't compile. We also clean up the code by using the generic test_bit if that is equivalent to the arch-specific version. Signed-off-by: Mikulas Patocka <[email protected]> Cc: [email protected] Fixes: 8238b45 ("wait_on_bit: add an acquire memory barrier") Signed-off-by: Linus Torvalds <[email protected]>
1 parent e022620 commit d6ffe60

File tree

6 files changed

+25
-33
lines changed

6 files changed

+25
-33
lines changed

arch/alpha/include/asm/bitops.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
283283
return (old & mask) != 0;
284284
}
285285

286-
static __always_inline bool
287-
arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
288-
{
289-
return (1UL & (((const int *) addr)[nr >> 5] >> (nr & 31))) != 0UL;
290-
}
286+
#define arch_test_bit generic_test_bit
287+
#define arch_test_bit_acquire generic_test_bit_acquire
291288

292289
/*
293290
* ffz = Find First Zero in word. Undefined if no zero exists,

arch/hexagon/include/asm/bitops.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,21 @@ arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
179179
return retval;
180180
}
181181

182+
static __always_inline bool
183+
arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
184+
{
185+
int retval;
186+
187+
asm volatile(
188+
"{P0 = tstbit(%1,%2); if (P0.new) %0 = #1; if (!P0.new) %0 = #0;}\n"
189+
: "=&r" (retval)
190+
: "r" (addr[BIT_WORD(nr)]), "r" (nr % BITS_PER_LONG)
191+
: "p0", "memory"
192+
);
193+
194+
return retval;
195+
}
196+
182197
/*
183198
* ffz - find first zero in word.
184199
* @word: The word to search

arch/ia64/include/asm/bitops.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
331331
return (old & bit) != 0;
332332
}
333333

334-
static __always_inline bool
335-
arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
336-
{
337-
return 1 & (((const volatile __u32 *) addr)[nr >> 5] >> (nr & 31));
338-
}
334+
#define arch_test_bit generic_test_bit
335+
#define arch_test_bit_acquire generic_test_bit_acquire
339336

340337
/**
341338
* ffz - find the first zero bit in a long word

arch/m68k/include/asm/bitops.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,8 @@ arch___change_bit(unsigned long nr, volatile unsigned long *addr)
157157
change_bit(nr, addr);
158158
}
159159

160-
static __always_inline bool
161-
arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
162-
{
163-
return (addr[nr >> 5] & (1UL << (nr & 31))) != 0;
164-
}
160+
#define arch_test_bit generic_test_bit
161+
#define arch_test_bit_acquire generic_test_bit_acquire
165162

166163
static inline int bset_reg_test_and_set_bit(int nr,
167164
volatile unsigned long *vaddr)

arch/s390/include/asm/bitops.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
176176
return old & mask;
177177
}
178178

179-
static __always_inline bool
180-
arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
181-
{
182-
const volatile unsigned long *p = __bitops_word(nr, addr);
183-
unsigned long mask = __bitops_mask(nr);
184-
185-
return *p & mask;
186-
}
179+
#define arch_test_bit generic_test_bit
180+
#define arch_test_bit_acquire generic_test_bit_acquire
187181

188182
static inline bool arch_test_and_set_bit_lock(unsigned long nr,
189183
volatile unsigned long *ptr)

arch/sh/include/asm/bitops-op32.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,8 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
135135
return (old & mask) != 0;
136136
}
137137

138-
/**
139-
* arch_test_bit - Determine whether a bit is set
140-
* @nr: bit number to test
141-
* @addr: Address to start counting from
142-
*/
143-
static __always_inline bool
144-
arch_test_bit(unsigned long nr, const volatile unsigned long *addr)
145-
{
146-
return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
147-
}
138+
#define arch_test_bit generic_test_bit
139+
#define arch_test_bit_acquire generic_test_bit_acquire
148140

149141
#include <asm-generic/bitops/non-instrumented-non-atomic.h>
150142

0 commit comments

Comments
 (0)