summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/vc4/vc4_regs.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/vc4/vc4_regs.h')
-rw-r--r--drivers/gpu/drm/vc4/vc4_regs.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_regs.h b/drivers/gpu/drm/vc4/vc4_regs.h
index b5a6b4cdd332..324462cc9cd4 100644
--- a/drivers/gpu/drm/vc4/vc4_regs.h
+++ b/drivers/gpu/drm/vc4/vc4_regs.h
@@ -6,19 +6,18 @@
#ifndef VC4_REGS_H
#define VC4_REGS_H
+#include <linux/bitfield.h>
#include <linux/bitops.h>
#define VC4_MASK(high, low) ((u32)GENMASK(high, low))
/* Using the GNU statement expression extension */
#define VC4_SET_FIELD(value, field) \
({ \
- uint32_t fieldval = (value) << field##_SHIFT; \
- WARN_ON((fieldval & ~field##_MASK) != 0); \
- fieldval & field##_MASK; \
+ WARN_ON(!FIELD_FIT(field##_MASK, value)); \
+ FIELD_PREP(field##_MASK, value); \
})
-#define VC4_GET_FIELD(word, field) (((word) & field##_MASK) >> \
- field##_SHIFT)
+#define VC4_GET_FIELD(word, field) FIELD_GET(field##_MASK, word)
#define V3D_IDENT0 0x00000
# define V3D_EXPECTED_IDENT0 \