The shift values in RCANFD_GAFLCFG_SETRNC are dictated by the field width: - R-Car Gen4 packs 2 values in a 32-bit word, using a field width of 16 bits, - R-Car Gen3 packs up to 4 values in a 32-bit word, using a field width of 8 bits. By using a formula (32 - (n % rnc_per_reg + 1) * field_width) we can simplify the shift value in RCANFD_GAFLCFG_SETRNC macro. Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx> --- v5: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 924a116cd9ab..214ae7716f4d 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -90,7 +90,7 @@ /* RSCFDnCFDGAFLCFG0 / RSCFDnGAFLCFG0 */ #define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \ (((x) & ((gpriv)->info->num_supported_rules - 1)) << \ - (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) + (32 - (((n) % RCANFD_RNC_PER_REG(gpriv) + 1) * (gpriv)->info->rnc_field_width))) /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) -- 2.43.0