]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/reg_defs: Add REG_FIELD_MAX wrapper for FIELD_MAX()
authorAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Wed, 24 Sep 2025 14:15:39 +0000 (19:45 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Thu, 25 Sep 2025 13:08:19 +0000 (18:38 +0530)
Introduce REG_FIELD_MAX macro as local wrapper around FIELD_MAX() to return
the maximum value representable by a bit mask. The value is cast to u32
for consistency with other REG_* macros and assumes the bitfield fits
within 32 bits.

v2: Use __mask as macro argument aligning with other macros. (Ville)

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20250924141542.3122126-8-ankit.k.nautiyal@intel.com
drivers/gpu/drm/i915/i915_reg_defs.h

index bfe98cb9a03847f9c0046ae097588934f9216858..e81fac8ab51b508136526f7c5d9fcf0240afddbe 100644 (file)
  */
 #define REG_FIELD_GET8(__mask, __val)   ((u8)FIELD_GET(__mask, __val))
 
+/**
+ * REG_FIELD_MAX() - produce the maximum value representable by a field
+ * @__mask: shifted mask defining the field's length and position
+ *
+ * Local wrapper for FIELD_MAX() to return the maximum bit value that can
+ * be held in the field specified by @_mask, cast to u32 for consistency
+ * with other macros.
+ */
+#define REG_FIELD_MAX(__mask)  ((u32)FIELD_MAX(__mask))
+
 typedef struct {
        u32 reg;
 } i915_reg_t;