[PATCH 04/20] media: synopsys: hdmirx: replace macros with bitfield variants

Nicolas Frattaroli
2025-06-12T18:58:17Z

The era of hand-rolled HIWORD_UPDATE macros is over, at least for those
drivers that use constant masks.

Replace the UPDATE macro with bitfield.h's FIELD_PREP, to give us
additional error checking.

Also, replace the HIWORD_UPDATE macro at the same time with bitfield.h's
new HWORD_UPDATE macro, which also gives us additional error checking.

The UPDATE/HIWORD_UPDATE macros are left as wrappers around the
bitfield.h macros, in order to not rock the boat too much, and keep the
changes easy to review.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h
index 220ab99ca61152b36b0a08b398ddefdb985709a5..cd5250e282a5c9de9a75ea73f26496ed53766dff 100644
--- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h
+++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h
@@ -8,10 +8,11 @@
#ifndef DW_HDMIRX_H
#define DW_HDMIRX_H

+#include <linux/bitfield.h>
#include <linux/bitops.h>

-#define UPDATE(x, h, l) (((x) << (l)) & GENMASK((h), (l)))
-#define HIWORD_UPDATE(v, h, l) (((v) << (l)) | (GENMASK((h), (l)) << 16))
+#define UPDATE(x, h, l) (FIELD_PREP(GENMASK((h), (l)), (x)))
+#define HIWORD_UPDATE(v, h, l) (HWORD_UPDATE(GENMASK((h), (l)), (v)))

/* SYS_GRF */
#define SYS_GRF_SOC_CON1 0x0304

--
2.49.0