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

media: synopsys: hdmirx: replace macros with bitfield variants

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 the new
FIELD_PREP_WM16 macro in hw_bitfield.h, which also gives us additional
error checking.

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

Yury: drop extra parens around FIELD_PREPs (Dmitry)

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>

authored by

Nicolas Frattaroli and committed by
Yury Norov
7d5f75a9 90fbf6a2

+4 -2
+4 -2
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h
··· 8 8 #ifndef DW_HDMIRX_H 9 9 #define DW_HDMIRX_H 10 10 11 + #include <linux/bitfield.h> 11 12 #include <linux/bitops.h> 13 + #include <linux/hw_bitfield.h> 12 14 13 - #define UPDATE(x, h, l) (((x) << (l)) & GENMASK((h), (l))) 14 - #define HIWORD_UPDATE(v, h, l) (((v) << (l)) | (GENMASK((h), (l)) << 16)) 15 + #define UPDATE(x, h, l) FIELD_PREP(GENMASK((h), (l)), (x)) 16 + #define HIWORD_UPDATE(v, h, l) FIELD_PREP_WM16(GENMASK((h), (l)), (v)) 15 17 16 18 /* SYS_GRF */ 17 19 #define SYS_GRF_SOC_CON1 0x0304