Commit 46ee8152 authored by Maxime Ripard's avatar Maxime Ripard

drm/vc4: Convert register accessors to FIELD_*

The VC4_SET_FIELD and VC4_GET_FIELD are reimplementing most of the logic
already defined in FIELD_SET and FIELD_GET. Let's convert the vc4 macros to
use the FIELD_* macros.
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20200703135713.985810-1-maxime@cerno.tech
parent 9ac2b637
...@@ -6,19 +6,18 @@ ...@@ -6,19 +6,18 @@
#ifndef VC4_REGS_H #ifndef VC4_REGS_H
#define VC4_REGS_H #define VC4_REGS_H
#include <linux/bitfield.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#define VC4_MASK(high, low) ((u32)GENMASK(high, low)) #define VC4_MASK(high, low) ((u32)GENMASK(high, low))
/* Using the GNU statement expression extension */ /* Using the GNU statement expression extension */
#define VC4_SET_FIELD(value, field) \ #define VC4_SET_FIELD(value, field) \
({ \ ({ \
uint32_t fieldval = (value) << field##_SHIFT; \ WARN_ON(!FIELD_FIT(field##_MASK, value)); \
WARN_ON((fieldval & ~field##_MASK) != 0); \ FIELD_PREP(field##_MASK, value); \
fieldval & field##_MASK; \
}) })
#define VC4_GET_FIELD(word, field) (((word) & field##_MASK) >> \ #define VC4_GET_FIELD(word, field) FIELD_GET(field##_MASK, word)
field##_SHIFT)
#define V3D_IDENT0 0x00000 #define V3D_IDENT0 0x00000
# define V3D_EXPECTED_IDENT0 \ # define V3D_EXPECTED_IDENT0 \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment