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

net: stmmac: dwmac-rk: switch to FIELD_PREP_WM16 macro

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

Like many other Rockchip drivers, dwmac-rk has its own HIWORD_UPDATE
macro. Its semantics allow us to redefine it as a wrapper to the shared
hw_bitfield.h FIELD_PREP_WM16 macros though.

Replace the implementation of this driver's very own HIWORD_UPDATE macro
with an instance of FIELD_PREP_WM16 from hw_bitfield.h. This keeps the
diff easily reviewable, while giving us more compile-time error
checking.

The related GRF_BIT macro is left alone for now; any attempt to rework
the code to not use its own solution here would likely end up harder to
review and less pretty for the time being.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
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
a785472b 3d1ef6e4

+2 -1
+2 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
··· 8 8 */ 9 9 10 10 #include <linux/stmmac.h> 11 + #include <linux/hw_bitfield.h> 11 12 #include <linux/bitops.h> 12 13 #include <linux/clk.h> 13 14 #include <linux/phy.h> ··· 151 150 } 152 151 153 152 #define HIWORD_UPDATE(val, mask, shift) \ 154 - ((val) << (shift) | (mask) << ((shift) + 16)) 153 + (FIELD_PREP_WM16((mask) << (shift), (val))) 155 154 156 155 #define GRF_BIT(nr) (BIT(nr) | BIT(nr+16)) 157 156 #define GRF_CLR_BIT(nr) (BIT(nr+16))