Re: [PATCH v3 16/20] PCI: rockchip: Switch to FIELD_PREP_WM16* macros

Heiko Stuebner
2025-08-27T07:57:38Z

Am Montag, 25. August 2025, 10:28:36 Mitteleuropäische Sommerzeit schrieb Nicolas Frattaroli:
> The era of hand-rolled HIWORD_UPDATE macros is over, at least for those
> drivers that use constant masks.
>
> The Rockchip PCI driver, like many other Rockchip drivers, has its very
> own definition of HIWORD_UPDATE.
>
> Remove it, and replace its usage with either FIELD_PREP_WM16, or two new
> header local macros for setting/clearing a bit with the high mask, which
> use FIELD_PREP_WM16_CONST internally. In the process, ENCODE_LANES
> needed to be adjusted, as FIELD_PREP_WM16* shifts the value for us.
>
> That this is equivalent was verified by first making all FIELD_PREP_WM16
> instances FIELD_PREP_WM16_CONST, then doing a static_assert() comparing
> it to the old macro (and for those with parameters, static_asserting for
> the full range of possible values with the old encode macro).
>
> What we get out of this is compile time error checking to make sure the
> value actually fits in the mask, and that the mask fits in the register,
> and also generally less icky code that writes shifted values when it
> actually just meant to set and clear a handful of bits.
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>