Skip to content

Commit db08bf0

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
* git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: asm-generic/io.h: allow people to override individual funcs bitops: remove duplicated extern declarations bitops: make asm-generic/bitops/find.h more generic asm-generic: kdebug.h: Checkpatch cleanup asm-generic: fcntl: make exported headers use strict posix types asm-generic: cmpxchg does not handle non-long arguments asm-generic: make atomic_add_unless a function
2 parents 092e0e7 + 35dbc0e commit db08bf0

File tree

9 files changed

+86
-85
lines changed

9 files changed

+86
-85
lines changed

arch/tile/include/asm/bitops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static inline unsigned long __arch_hweight64(__u64 w)
120120

121121
#include <asm-generic/bitops/const_hweight.h>
122122
#include <asm-generic/bitops/lock.h>
123+
#include <asm-generic/bitops/find.h>
123124
#include <asm-generic/bitops/sched.h>
124125
#include <asm-generic/bitops/ext2-non-atomic.h>
125126
#include <asm-generic/bitops/minix.h>

arch/x86/include/asm/bitops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ static inline int fls(int x)
440440

441441
#ifdef __KERNEL__
442442

443+
#include <asm-generic/bitops/find.h>
444+
443445
#include <asm-generic/bitops/sched.h>
444446

445447
#define ARCH_HAS_FAST_MULTIPLIER 1

include/asm-generic/atomic.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,23 @@ static inline void atomic_dec(atomic_t *v)
120120
#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
121121
#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
122122

123-
#define atomic_add_unless(v, a, u) \
124-
({ \
125-
int c, old; \
126-
c = atomic_read(v); \
127-
while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
128-
c = old; \
129-
c != (u); \
130-
})
123+
#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
124+
#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
125+
126+
#define cmpxchg_local(ptr, o, n) \
127+
((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
128+
(unsigned long)(n), sizeof(*(ptr))))
129+
130+
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
131+
132+
static inline int atomic_add_unless(atomic_t *v, int a, int u)
133+
{
134+
int c, old;
135+
c = atomic_read(v);
136+
while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c)
137+
c = old;
138+
return c != u;
139+
}
131140

132141
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
133142

@@ -141,15 +150,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
141150
raw_local_irq_restore(flags);
142151
}
143152

144-
#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
145-
#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
146-
147-
#define cmpxchg_local(ptr, o, n) \
148-
((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
149-
(unsigned long)(n), sizeof(*(ptr))))
150-
151-
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
152-
153153
/* Assume that atomic operations are already serializing */
154154
#define smp_mb__before_atomic_dec() barrier()
155155
#define smp_mb__after_atomic_dec() barrier()

include/asm-generic/bitops/find.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,50 @@
11
#ifndef _ASM_GENERIC_BITOPS_FIND_H_
22
#define _ASM_GENERIC_BITOPS_FIND_H_
33

4-
#ifndef CONFIG_GENERIC_FIND_NEXT_BIT
4+
/**
5+
* find_next_bit - find the next set bit in a memory region
6+
* @addr: The address to base the search on
7+
* @offset: The bitnumber to start searching at
8+
* @size: The bitmap size in bits
9+
*/
510
extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
611
size, unsigned long offset);
712

13+
/**
14+
* find_next_zero_bit - find the next cleared bit in a memory region
15+
* @addr: The address to base the search on
16+
* @offset: The bitnumber to start searching at
17+
* @size: The bitmap size in bits
18+
*/
819
extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
920
long size, unsigned long offset);
10-
#endif
21+
22+
#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
23+
24+
/**
25+
* find_first_bit - find the first set bit in a memory region
26+
* @addr: The address to start the search at
27+
* @size: The maximum size to search
28+
*
29+
* Returns the bit number of the first set bit.
30+
*/
31+
extern unsigned long find_first_bit(const unsigned long *addr,
32+
unsigned long size);
33+
34+
/**
35+
* find_first_zero_bit - find the first cleared bit in a memory region
36+
* @addr: The address to start the search at
37+
* @size: The maximum size to search
38+
*
39+
* Returns the bit number of the first cleared bit.
40+
*/
41+
extern unsigned long find_first_zero_bit(const unsigned long *addr,
42+
unsigned long size);
43+
#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
1144

