Peter Maydell <[email protected]> writes: > On Tue, 24 Feb 2026 at 15:43, Alex Bennée <[email protected]> wrote: >> >> We can use the registerfields API to safely set the individual fields >> and avoid open coding magic numbers. The EC and IL fields are still >> driven by defines but we could convert them later. >> >> Signed-off-by: Alex Bennée <[email protected]> > >> +FIELD(WFX_ISS, TI, 0, 2) >> +FIELD(WFX_ISS, RV, 14, 1) >> +FIELD(WFX_ISS, RN, 15, 5) >> +FIELD(WFX_ISS, COND, 20, 4) >> +FIELD(WFX_ISS, CV, 24, 1) >> + >> static inline uint32_t syn_wfx(int cv, int cond, int ti, bool is_16bit) >> { >> - return (EC_WFX_TRAP << ARM_EL_EC_SHIFT) | >> - (is_16bit ? 0 : (1 << ARM_EL_IL_SHIFT)) | >> - (cv << 24) | (cond << 20) | ti; >> + uint32_t res = (EC_WFX_TRAP << ARM_EL_EC_SHIFT); >> + >> + res = FIELD_DP32(res, WFX_ISS, CV, cv); >> + res = FIELD_DP32(res, WFX_ISS, COND, cond); >> + res = FIELD_DP32(res, WFX_ISS, TI, ti); >> + >> + if (!is_16bit) { >> + res |= ARM_EL_IL; >> + } >> + return res; >> } > > I'm not hugely enthusiastic about this mostly because it > means we would have one syn_foo function that's written totally > differently to all the rest.
I did consider running through the rest of the file updating with proper field setting but I didn't want to bloat the series. I think it does help with readability compared to open coded constant shifts. > > -- PMM -- Alex Bennée Virtualisation Tech Lead @ Linaro
