From 69d98969a0540039fc04e0f22bbe9f41b0a13d66 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Tue, 10 Nov 2020 11:18:46 +0100 Subject: can: rename get_can_dlc() macro with can_cc_dlc2len() The get_can_dlc() macro is used to ensure the payload length information of the Classical CAN frame to be max 8 bytes (the CAN_MAX_DLEN). Rename the macro and use the correct constant in preparation of the len/dlc cleanup for Classical CAN frames. Signed-off-by: Oliver Hartkopp Link: https://lore.kernel.org/r/20201110101852.1973-3-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde --- drivers/net/can/at91_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/can/at91_can.c') diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index c14de95d2ca7..db06254f8eb7 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -580,7 +580,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb, cf->can_id = (reg_mid >> 18) & CAN_SFF_MASK; reg_msr = at91_read(priv, AT91_MSR(mb)); - cf->can_dlc = get_can_dlc((reg_msr >> 16) & 0xf); + cf->can_dlc = can_cc_dlc2len((reg_msr >> 16) & 0xf); if (reg_msr & AT91_MSR_MRTR) cf->can_id |= CAN_RTR_FLAG; -- cgit v1.2.3 From c7b74967799b1af52b3045d69d4c26836b2d41de Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Fri, 20 Nov 2020 11:04:44 +0100 Subject: can: replace can_dlc as variable/element for payload length The naming of can_dlc as element of struct can_frame and also as variable name is misleading as it claims to be a 'data length CODE' but in reality it always was a plain data length. With the indroduction of a new 'len' element in struct can_frame we can now remove can_dlc as name and make clear which of the former uses was a plain length (-> 'len') or a data length code (-> 'dlc') value. Signed-off-by: Oliver Hartkopp Link: https://lore.kernel.org/r/20201120100444.3199-1-socketcan@hartkopp.net [mkl: gs_usb: keep struct gs_host_frame::can_dlc as is] Signed-off-by: Marc Kleine-Budde --- drivers/net/can/at91_can.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/net/can/at91_can.c') diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index db06254f8eb7..5284f0ab3b06 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -468,7 +468,7 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev) } reg_mid = at91_can_id_to_reg_mid(cf->can_id); reg_mcr = ((cf->can_id & CAN_RTR_FLAG) ? AT91_MCR_MRTR : 0) | - (cf->can_dlc << 16) | AT91_MCR_MTCR; + (cf->len << 16) | AT91_MCR_MTCR; /* disable MB while writing ID (see datasheet) */ set_mb_mode(priv, mb, AT91_MB_MODE_DISABLED); @@ -481,7 +481,7 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev) /* This triggers transmission */ at91_write(priv, AT91_MCR(mb), reg_mcr); - stats->tx_bytes += cf->can_dlc; + stats->tx_bytes += cf->len; /* _NOTE_: subtract AT91_MB_TX_FIRST offset from mb! */ can_put_echo_skb(skb, dev, mb - get_mb_tx_first(priv)); @@ -554,7 +554,7 @@ static void at91_rx_overflow_err(struct net_device *dev) cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; stats->rx_packets++; - stats->rx_bytes += cf->can_dlc; + stats->rx_bytes += cf->len; netif_receive_skb(skb); } @@ -580,7 +580,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb, cf->can_id = (reg_mid >> 18) & CAN_SFF_MASK; reg_msr = at91_read(priv, AT91_MSR(mb)); - cf->can_dlc = can_cc_dlc2len((reg_msr >> 16) & 0xf); + cf->len = can_cc_dlc2len((reg_msr >> 16) & 0xf); if (reg_msr & AT91_MSR_MRTR) cf->can_id |= CAN_RTR_FLAG; @@ -619,7 +619,7 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb) at91_read_mb(dev, mb, cf); stats->rx_packets++; - stats->rx_bytes += cf->can_dlc; + stats->rx_bytes += cf->len; netif_receive_skb(skb); can_led_event(dev, CAN_LED_EVENT_RX); @@ -780,7 +780,7 @@ static int at91_poll_err(struct net_device *dev, int quota, u32 reg_sr) at91_poll_err_frame(dev, cf, reg_sr); dev->stats.rx_packets++; - dev->stats.rx_bytes += cf->can_dlc; + dev->stats.rx_bytes += cf->len; netif_receive_skb(skb); return 1; @@ -1047,7 +1047,7 @@ static void at91_irq_err(struct net_device *dev) at91_irq_err_state(dev, cf, new_state); dev->stats.rx_packets++; - dev->stats.rx_bytes += cf->can_dlc; + dev->stats.rx_bytes += cf->len; netif_rx(skb); priv->can.state = new_state; -- cgit v1.2.3