1245
#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
1346
#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
1447

48+
#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
49+
1550
#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */

include/asm-generic/fcntl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122

123123
struct f_owner_ex {
124124
int type;
125-
pid_t pid;
125+
__kernel_pid_t pid;
126126
};
127127

128128
/* for F_[GET|SET]FL */

include/asm-generic/io.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
#include <asm-generic/iomap.h>
2020
#endif
2121

22+
#ifndef mmiowb
2223
#define mmiowb() do {} while (0)
24+
#endif
2325

2426
/*****************************************************************************/
2527
/*
@@ -28,39 +30,51 @@
2830
* differently. On the simple architectures, we just read/write the
2931
* memory location directly.
3032
*/
33+
#ifndef __raw_readb
3134
static inline u8 __raw_readb(const volatile void __iomem *addr)
3235
{
3336
return *(const volatile u8 __force *) addr;
3437
}
38+
#endif
3539

40+
#ifndef __raw_readw
3641
static inline u16 __raw_readw(const volatile void __iomem *addr)
3742
{
3843
return *(const volatile u16 __force *) addr;
3944
}
45+
#endif
4046

47+
#ifndef __raw_readl
4148
static inline u32 __raw_readl(const volatile void __iomem *addr)
4249
{
4350
return *(const volatile u32 __force *) addr;
4451
}
52+
#endif
4553

4654
#define readb __raw_readb
4755
#define readw(addr) __le16_to_cpu(__raw_readw(addr))
4856
#define readl(addr) __le32_to_cpu(__raw_readl(addr))
4957

58+
#ifndef __raw_writeb
5059
static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
5160
{
5261
*(volatile u8 __force *) addr = b;
5362
}
63+
#endif
5464

65+
#ifndef __raw_writew
5566
static inline void __raw_writew(u16 b, volatile void __iomem *addr)
5667
{
5768
*(volatile u16 __force *) addr = b;
5869
}
70+
#endif
5971

72+
#ifndef __raw_writel
6073
static inline void __raw_writel(u32 b, volatile void __iomem *addr)
6174
{
6275
*(volatile u32 __force *) addr = b;
6376
}
77+
#endif
6478

6579
#define writeb __raw_writeb
6680
#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)
@@ -122,6 +136,7 @@ static inline void outl(u32 b, unsigned long addr)
122136
#define outw_p(x, addr) outw((x), (addr))
123137
#define outl_p(x, addr) outl((x), (addr))
124138

139+
#ifndef insb
125140
static inline void insb(unsigned long addr, void *buffer, int count)
126141
{
127142
if (count) {
@@ -132,7 +147,9 @@ static inline void insb(unsigned long addr, void *buffer, int count)
132147
} while (--count);
133148
}
134149
}
150+
#endif
135151

152+
#ifndef insw
136153
static inline void insw(unsigned long addr, void *buffer, int count)
137154
{
138155
if (count) {
@@ -143,7 +160,9 @@ static inline void insw(unsigned long addr, void *buffer, int count)
143160
} while (--count);
144161
}
145162
}
163+
#endif
146164

165+
#ifndef insl
147166
static inline void insl(unsigned long addr, void *buffer, int count)
148167
{
149168
if (count) {
@@ -154,7 +173,9 @@ static inline void insl(unsigned long addr, void *buffer, int count)
154173
} while (--count);
155174
}
156175
}
176+
#endif
157177

178+
#ifndef outsb
158179
static inline void outsb(unsigned long addr, const void *buffer, int count)
159180
{
160181
if (count) {
@@ -164,7 +185,9 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
164185
} while (--count);
165186
}
166187
}
188+
#endif
167189

