Re: [PATCH v4 08/11] can: rcar_canfd: Add shift table to struct rcar_canfd_hw_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Biju,

Thanks for your patch!

On Thu, 6 Mar 2025 at 13:43, Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> R-Car Gen3 and Gen4 has some differences in the shift bits. Add a

have

> shift table to handle these differences. After this drop the unused
> functions reg_gen4() and is_gen4().
>
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

A suggestion for improvement below.

> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -90,11 +90,13 @@
>  /* RSCFDnCFDGAFLCFG0 / RSCFDnGAFLCFG0 */
>  #define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \
>         (((x) & (gpriv)->info->mask_table[RCANFD_RNC_MASK]) << \
> -        (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8)))
> +        ((gpriv)->info->shift_table[RCANFD_FIRST_RNC_SH] - ((n) & 1) * \
> +         (gpriv)->info->shift_table[RCANFD_SECOND_RNC_SH]))

Both shifts 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.
The odd split in two shifts is due to the MSB-first numbering of
the fields.  Hence I think it would be better to use a field width
parameter, and derive the proper shift value from that (like you have
already done for ICU ;-)

Note that the formula will have to be reworked anyway to support the
third channel on R-Car V3H_2, as "n & "1 will no longer fly here...

>  #define RCANFD_GAFLCFG_GETRNC(gpriv, n, x) \
> -       (((x) >> (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) & \
> -        (gpriv)->info->mask_table[RCANFD_RNC_MASK])
> +       (((x) >> ((gpriv)->info->shift_table[RCANFD_FIRST_RNC_SH] - ((n) & 1) * \
> +                 (gpriv)->info->shift_table[RCANFD_SECOND_RNC_SH])) & \
> +                 (gpriv)->info->mask_table[RCANFD_RNC_MASK])

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux