Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
them to implement the i915/xe specific macros. Converting each driver
to use the generic macros are left for later, when/if other
driver-specific macros are also generalized.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Yury Norov <yury.norov@gmail.com>

authored by

Lucas De Marchi and committed by
Yury Norov
4fd225f7 5b572e8a

+11 -97
+11 -97
drivers/gpu/drm/i915/i915_reg_defs.h
··· 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. 12 + /* 13 + * Wrappers over the generic fixed width BIT_U*() and GENMASK_U*() 14 + * implementations, for compatibility reasons with previous implementation. 19 15 */ 20 - #define REG_BIT(__n) \ 21 - ((u32)(BIT(__n) + \ 22 - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ 23 - ((__n) < 0 || (__n) > 31)))) 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) 24 20 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. 61 - */ 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))))) 67 - 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(). ··· 86 143 */ 87 144 #define REG_FIELD_GET64(__mask, __val) ((u64)FIELD_GET(__mask, __val)) 88 145 89 - /** 90 - * REG_BIT16() - Prepare a u16 bit value 91 - * @__n: 0-based bit number 92 - * 93 - * Local wrapper for BIT() to force u16, with compile time 94 - * checks. 95 - * 96 - * @return: Value with bit @__n set. 97 - */ 98 - #define REG_BIT16(__n) \ 99 - ((u16)(BIT(__n) + \ 100 - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ 101 - ((__n) < 0 || (__n) > 15)))) 102 - 103 - /** 104 - * REG_GENMASK16() - Prepare a continuous u8 bitmask 105 - * @__high: 0-based high bit 106 - * @__low: 0-based low bit 107 - * 108 - * Local wrapper for GENMASK() to force u16, with compile time 109 - * checks. 110 - * 111 - * @return: Continuous bitmask from @__high to @__low, inclusive. 112 - */ 113 - #define REG_GENMASK16(__high, __low) \ 114 - ((u16)(GENMASK(__high, __low) + \ 115 - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ 116 - __is_constexpr(__low) && \ 117 - ((__low) < 0 || (__high) > 15 || (__low) > (__high))))) 118 146 119 147 /** 120 148 * REG_FIELD_PREP16() - Prepare a u16 bitfield value