diff options
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/atomic.h | 59 | ||||
-rw-r--r-- | include/asm-generic/bitops/ext2-atomic-setbit.h | 11 | ||||
-rw-r--r-- | include/asm-generic/bitops/ext2-atomic.h | 4 | ||||
-rw-r--r-- | include/asm-generic/iomap.h | 8 | ||||
-rw-r--r-- | include/asm-generic/local.h | 2 | ||||
-rw-r--r-- | include/asm-generic/local64.h | 2 | ||||
-rw-r--r-- | include/asm-generic/pci-bridge.h | 62 | ||||
-rw-r--r-- | include/asm-generic/system.h | 2 |
8 files changed, 134 insertions, 16 deletions
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index e994197f84b7..e37963c1df4d 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h | |||
@@ -1,5 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Generic C implementation of atomic counter operations | 2 | * Generic C implementation of atomic counter operations. Usable on |
3 | * UP systems only. Do not include in machine independent code. | ||
4 | * | ||
3 | * Originally implemented for MN10300. | 5 | * Originally implemented for MN10300. |
4 | * | 6 | * |
5 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. | 7 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
@@ -14,7 +16,11 @@ | |||
14 | #define __ASM_GENERIC_ATOMIC_H | 16 | #define __ASM_GENERIC_ATOMIC_H |
15 | 17 | ||
16 | #ifdef CONFIG_SMP | 18 | #ifdef CONFIG_SMP |
17 | #error not SMP safe | 19 | /* Force people to define core atomics */ |
20 | # if !defined(atomic_add_return) || !defined(atomic_sub_return) || \ | ||
21 | !defined(atomic_clear_mask) || !defined(atomic_set_mask) | ||
22 | # error "SMP requires a little arch-specific magic" | ||
23 | # endif | ||
18 | #endif | 24 | #endif |
19 | 25 | ||
20 | /* | 26 | /* |
@@ -32,7 +38,9 @@ | |||
32 | * | 38 | * |
33 | * Atomically reads the value of @v. | 39 | * Atomically reads the value of @v. |
34 | */ | 40 | */ |
41 | #ifndef atomic_read | ||
35 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 42 | #define atomic_read(v) (*(volatile int *)&(v)->counter) |
43 | #endif | ||
36 | 44 | ||
37 | /** | 45 | /** |
38 | * atomic_set - set atomic variable | 46 | * atomic_set - set atomic variable |
@@ -53,6 +61,7 @@ | |||
53 | * | 61 | * |
54 | * Atomically adds @i to @v and returns the result | 62 | * Atomically adds @i to @v and returns the result |
55 | */ | 63 | */ |
64 | #ifndef atomic_add_return | ||
56 | static inline int atomic_add_return(int i, atomic_t *v) | 65 | static inline int atomic_add_return(int i, atomic_t *v) |
57 | { | 66 | { |
58 | unsigned long flags; | 67 | unsigned long flags; |
@@ -66,6 +75,7 @@ static inline int atomic_add_return(int i, atomic_t *v) | |||
66 | 75 | ||
67 | return temp; | 76 | return temp; |
68 | } | 77 | } |
78 | #endif | ||
69 | 79 | ||
70 | /** | 80 | /** |
71 | * atomic_sub_return - subtract integer from atomic variable | 81 | * atomic_sub_return - subtract integer from atomic variable |
@@ -74,6 +84,7 @@ static inline int atomic_add_return(int i, atomic_t *v) | |||
74 | * | 84 | * |
75 | * Atomically subtracts @i from @v and returns the result | 85 | * Atomically subtracts @i from @v and returns the result |
76 | */ | 86 | */ |
87 | #ifndef atomic_sub_return | ||
77 | static inline int atomic_sub_return(int i, atomic_t *v) | 88 | static inline int atomic_sub_return(int i, atomic_t *v) |
78 | { | 89 | { |
79 | unsigned long flags; | 90 | unsigned long flags; |
@@ -87,6 +98,7 @@ static inline int atomic_sub_return(int i, atomic_t *v) | |||
87 | 98 | ||
88 | return temp; | 99 | return temp; |
89 | } | 100 | } |
101 | #endif | ||
90 | 102 | ||
91 | static inline int atomic_add_negative(int i, atomic_t *v) | 103 | static inline int atomic_add_negative(int i, atomic_t *v) |
92 | { | 104 | { |
@@ -117,8 +129,8 @@ static inline void atomic_dec(atomic_t *v) | |||
117 | #define atomic_inc_return(v) atomic_add_return(1, (v)) | 129 | #define atomic_inc_return(v) atomic_add_return(1, (v)) |
118 | 130 | ||
119 | #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0) | 131 | #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0) |
120 | #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) | 132 | #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) |
121 | #define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) | 133 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) |
122 | 134 | ||
123 | #define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v))) | 135 | #define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v))) |
124 | #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) | 136 | #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) |
@@ -129,26 +141,51 @@ static inline void atomic_dec(atomic_t *v) | |||
129 | 141 | ||
130 | #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) | 142 | #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) |
131 | 143 | ||
132 | static inline int atomic_add_unless(atomic_t *v, int a, int u) | 144 | static inline int __atomic_add_unless(atomic_t *v, int a, int u) |
133 | { | 145 | { |
134 | int c, old; | 146 | int c, old; |
135 | c = atomic_read(v); | 147 | c = atomic_read(v); |
136 | while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c) | 148 | while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c) |
137 | c = old; | 149 | c = old; |
138 | return c != u; | 150 | return c; |
139 | } | 151 | } |
140 | 152 | ||
141 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | 153 | /** |
142 | 154 | * atomic_clear_mask - Atomically clear bits in atomic variable | |
143 | static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) | 155 | * @mask: Mask of the bits to be cleared |
156 | * @v: pointer of type atomic_t | ||
157 | * | ||
158 | * Atomically clears the bits set in @mask from @v | ||
159 | */ | ||
160 | #ifndef atomic_clear_mask | ||
161 | static inline void atomic_clear_mask(unsigned long mask, atomic_t *v) | ||
144 | { | 162 | { |
145 | unsigned long flags; | 163 | unsigned long flags; |
146 | 164 | ||
147 | mask = ~mask; | 165 | mask = ~mask; |
148 | raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */ | 166 | raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */ |
149 | *addr &= mask; | 167 | v->counter &= mask; |
150 | raw_local_irq_restore(flags); | 168 | raw_local_irq_restore(flags); |
151 | } | 169 | } |
170 | #endif | ||
171 | |||
172 | /** | ||
173 | * atomic_set_mask - Atomically set bits in atomic variable | ||
174 | * @mask: Mask of the bits to be set | ||
175 | * @v: pointer of type atomic_t | ||
176 | * | ||
177 | * Atomically sets the bits set in @mask in @v | ||
178 | */ | ||
179 | #ifndef atomic_set_mask | ||
180 | static inline void atomic_set_mask(unsigned int mask, atomic_t *v) | ||
181 | { | ||
182 | unsigned long flags; | ||
183 | |||
184 | raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */ | ||
185 | v->counter |= mask; | ||
186 | raw_local_irq_restore(flags); | ||
187 | } | ||
188 | #endif | ||
152 | 189 | ||
153 | /* Assume that atomic operations are already serializing */ | 190 | /* Assume that atomic operations are already serializing */ |
154 | #define smp_mb__before_atomic_dec() barrier() | 191 | #define smp_mb__before_atomic_dec() barrier() |
@@ -156,7 +193,5 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) | |||
156 | #define smp_mb__before_atomic_inc() barrier() | 193 | #define smp_mb__before_atomic_inc() barrier() |
157 | #define smp_mb__after_atomic_inc() barrier() | 194 | #define smp_mb__after_atomic_inc() barrier() |
158 | 195 | ||
159 | #include <asm-generic/atomic-long.h> | ||
160 | |||
161 | #endif /* __KERNEL__ */ | 196 | #endif /* __KERNEL__ */ |
162 | #endif /* __ASM_GENERIC_ATOMIC_H */ | 197 | #endif /* __ASM_GENERIC_ATOMIC_H */ |
diff --git a/include/asm-generic/bitops/ext2-atomic-setbit.h b/include/asm-generic/bitops/ext2-atomic-setbit.h new file mode 100644 index 000000000000..5a0997857b34 --- /dev/null +++ b/include/asm-generic/bitops/ext2-atomic-setbit.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_ | ||
3 | |||
4 | /* | ||
5 | * Atomic bitops based version of ext2 atomic bitops | ||
6 | */ | ||
7 | |||
8 | #define ext2_set_bit_atomic(l, nr, addr) test_and_set_bit_le(nr, addr) | ||
9 | #define ext2_clear_bit_atomic(l, nr, addr) test_and_clear_bit_le(nr, addr) | ||
10 | |||
11 | #endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_ */ | ||
diff --git a/include/asm-generic/bitops/ext2-atomic.h b/include/asm-generic/bitops/ext2-atomic.h index ecf1c9d8a7cc..87f0f109d7f1 100644 --- a/include/asm-generic/bitops/ext2-atomic.h +++ b/include/asm-generic/bitops/ext2-atomic.h | |||
@@ -1,6 +1,10 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ | 1 | #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ |
2 | #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ | 2 | #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ |
3 | 3 | ||
4 | /* | ||
5 | * Spinlock based version of ext2 atomic bitops | ||
6 | */ | ||
7 | |||
4 | #define ext2_set_bit_atomic(lock, nr, addr) \ | 8 | #define ext2_set_bit_atomic(lock, nr, addr) \ |
5 | ({ \ | 9 | ({ \ |
6 | int ret; \ | 10 | int ret; \ |
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index c74ef2c6e633..98dcd76ce836 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h | |||
@@ -71,6 +71,14 @@ extern void ioport_unmap(void __iomem *); | |||
71 | struct pci_dev; | 71 | struct pci_dev; |
72 | extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); | 72 | extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); |
73 | extern void pci_iounmap(struct pci_dev *dev, void __iomem *); | 73 | extern void pci_iounmap(struct pci_dev *dev, void __iomem *); |
74 | #else | ||
75 | struct pci_dev; | ||
76 | static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max) | ||
77 | { | ||
78 | return NULL; | ||
79 | } | ||
80 | static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) | ||
81 | { } | ||
74 | #endif | 82 | #endif |
75 | 83 | ||
76 | #endif | 84 | #endif |
diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h index c8a5d68541d7..9ceb03b4f466 100644 --- a/include/asm-generic/local.h +++ b/include/asm-generic/local.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define _ASM_GENERIC_LOCAL_H | 2 | #define _ASM_GENERIC_LOCAL_H |
3 | 3 | ||
4 | #include <linux/percpu.h> | 4 | #include <linux/percpu.h> |
5 | #include <asm/atomic.h> | 5 | #include <linux/atomic.h> |
6 | #include <asm/types.h> | 6 | #include <asm/types.h> |
7 | 7 | ||
8 | /* | 8 | /* |
diff --git a/include/asm-generic/local64.h b/include/asm-generic/local64.h index 02ac760c1a8b..5980002b8b7b 100644 --- a/include/asm-generic/local64.h +++ b/include/asm-generic/local64.h | |||
@@ -55,7 +55,7 @@ typedef struct { | |||
55 | 55 | ||
56 | #else /* BITS_PER_LONG != 64 */ | 56 | #else /* BITS_PER_LONG != 64 */ |
57 | 57 | ||
58 | #include <asm/atomic.h> | 58 | #include <linux/atomic.h> |
59 | 59 | ||
60 | /* Don't use typedef: don't want them to be mixed with atomic_t's. */ | 60 | /* Don't use typedef: don't want them to be mixed with atomic_t's. */ |
61 | typedef struct { | 61 | typedef struct { |
diff --git a/include/asm-generic/pci-bridge.h b/include/asm-generic/pci-bridge.h new file mode 100644 index 000000000000..4a5aca2a2c94 --- /dev/null +++ b/include/asm-generic/pci-bridge.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or | ||
3 | * modify it under the terms of the GNU General Public License | ||
4 | * as published by the Free Software Foundation; either version | ||
5 | * 2 of the License, or (at your option) any later version. | ||
6 | */ | ||
7 | #ifndef _ASM_GENERIC_PCI_BRIDGE_H | ||
8 | #define _ASM_GENERIC_PCI_BRIDGE_H | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | enum { | ||
13 | /* Force re-assigning all resources (ignore firmware | ||
14 | * setup completely) | ||
15 | */ | ||
16 | PCI_REASSIGN_ALL_RSRC = 0x00000001, | ||
17 | |||
18 | /* Re-assign all bus numbers */ | ||
19 | PCI_REASSIGN_ALL_BUS = 0x00000002, | ||
20 | |||
21 | /* Do not try to assign, just use existing setup */ | ||
22 | PCI_PROBE_ONLY = 0x00000004, | ||
23 | |||
24 | /* Don't bother with ISA alignment unless the bridge has | ||
25 | * ISA forwarding enabled | ||
26 | */ | ||
27 | PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, | ||
28 | |||
29 | /* Enable domain numbers in /proc */ | ||
30 | PCI_ENABLE_PROC_DOMAINS = 0x00000010, | ||
31 | /* ... except for domain 0 */ | ||
32 | PCI_COMPAT_DOMAIN_0 = 0x00000020, | ||
33 | }; | ||
34 | |||
35 | #ifdef CONFIG_PCI | ||
36 | extern unsigned int pci_flags; | ||
37 | |||
38 | static inline void pci_set_flags(int flags) | ||
39 | { | ||
40 | pci_flags = flags; | ||
41 | } | ||
42 | |||
43 | static inline void pci_add_flags(int flags) | ||
44 | { | ||
45 | pci_flags |= flags; | ||
46 | } | ||
47 | |||
48 | static inline int pci_has_flag(int flag) | ||
49 | { | ||
50 | return pci_flags & flag; | ||
51 | } | ||
52 | #else | ||
53 | static inline void pci_set_flags(int flags) { } | ||
54 | static inline void pci_add_flags(int flags) { } | ||
55 | static inline int pci_has_flag(int flag) | ||
56 | { | ||
57 | return 0; | ||
58 | } | ||
59 | #endif /* CONFIG_PCI */ | ||
60 | |||
61 | #endif /* __KERNEL__ */ | ||
62 | #endif /* _ASM_GENERIC_PCI_BRIDGE_H */ | ||
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h index 4b0b9cbbfae5..215efa74f5a2 100644 --- a/include/asm-generic/system.h +++ b/include/asm-generic/system.h | |||
@@ -14,7 +14,6 @@ | |||
14 | #ifndef __ASM_GENERIC_SYSTEM_H | 14 | #ifndef __ASM_GENERIC_SYSTEM_H |
15 | #define __ASM_GENERIC_SYSTEM_H | 15 | #define __ASM_GENERIC_SYSTEM_H |
16 | 16 | ||
17 | #ifdef __KERNEL__ | ||
18 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
19 | 18 | ||
20 | #include <linux/types.h> | 19 | #include <linux/types.h> |
@@ -139,5 +138,4 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size) | |||
139 | 138 | ||
140 | #endif /* !__ASSEMBLY__ */ | 139 | #endif /* !__ASSEMBLY__ */ |
141 | 140 | ||
142 | #endif /* __KERNEL__ */ | ||
143 | #endif /* __ASM_GENERIC_SYSTEM_H */ | 141 | #endif /* __ASM_GENERIC_SYSTEM_H */ |