Use FIELD_GET() to access the individual fields of the ECR register. Link: https://lore.kernel.org/all/20231005-at91_can-rx_offload-v2-5-9987d53600e0@xxxxxxxxxxxxxx Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> --- drivers/net/can/at91_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index 79eb78b9f8ae..7597da543348 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -72,6 +72,9 @@ enum at91_reg { #define AT91_BR_BRP_MASK GENMASK(22, 16) #define AT91_BR_SMP BIT(24) +#define AT91_ECR_REC_MASK GENMASK(8, 0) +#define AT91_ECR_TEC_MASK GENMASK(23, 16) + #define AT91_MMR_PRIO_SHIFT (16) #define AT91_MID_MIDE BIT(29) @@ -385,8 +388,8 @@ static int at91_get_berr_counter(const struct net_device *dev, const struct at91_priv *priv = netdev_priv(dev); u32 reg_ecr = at91_read(priv, AT91_ECR); - bec->rxerr = reg_ecr & 0xff; - bec->txerr = reg_ecr >> 16; + bec->rxerr = FIELD_GET(AT91_ECR_REC_MASK, reg_ecr); + bec->txerr = FIELD_GET(AT91_ECR_TEC_MASK, reg_ecr); return 0; } -- 2.40.1