diff options
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/atomic.h | 2 | ||||
-rw-r--r-- | include/asm-generic/bitops/arch_hweight.h | 25 | ||||
-rw-r--r-- | include/asm-generic/bitops/const_hweight.h | 42 | ||||
-rw-r--r-- | include/asm-generic/bitops/hweight.h | 8 | ||||
-rw-r--r-- | include/asm-generic/dma-mapping-common.h | 4 | ||||
-rw-r--r-- | include/asm-generic/kmap_types.h | 3 |
6 files changed, 74 insertions, 10 deletions
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index c99c64dc5f3d..c33749f95b32 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h | |||
@@ -33,7 +33,7 @@ | |||
33 | * Atomically reads the value of @v. Note that the guaranteed | 33 | * Atomically reads the value of @v. Note that the guaranteed |
34 | * useful range of an atomic_t is only 24 bits. | 34 | * useful range of an atomic_t is only 24 bits. |
35 | */ | 35 | */ |
36 | #define atomic_read(v) ((v)->counter) | 36 | #define atomic_read(v) (*(volatile int *)&(v)->counter) |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * atomic_set - set atomic variable | 39 | * atomic_set - set atomic variable |
diff --git a/include/asm-generic/bitops/arch_hweight.h b/include/asm-generic/bitops/arch_hweight.h new file mode 100644 index 000000000000..6a211f40665c --- /dev/null +++ b/include/asm-generic/bitops/arch_hweight.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | static inline unsigned int __arch_hweight32(unsigned int w) | ||
7 | { | ||
8 | return __sw_hweight32(w); | ||
9 | } | ||
10 | |||
11 | static inline unsigned int __arch_hweight16(unsigned int w) | ||
12 | { | ||
13 | return __sw_hweight16(w); | ||
14 | } | ||
15 | |||
16 | static inline unsigned int __arch_hweight8(unsigned int w) | ||
17 | { | ||
18 | return __sw_hweight8(w); | ||
19 | } | ||
20 | |||
21 | static inline unsigned long __arch_hweight64(__u64 w) | ||
22 | { | ||
23 | return __sw_hweight64(w); | ||
24 | } | ||
25 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ | ||
diff --git a/include/asm-generic/bitops/const_hweight.h b/include/asm-generic/bitops/const_hweight.h new file mode 100644 index 000000000000..fa2a50b7ee66 --- /dev/null +++ b/include/asm-generic/bitops/const_hweight.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ | ||
3 | |||
4 | /* | ||
5 | * Compile time versions of __arch_hweightN() | ||
6 | */ | ||
7 | #define __const_hweight8(w) \ | ||
8 | ( (!!((w) & (1ULL << 0))) + \ | ||
9 | (!!((w) & (1ULL << 1))) + \ | ||
10 | (!!((w) & (1ULL << 2))) + \ | ||
11 | (!!((w) & (1ULL << 3))) + \ | ||
12 | (!!((w) & (1ULL << 4))) + \ | ||
13 | (!!((w) & (1ULL << 5))) + \ | ||
14 | (!!((w) & (1ULL << 6))) + \ | ||
15 | (!!((w) & (1ULL << 7))) ) | ||
16 | |||
17 | #define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 )) | ||
18 | #define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16)) | ||
19 | #define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32)) | ||
20 | |||
21 | /* | ||
22 | * Generic interface. | ||
23 | */ | ||
24 | #define hweight8(w) (__builtin_constant_p(w) ? __const_hweight8(w) : __arch_hweight8(w)) | ||
25 | #define hweight16(w) (__builtin_constant_p(w) ? __const_hweight16(w) : __arch_hweight16(w)) | ||
26 | #define hweight32(w) (__builtin_constant_p(w) ? __const_hweight32(w) : __arch_hweight32(w)) | ||
27 | #define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w)) | ||
28 | |||
29 | /* | ||
30 | * Interface for known constant arguments | ||
31 | */ | ||
32 | #define HWEIGHT8(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight8(w)) | ||
33 | #define HWEIGHT16(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight16(w)) | ||
34 | #define HWEIGHT32(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight32(w)) | ||
35 | #define HWEIGHT64(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight64(w)) | ||
36 | |||
37 | /* | ||
38 | * Type invariant interface to the compile time constant hweight functions. | ||
39 | */ | ||
40 | #define HWEIGHT(w) HWEIGHT64((u64)w) | ||
41 | |||
42 | #endif /* _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ */ | ||
diff --git a/include/asm-generic/bitops/hweight.h b/include/asm-generic/bitops/hweight.h index fbbc383771da..a94d6519c7ed 100644 --- a/include/asm-generic/bitops/hweight.h +++ b/include/asm-generic/bitops/hweight.h | |||
@@ -1,11 +1,7 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_HWEIGHT_H_ | 1 | #ifndef _ASM_GENERIC_BITOPS_HWEIGHT_H_ |
2 | #define _ASM_GENERIC_BITOPS_HWEIGHT_H_ | 2 | #define _ASM_GENERIC_BITOPS_HWEIGHT_H_ |
3 | 3 | ||
4 | #include <asm/types.h> | 4 | #include <asm-generic/bitops/arch_hweight.h> |
5 | 5 | #include <asm-generic/bitops/const_hweight.h> | |
6 | extern unsigned int hweight32(unsigned int w); | ||
7 | extern unsigned int hweight16(unsigned int w); | ||
8 | extern unsigned int hweight8(unsigned int w); | ||
9 | extern unsigned long hweight64(__u64 w); | ||
10 | 6 | ||
11 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ | 7 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ |
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index e694263445f7..69206957b72c 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h | |||
@@ -131,7 +131,7 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev, | |||
131 | debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); | 131 | debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); |
132 | 132 | ||
133 | } else | 133 | } else |
134 | dma_sync_single_for_cpu(dev, addr, size, dir); | 134 | dma_sync_single_for_cpu(dev, addr + offset, size, dir); |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline void dma_sync_single_range_for_device(struct device *dev, | 137 | static inline void dma_sync_single_range_for_device(struct device *dev, |
@@ -148,7 +148,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev, | |||
148 | debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir); | 148 | debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir); |
149 | 149 | ||
150 | } else | 150 | } else |
151 | dma_sync_single_for_device(dev, addr, size, dir); | 151 | dma_sync_single_for_device(dev, addr + offset, size, dir); |
152 | } | 152 | } |
153 | 153 | ||
154 | static inline void | 154 | static inline void |
diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h index e5f234a08540..97e807c8c812 100644 --- a/include/asm-generic/kmap_types.h +++ b/include/asm-generic/kmap_types.h | |||
@@ -28,7 +28,8 @@ KMAP_D(15) KM_UML_USERCOPY, | |||
28 | KMAP_D(16) KM_IRQ_PTE, | 28 | KMAP_D(16) KM_IRQ_PTE, |
29 | KMAP_D(17) KM_NMI, | 29 | KMAP_D(17) KM_NMI, |
30 | KMAP_D(18) KM_NMI_PTE, | 30 | KMAP_D(18) KM_NMI_PTE, |
31 | KMAP_D(19) KM_TYPE_NR | 31 | KMAP_D(19) KM_KDB, |
32 | KMAP_D(20) KM_TYPE_NR | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | #undef KMAP_D | 35 | #undef KMAP_D |