Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: drivers: add len8_dlc support for esd_usb2 CAN adapter

Support the Classical CAN raw DLC functionality to send and receive DLC values
from 9 .. 15 for the Classical CAN capable CAN network driver esd_usb that
supports the esd CAN-USB/2 and CAN-USB/Micro devices:

- esd_usb2

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Tested-by: Stefan Mätje <stefan.maetje@esd.eu>
Link: https://lore.kernel.org/r/20201116184430.25462-2-stefan.maetje@esd.eu
[mkl: rewrapped some long lines]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Stefan Mätje and committed by
Marc Kleine-Budde
396b3ced 4c01fc87

+8 -6
+8 -6
drivers/net/can/usb/esd_usb2.c
··· 183 183 struct esd_tx_urb_context { 184 184 struct esd_usb2_net_priv *priv; 185 185 u32 echo_index; 186 - int dlc; 186 + int len; /* CAN payload length */ 187 187 }; 188 188 189 189 struct esd_usb2 { ··· 321 321 } 322 322 323 323 cf->can_id = id & ESD_IDMASK; 324 - cf->len = can_cc_dlc2len(msg->msg.rx.dlc & ~ESD_RTR); 324 + can_frame_set_cc_len(cf, msg->msg.rx.dlc & ~ESD_RTR, 325 + priv->can.ctrlmode); 325 326 326 327 if (id & ESD_EXTID) 327 328 cf->can_id |= CAN_EFF_FLAG; ··· 356 355 357 356 if (!msg->msg.txdone.status) { 358 357 stats->tx_packets++; 359 - stats->tx_bytes += context->dlc; 358 + stats->tx_bytes += context->len; 360 359 can_get_echo_skb(netdev, context->echo_index); 361 360 } else { 362 361 stats->tx_errors++; ··· 738 737 msg->msg.hdr.len = 3; /* minimal length */ 739 738 msg->msg.hdr.cmd = CMD_CAN_TX; 740 739 msg->msg.tx.net = priv->index; 741 - msg->msg.tx.dlc = cf->len; 740 + msg->msg.tx.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode); 742 741 msg->msg.tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK); 743 742 744 743 if (cf->can_id & CAN_RTR_FLAG) ··· 770 769 771 770 context->priv = priv; 772 771 context->echo_index = i; 773 - context->dlc = cf->len; 772 + context->len = cf->len; 774 773 775 774 /* hnd must not be 0 - MSB is stripped in txdone handling */ 776 775 msg->msg.tx.hnd = 0x80000000 | i; /* returned in TX done message */ ··· 989 988 priv->index = index; 990 989 991 990 priv->can.state = CAN_STATE_STOPPED; 992 - priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY; 991 + priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY | 992 + CAN_CTRLMODE_CC_LEN8_DLC; 993 993 994 994 if (le16_to_cpu(dev->udev->descriptor.idProduct) == 995 995 USB_CANUSBM_PRODUCT_ID)