diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2023-04-18 16:35:54 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2023-10-05 21:45:41 +0200 |
commit | 90aa9a250cf2def73e890177867155f6ce956912 (patch) | |
tree | ee71fc7377655471fb6f17266be1a5df7c92e858 /drivers/net | |
parent | 53558ac133c0a8d4fd4c81d6c7885dacd3cca557 (diff) | |
download | linux-90aa9a250cf2def73e890177867155f6ce956912.tar.gz linux-90aa9a250cf2def73e890177867155f6ce956912.tar.bz2 linux-90aa9a250cf2def73e890177867155f6ce956912.zip |
can: at91_can: MID registers: convert access to FIELD_PREP(), FIELD_GET()
Use FIELD_PREP() and FIELD_GET() to access the individual fields of
the MID register.
Link: https://lore.kernel.org/all/20231005-at91_can-rx_offload-v2-7-9987d53600e0@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/can/at91_can.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index 16a62f649418..ec028fe833f0 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -79,6 +79,8 @@ enum at91_reg { #define AT91_MMR_PRIOR_MASK GENMASK(19, 16) #define AT91_MMR_MOT_MASK GENMASK(26, 24) +#define AT91_MID_MIDVB_MASK GENMASK(17, 0) +#define AT91_MID_MIDVA_MASK GENMASK(28, 18) #define AT91_MID_MIDE BIT(29) #define AT91_MSR_MRTR BIT(20) @@ -320,9 +322,10 @@ static inline u32 at91_can_id_to_reg_mid(canid_t can_id) u32 reg_mid; if (can_id & CAN_EFF_FLAG) - reg_mid = (can_id & CAN_EFF_MASK) | AT91_MID_MIDE; + reg_mid = FIELD_PREP(AT91_MID_MIDVA_MASK | AT91_MID_MIDVB_MASK, can_id) | + AT91_MID_MIDE; else - reg_mid = (can_id & CAN_SFF_MASK) << 18; + reg_mid = FIELD_PREP(AT91_MID_MIDVA_MASK, can_id); return reg_mid; } @@ -590,9 +593,10 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb, reg_mid = at91_read(priv, AT91_MID(mb)); if (reg_mid & AT91_MID_MIDE) - cf->can_id = ((reg_mid >> 0) & CAN_EFF_MASK) | CAN_EFF_FLAG; + cf->can_id = FIELD_GET(AT91_MID_MIDVA_MASK | AT91_MID_MIDVB_MASK, reg_mid) | + CAN_EFF_FLAG; else - cf->can_id = (reg_mid >> 18) & CAN_SFF_MASK; + cf->can_id = FIELD_GET(AT91_MID_MIDVA_MASK, reg_mid); reg_msr = at91_read(priv, AT91_MSR(mb)); cf->len = can_cc_dlc2len((reg_msr >> 16) & 0xf); |