mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
	linux-can@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Biju Das <biju.das.au@gmail.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>
Subject: Re: [PATCH 4/4] can: rcar_canfd: Replace RCANFD_CFG_* macros with FIELD_PREP
Date: Fri, 4 Jul 2025 11:24:49 +0900	[thread overview]
Message-ID: <dc6d1cdf-0c93-4d7a-b3c4-722d1e58f5cf@wanadoo.fr> (raw)
In-Reply-To: <20250703183411.332828-5-biju.das.jz@bp.renesas.com>

Hi Biju,

On 04/07/2025 at 03:34, Biju Das wrote:
> Replace RCANFD_CFG_* macros with simpler FIELD_PREP macro.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/net/can/rcar/rcar_canfd.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index b5b059e83374..dd87b4e8e688 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -102,12 +102,6 @@
>  
>  /* Channel register bits */
>  
> -/* RSCFDnCmCFG - Classical CAN only */
> -#define RCANFD_CFG_SJW(x)		(((x) & 0x3) << 24)
> -#define RCANFD_CFG_TSEG2(x)		(((x) & 0x7) << 20)
> -#define RCANFD_CFG_TSEG1(x)		(((x) & 0xf) << 16)
> -#define RCANFD_CFG_BRP(x)		(((x) & 0x3ff) << 0)
> -
>  /* RSCFDnCFDCmCTR / RSCFDnCmCTR */
>  #define RCANFD_CCTR_CTME		BIT(24)
>  #define RCANFD_CCTR_ERRD		BIT(23)
> @@ -1418,8 +1412,8 @@ static void rcar_canfd_set_bittiming(struct net_device *ndev)
>  	if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || gpriv->info->shared_can_regs) {
>  		cfg = rcar_canfd_compute_nominal_bit_rate_cfg(gpriv->info, tseg1, brp, sjw, tseg2);
>  	} else {
> -		cfg = (RCANFD_CFG_TSEG1(tseg1) | RCANFD_CFG_BRP(brp) |
> -		       RCANFD_CFG_SJW(sjw) | RCANFD_CFG_TSEG2(tseg2));
> +		cfg = FIELD_PREP(GENMASK(19, 16), tseg1) | FIELD_PREP(GENMASK(9, 0), brp) |
> +		      FIELD_PREP(GENMASK(25, 24), sjw) | FIELD_PREP(GENMASK(22, 20), tseg2);
>  	}

You can still keep the macro definition to give a meaning to the magic number:

  #define RCANFD_CFG_SJW_MASK GENMASK(25, 24)

and do a:

  FIELD_PREP(RCANFD_CFG_SJW_MASK, sjw)

(same for the other fields).

>  	rcar_canfd_write(priv->base, RCANFD_CCFG(ch), cfg);


Yours sincerely,
Vincent Mailhol


  reply	other threads:[~2025-07-04  2:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 18:33 [PATCH 0/4] R-Car CANFD Improvements Biju Das
2025-07-03 18:33 ` [PATCH 1/4] can: rcar_canfd: Add shared_bittiming variable to struct rcar_canfd_hw_info Biju Das
2025-07-03 18:34 ` [PATCH 2/4] can: rcar_canfd: Drop unused macros Biju Das
2025-07-03 18:34 ` [PATCH 3/4] can: rcar_canfd: Replace RCANFD_NCFG_* and RCANFD_DCFG_* macros Biju Das
2025-07-03 18:34 ` [PATCH 4/4] can: rcar_canfd: Replace RCANFD_CFG_* macros with FIELD_PREP Biju Das
2025-07-04  2:24   ` Vincent Mailhol [this message]
2025-07-04 10:12     ` Biju Das
2025-07-04 15:37       ` Vincent Mailhol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc6d1cdf-0c93-4d7a-b3c4-722d1e58f5cf@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=biju.das.au@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mkl@pengutronix.de \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®