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 Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Sent: 14 March 2025 14:48
> Subject: Re: [PATCH v4 08/11] can: rcar_canfd: Add shift table to struct rcar_canfd_hw_info
> 
> 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 ;-)

What about ((32  - (n + 1)* field_width) ?
 
{24,16,8} for n = {0, 1, 2}

And 

{16,0} for n = {0, 1}

Cheers,
Biju




[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