190+
#ifndef outsw
168191
static inline void outsw(unsigned long addr, const void *buffer, int count)
169192
{
170193
if (count) {
@@ -174,7 +197,9 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
174197
} while (--count);
175198
}
176199
}
200+
#endif
177201

202+
#ifndef outsl
178203
static inline void outsl(unsigned long addr, const void *buffer, int count)
179204
{
180205
if (count) {
@@ -184,6 +209,7 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
184209
} while (--count);
185210
}
186211
}
212+
#endif
187213

188214
#ifndef CONFIG_GENERIC_IOMAP
189215
#define ioread8(addr) readb(addr)

include/asm-generic/kdebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
enum die_val {
55
DIE_UNUSED,
6-
DIE_OOPS=1
6+
DIE_OOPS = 1,
77
};
88

99
#endif /* _ASM_GENERIC_KDEBUG_H */

include/asm-generic/system.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/irqflags.h>
2222

2323
#include <asm/cmpxchg-local.h>
24+
#include <asm/cmpxchg.h>
2425

2526
struct task_struct;
2627

@@ -136,25 +137,6 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
136137
#define xchg(ptr, x) \
137138
((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
138139

139-
static inline unsigned long __cmpxchg(volatile unsigned long *m,
140-
unsigned long old, unsigned long new)
141-
{
142-
unsigned long retval;
143-
unsigned long flags;
144-
145-
local_irq_save(flags);
146-
retval = *m;
147-
if (retval == old)
148-
*m = new;
149-
local_irq_restore(flags);
150-
return retval;
151-
}
152-
153-
#define cmpxchg(ptr, o, n) \
154-
((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
155-
(unsigned long)(o), \
156-
(unsigned long)(n)))
157-
158140
#endif /* !__ASSEMBLY__ */
159141

160142
#endif /* __KERNEL__ */

include/linux/bitops.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,6 @@ static inline unsigned long __ffs64(u64 word)
136136
}
137137

138138
#ifdef __KERNEL__
139-
#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
140-
141-
/**
142-
* find_first_bit - find the first set bit in a memory region
143-
* @addr: The address to start the search at
144-
* @size: The maximum size to search
145-
*
146-
* Returns the bit number of the first set bit.
147-
*/
148-
extern unsigned long find_first_bit(const unsigned long *addr,
149-
unsigned long size);
150-
151-
/**
152-
* find_first_zero_bit - find the first cleared bit in a memory region
153-
* @addr: The address to start the search at
154-
* @size: The maximum size to search
155-
*
156-
* Returns the bit number of the first cleared bit.
157-
*/
158-
extern unsigned long find_first_zero_bit(const unsigned long *addr,
159-
unsigned long size);
160-
#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
161139

162140
#ifdef CONFIG_GENERIC_FIND_LAST_BIT
163141
/**
@@ -171,28 +149,5 @@ extern unsigned long find_last_bit(const unsigned long *addr,
171149
unsigned long size);
172150
#endif /* CONFIG_GENERIC_FIND_LAST_BIT */
173151

174-
#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
175-
176-
/**
177-
* find_next_bit - find the next set bit in a memory region
178-
* @addr: The address to base the search on
179-
* @offset: The bitnumber to start searching at
180-
* @size: The bitmap size in bits
181-
*/
182-
extern unsigned long find_next_bit(const unsigned long *addr,
183-
unsigned long size, unsigned long offset);
184-
185-
/**
186-
* find_next_zero_bit - find the next cleared bit in a memory region
187-
* @addr: The address to base the search on
188-
* @offset: The bitnumber to start searching at
189-
* @size: The bitmap size in bits
190-
*/
191-
192-
extern unsigned long find_next_zero_bit(const unsigned long *addr,
193-
unsigned long size,
194-
unsigned long offset);
195-
196-
#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
197152
#endif /* __KERNEL__ */
198153
#endif

0 commit comments

Comments
 (0)