Re: [PATCH v7 07/18] can: rcar_canfd: Add rnc_stride variable to struct rcar_canfd_hw_info

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

 



Hi Vincent,

On Fri, 28 Mar 2025 at 11:36, Vincent Mailhol
<mailhol.vincent@xxxxxxxxxx> wrote:
> On 26/03/2025 at 21:19, Biju Das wrote:
> > R-Car Gen4 packs 2 RNC values in a 32-bit word, whereas R-Car Gen3 packs
> > up to 4 values in a 32-bit word. Handle this difference by adding
> > rnc_stride variable to struct rcar_canfd_hw_info and update the macro
> > RCANFD_GAFLCFG.
> >
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> > Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> > ---
> > v6->v7:
> >  * Collected tag.
> > v5->v6:
> >  * Replaced RCANFD_RNC_PER_REG macro with rnc_stride variable.
> >  * Updated commit description
> >  * Dropped Rb tag.
> > v5:
> >  * New patch.
> > ---
> >  drivers/net/can/rcar/rcar_canfd.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> > index 32d700962d69..0001c8043c25 100644
> > --- a/drivers/net/can/rcar/rcar_canfd.c
> > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > @@ -291,7 +291,7 @@
> >  /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */
> >  #define RCANFD_GAFLECTR                      (0x0098)
> >  /* RSCFDnCFDGAFLCFG / RSCFDnGAFLCFG */
> > -#define RCANFD_GAFLCFG(ch)           (0x009c + (0x04 * ((ch) / 2)))
> > +#define RCANFD_GAFLCFG(gpriv, ch)    (0x009c + (0x04 * ((ch) / (gpriv)->info->rnc_stride)))
>
> I find it rather hard to follow the logic here. Your are multiplying by
> four and then dividing again to get the good results. Here, I guess that
> 0x04 represents sizeof(u32), but this needs some thinking to figure that
> out.

The division is done first...

> Wouldn't it be more intuitive to instead store the size in bytes of the
> RNC value?
>
> #define RCANFD_GAFLCFG(gpriv, ch) \
>         (0x009c + (gpriv)->info->sizeof_rnc * (ch))
>
> This way, no more 0x04 magic number and it is easier to process a
> multiplication than a division in your head when reading the code.

... so this is not equivalent.

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