lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <20231005195812.549776-15-mkl@pengutronix.de> Date: Thu, 5 Oct 2023 21:57:49 +0200 From: Marc Kleine-Budde <mkl@...gutronix.de> To: netdev@...r.kernel.org Cc: davem@...emloft.net, kuba@...nel.org, linux-can@...r.kernel.org, kernel@...gutronix.de, Marc Kleine-Budde <mkl@...gutronix.de> Subject: [PATCH net-next 14/37] can: at91_can: BR register: convert to FIELD_PREP() Use FIELD_PREP() to access the individual fields of the BR register. Link: https://lore.kernel.org/all/20231005-at91_can-rx_offload-v2-4-9987d53600e0@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@...gutronix.de> --- drivers/net/can/at91_can.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index 966980d4b5dd..79eb78b9f8ae 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -6,6 +6,7 @@ * (C) 2008, 2009, 2010, 2011 by Marc Kleine-Budde <kernel@...gutronix.de> */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/errno.h> #include <linux/ethtool.h> @@ -64,6 +65,13 @@ enum at91_reg { #define AT91_SR_RBSY BIT(29) +#define AT91_BR_PHASE2_MASK GENMASK(2, 0) +#define AT91_BR_PHASE1_MASK GENMASK(6, 4) +#define AT91_BR_PROPAG_MASK GENMASK(10, 8) +#define AT91_BR_SJW_MASK GENMASK(13, 12) +#define AT91_BR_BRP_MASK GENMASK(22, 16) +#define AT91_BR_SMP BIT(24) + #define AT91_MMR_PRIO_SHIFT (16) #define AT91_MID_MIDE BIT(29) @@ -353,12 +361,16 @@ static int at91_set_bittiming(struct net_device *dev) { const struct at91_priv *priv = netdev_priv(dev); const struct can_bittiming *bt = &priv->can.bittiming; - u32 reg_br; + u32 reg_br = 0; - reg_br = ((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 << 24 : 0) | - ((bt->brp - 1) << 16) | ((bt->sjw - 1) << 12) | - ((bt->prop_seg - 1) << 8) | ((bt->phase_seg1 - 1) << 4) | - ((bt->phase_seg2 - 1) << 0); + if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) + reg_br |= AT91_BR_SMP; + + reg_br |= FIELD_PREP(AT91_BR_BRP_MASK, bt->brp - 1) | + FIELD_PREP(AT91_BR_SJW_MASK, bt->sjw - 1) | + FIELD_PREP(AT91_BR_PROPAG_MASK, bt->prop_seg - 1) | + FIELD_PREP(AT91_BR_PHASE1_MASK, bt->phase_seg1 - 1) | + FIELD_PREP(AT91_BR_PHASE2_MASK, bt->phase_seg2 - 1); netdev_info(dev, "writing AT91_BR: 0x%08x\n", reg_br); -- 2.40.1
Powered by blists - more mailing lists