diff options
Diffstat (limited to 'include/asm-parisc/bitops.h')
-rw-r--r-- | include/asm-parisc/bitops.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h index 900561922c4c..015cb0d379bd 100644 --- a/include/asm-parisc/bitops.h +++ b/include/asm-parisc/bitops.h | |||
@@ -60,31 +60,37 @@ static __inline__ void change_bit(int nr, volatile unsigned long * addr) | |||
60 | static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr) | 60 | static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr) |
61 | { | 61 | { |
62 | unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr); | 62 | unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr); |
63 | unsigned long oldbit; | 63 | unsigned long old; |
64 | unsigned long flags; | 64 | unsigned long flags; |
65 | int set; | ||
65 | 66 | ||
66 | addr += (nr >> SHIFT_PER_LONG); | 67 | addr += (nr >> SHIFT_PER_LONG); |
67 | _atomic_spin_lock_irqsave(addr, flags); | 68 | _atomic_spin_lock_irqsave(addr, flags); |
68 | oldbit = *addr; | 69 | old = *addr; |
69 | *addr = oldbit | mask; | 70 | set = (old & mask) ? 1 : 0; |
71 | if (!set) | ||
72 | *addr = old | mask; | ||
70 | _atomic_spin_unlock_irqrestore(addr, flags); | 73 | _atomic_spin_unlock_irqrestore(addr, flags); |
71 | 74 | ||
72 | return (oldbit & mask) ? 1 : 0; | 75 | return set; |
73 | } | 76 | } |
74 | 77 | ||
75 | static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr) | 78 | static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr) |
76 | { | 79 | { |
77 | unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr); | 80 | unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr); |
78 | unsigned long oldbit; | 81 | unsigned long old; |
79 | unsigned long flags; | 82 | unsigned long flags; |
83 | int set; | ||
80 | 84 | ||
81 | addr += (nr >> SHIFT_PER_LONG); | 85 | addr += (nr >> SHIFT_PER_LONG); |
82 | _atomic_spin_lock_irqsave(addr, flags); | 86 | _atomic_spin_lock_irqsave(addr, flags); |
83 | oldbit = *addr; | 87 | old = *addr; |
84 | *addr = oldbit & ~mask; | 88 | set = (old & mask) ? 1 : 0; |
89 | if (set) | ||
90 | *addr = old & ~mask; | ||
85 | _atomic_spin_unlock_irqrestore(addr, flags); | 91 | _atomic_spin_unlock_irqrestore(addr, flags); |
86 | 92 | ||
87 | return (oldbit & mask) ? 1 : 0; | 93 | return set; |
88 | } | 94 | } |
89 | 95 | ||
90 | static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr) | 96 | static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr) |
@@ -130,7 +136,7 @@ static __inline__ unsigned long __ffs(unsigned long x) | |||
130 | unsigned long ret; | 136 | unsigned long ret; |
131 | 137 | ||
132 | __asm__( | 138 | __asm__( |
133 | #ifdef __LP64__ | 139 | #ifdef CONFIG_64BIT |
134 | " ldi 63,%1\n" | 140 | " ldi 63,%1\n" |
135 | " extrd,u,*<> %0,63,32,%%r0\n" | 141 | " extrd,u,*<> %0,63,32,%%r0\n" |
136 | " extrd,u,*TR %0,31,32,%0\n" /* move top 32-bits down */ | 142 | " extrd,u,*TR %0,31,32,%0\n" /* move top 32-bits down */ |