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,

On Sat, 15 Mar 2025 at 18:31, Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> > From: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> > 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
> > > 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...
>
> Agreed. Will introduce rnc_field_width variable in struct rcar_canfd_hw_info and
> Simplify the calculation using the formula (32 - (n + 1) * rnc_field_width).
> Which will work for third channel on R-Car V3H_2 as well.

Note that you still need to mask n, as n can be up to 7 (on R-Car V4H),
while the register holds only 2 or 4 values.

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]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux