can: dev: __can_get_echo_skb(): replace struct can_frame by canfd_frame to access...
authorMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 31 Oct 2018 10:08:21 +0000 (11:08 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 9 Nov 2018 16:20:40 +0000 (17:20 +0100)
This patch replaces the use of "struct can_frame::can_dlc" by "struct
canfd_frame::len" to access the frame's length. As it is ensured that
both structures have a compatible memory layout for this member this is
no functional change. Futher, this compatibility is documented in a
comment.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/dev.c

index 80530ab37b1e3d7e5a0848f78753d9986d25832f..46cc5fec4043d9a8e93699d0ac487699aad6c27f 100644 (file)
@@ -484,11 +484,14 @@ struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8
        BUG_ON(idx >= priv->echo_skb_max);
 
        if (priv->echo_skb[idx]) {
+               /* Using "struct canfd_frame::len" for the frame
+                * length is supported on both CAN and CANFD frames.
+                */
                struct sk_buff *skb = priv->echo_skb[idx];
-               struct can_frame *cf = (struct can_frame *)skb->data;
-               u8 dlc = cf->can_dlc;
+               struct canfd_frame *cf = (struct canfd_frame *)skb->data;
+               u8 len = cf->len;
 
-               *len_ptr = dlc;
+               *len_ptr = len;
                priv->echo_skb[idx] = NULL;
 
                return skb;