|
9 | 9 | #include <linux/bitfield.h>
|
10 | 10 | #include <linux/bits.h>
|
11 | 11 |
|
12 |
| -/** |
13 |
| - * REG_BIT() - Prepare a u32 bit value |
14 |
| - * @__n: 0-based bit number |
15 |
| - * |
16 |
| - * Local wrapper for BIT() to force u32, with compile time checks. |
17 |
| - * |
18 |
| - * @return: Value with bit @__n set. |
19 |
| - */ |
20 |
| -#define REG_BIT(__n) \ |
21 |
| - ((u32)(BIT(__n) + \ |
22 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ |
23 |
| - ((__n) < 0 || (__n) > 31)))) |
24 |
| - |
25 |
| -/** |
26 |
| - * REG_BIT8() - Prepare a u8 bit value |
27 |
| - * @__n: 0-based bit number |
28 |
| - * |
29 |
| - * Local wrapper for BIT() to force u8, with compile time checks. |
30 |
| - * |
31 |
| - * @return: Value with bit @__n set. |
32 |
| - */ |
33 |
| -#define REG_BIT8(__n) \ |
34 |
| - ((u8)(BIT(__n) + \ |
35 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ |
36 |
| - ((__n) < 0 || (__n) > 7)))) |
37 |
| - |
38 |
| -/** |
39 |
| - * REG_GENMASK() - Prepare a continuous u32 bitmask |
40 |
| - * @__high: 0-based high bit |
41 |
| - * @__low: 0-based low bit |
42 |
| - * |
43 |
| - * Local wrapper for GENMASK() to force u32, with compile time checks. |
44 |
| - * |
45 |
| - * @return: Continuous bitmask from @__high to @__low, inclusive. |
46 |
| - */ |
47 |
| -#define REG_GENMASK(__high, __low) \ |
48 |
| - ((u32)(GENMASK(__high, __low) + \ |
49 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ |
50 |
| - __is_constexpr(__low) && \ |
51 |
| - ((__low) < 0 || (__high) > 31 || (__low) > (__high))))) |
52 |
| - |
53 |
| -/** |
54 |
| - * REG_GENMASK64() - Prepare a continuous u64 bitmask |
55 |
| - * @__high: 0-based high bit |
56 |
| - * @__low: 0-based low bit |
57 |
| - * |
58 |
| - * Local wrapper for GENMASK_ULL() to force u64, with compile time checks. |
59 |
| - * |
60 |
| - * @return: Continuous bitmask from @__high to @__low, inclusive. |
| 12 | +/* |
| 13 | + * Wrappers over the generic fixed width BIT_U*() and GENMASK_U*() |
| 14 | + * implementations, for compatibility reasons with previous implementation. |
61 | 15 | */
|
62 |
| -#define REG_GENMASK64(__high, __low) \ |
63 |
| - ((u64)(GENMASK_ULL(__high, __low) + \ |
64 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ |
65 |
| - __is_constexpr(__low) && \ |
66 |
| - ((__low) < 0 || (__high) > 63 || (__low) > (__high))))) |
| 16 | +#define REG_GENMASK(high, low) GENMASK_U32(high, low) |
| 17 | +#define REG_GENMASK64(high, low) GENMASK_U64(high, low) |
| 18 | +#define REG_GENMASK16(high, low) GENMASK_U16(high, low) |
| 19 | +#define REG_GENMASK8(high, low) GENMASK_U8(high, low) |
67 | 20 |
|
68 |
| -/** |
69 |
| - * REG_GENMASK8() - Prepare a continuous u8 bitmask |
70 |
| - * @__high: 0-based high bit |
71 |
| - * @__low: 0-based low bit |
72 |
| - * |
73 |
| - * Local wrapper for GENMASK() to force u8, with compile time checks. |
74 |
| - * |
75 |
| - * @return: Continuous bitmask from @__high to @__low, inclusive. |
76 |
| - */ |
77 |
| -#define REG_GENMASK8(__high, __low) \ |
78 |
| - ((u8)(GENMASK(__high, __low) + \ |
79 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ |
80 |
| - __is_constexpr(__low) && \ |
81 |
| - ((__low) < 0 || (__high) > 7 || (__low) > (__high))))) |
| 21 | +#define REG_BIT(n) BIT_U32(n) |
| 22 | +#define REG_BIT64(n) BIT_U64(n) |
| 23 | +#define REG_BIT16(n) BIT_U16(n) |
| 24 | +#define REG_BIT8(n) BIT_U8(n) |
82 | 25 |
|
83 | 26 | /*
|
84 | 27 | * Local integer constant expression version of is_power_of_2().
|
|
143 | 86 | */
|
144 | 87 | #define REG_FIELD_GET64(__mask, __val) ((u64)FIELD_GET(__mask, __val))
|
145 | 88 |
|
146 |
| -/** |
147 |
| - * REG_BIT16() - Prepare a u16 bit value |
148 |
| - * @__n: 0-based bit number |
149 |
| - * |
150 |
| - * Local wrapper for BIT() to force u16, with compile time |
151 |
| - * checks. |
152 |
| - * |
153 |
| - * @return: Value with bit @__n set. |
154 |
| - */ |
155 |
| -#define REG_BIT16(__n) \ |
156 |
| - ((u16)(BIT(__n) + \ |
157 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ |
158 |
| - ((__n) < 0 || (__n) > 15)))) |
159 |
| - |
160 |
| -/** |
161 |
| - * REG_GENMASK16() - Prepare a continuous u8 bitmask |
162 |
| - * @__high: 0-based high bit |
163 |
| - * @__low: 0-based low bit |
164 |
| - * |
165 |
| - * Local wrapper for GENMASK() to force u16, with compile time |
166 |
| - * checks. |
167 |
| - * |
168 |
| - * @return: Continuous bitmask from @__high to @__low, inclusive. |
169 |
| - */ |
170 |
| -#define REG_GENMASK16(__high, __low) \ |
171 |
| - ((u16)(GENMASK(__high, __low) + \ |
172 |
| - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ |
173 |
| - __is_constexpr(__low) && \ |
174 |
| - ((__low) < 0 || (__high) > 15 || (__low) > (__high))))) |
175 | 89 |
|
176 | 90 | /**
|
177 | 91 | * REG_FIELD_PREP16() - Prepare a u16 bitfield value
|
|
0 commit comments