linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] Add support for CAN_CTRLMODE_CC_LEN8_DLC to esd_usb2
@ 2020-11-16 18:44 Stefan Mätje
  2020-11-16 18:44 ` [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter Stefan Mätje
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Mätje @ 2020-11-16 18:44 UTC (permalink / raw)
  To: socketcan, linux-can; +Cc: mkl, mailhol.vincent, Stefan Mätje

From: Stefan Mätje <Stefan.Maetje@esd.eu>

Hi Oliver,

here is my patch to add support for CAN_CTRLMODE_CC_LEN8_DLC to the esd_usb2
driver. I have tested it with both supported devices the CAN-USB/2 and the
CAN-USB/Micro.

The patch is based on Marc's 'testing' branch of linux-can-next. I cloned it from
here:
https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=testing

Btw. is there a simple way to read out the supported control modes of the
device (perhaps an ioctl())? The libsocketcan (at least the version 0.0.10) that
I have here on my system does only support to get/set the current control mode
and not the supported control modes.

Best regards,
Stefan

PS: I cloned the wording for the patch subject and comment shameless from your 
patch for the other device drivers.

Stefan Mätje (1):
  can: drivers: add len8_dlc support for esd_usb2 CAN adapter

 drivers/net/can/usb/esd_usb2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter
  2020-11-16 18:44 [PATCH 0/1] Add support for CAN_CTRLMODE_CC_LEN8_DLC to esd_usb2 Stefan Mätje
@ 2020-11-16 18:44 ` Stefan Mätje
  2020-11-17  7:54   ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Mätje @ 2020-11-16 18:44 UTC (permalink / raw)
  To: socketcan, linux-can; +Cc: mkl, mailhol.vincent, Stefan Mätje

From: Stefan Mätje <Stefan.Maetje@esd.eu>

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>
---
 drivers/net/can/usb/esd_usb2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 3643a8ee03cf..cf89387de166 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -183,7 +183,7 @@ struct esd_usb2_net_priv;
 struct esd_tx_urb_context {
 	struct esd_usb2_net_priv *priv;
 	u32 echo_index;
-	int dlc;
+	int len;	/* CAN payload length */
 };
 
 struct esd_usb2 {
@@ -321,7 +321,7 @@ static void esd_usb2_rx_can_msg(struct esd_usb2_net_priv *priv,
 		}
 
 		cf->can_id = id & ESD_IDMASK;
-		cf->len = can_cc_dlc2len(msg->msg.rx.dlc & ~ESD_RTR);
+		can_frame_set_cc_len(cf, msg->msg.rx.dlc & ~ESD_RTR, priv->can.ctrlmode);
 
 		if (id & ESD_EXTID)
 			cf->can_id |= CAN_EFF_FLAG;
@@ -355,7 +355,7 @@ static void esd_usb2_tx_done_msg(struct esd_usb2_net_priv *priv,
 
 	if (!msg->msg.txdone.status) {
 		stats->tx_packets++;
-		stats->tx_bytes += context->dlc;
+		stats->tx_bytes += context->len;
 		can_get_echo_skb(netdev, context->echo_index);
 	} else {
 		stats->tx_errors++;
@@ -737,7 +737,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
 	msg->msg.hdr.len = 3; /* minimal length */
 	msg->msg.hdr.cmd = CMD_CAN_TX;
 	msg->msg.tx.net = priv->index;
-	msg->msg.tx.dlc = cf->len;
+	msg->msg.tx.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode);
 	msg->msg.tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK);
 
 	if (cf->can_id & CAN_RTR_FLAG)
@@ -769,7 +769,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
 
 	context->priv = priv;
 	context->echo_index = i;
-	context->dlc = cf->len;
+	context->len = cf->len;
 
 	/* hnd must not be 0 - MSB is stripped in txdone handling */
 	msg->msg.tx.hnd = 0x80000000 | i; /* returned in TX done message */
@@ -988,7 +988,7 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index)
 	priv->index = index;
 
 	priv->can.state = CAN_STATE_STOPPED;
-	priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY;
+	priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_CC_LEN8_DLC;
 
 	if (le16_to_cpu(dev->udev->descriptor.idProduct) ==
 	    USB_CANUSBM_PRODUCT_ID)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter
  2020-11-16 18:44 ` [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter Stefan Mätje
@ 2020-11-17  7:54   ` Marc Kleine-Budde
  2020-11-17 13:14     ` Stefan Mätje
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2020-11-17  7:54 UTC (permalink / raw)
  To: Stefan Mätje, socketcan, linux-can; +Cc: mailhol.vincent


[-- Attachment #1.1: Type: text/plain, Size: 802 bytes --]

On 11/16/20 7:44 PM, Stefan Mätje wrote:
> From: Stefan Mätje <Stefan.Maetje@esd.eu>
> 
> 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>

I've re-wrapped some long lines and applied to linux-can-next/testing.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter
  2020-11-17  7:54   ` Marc Kleine-Budde
@ 2020-11-17 13:14     ` Stefan Mätje
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Mätje @ 2020-11-17 13:14 UTC (permalink / raw)
  To: linux-can, mkl

Am Dienstag, den 17.11.2020, 08:54 +0100 schrieb Marc Kleine-Budde:
> On 11/16/20 7:44 PM, Stefan Mätje wrote:
> > From: Stefan Mätje <Stefan.Maetje@esd.eu>
> > 
> > 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>
> 
> I've re-wrapped some long lines and applied to linux-can-next/testing.
> 
> Thanks,
> Marc
> 
Thank you for reformatting the patch and integration to the upstream path.

Best regards,
    Stefan

------------------------------------------------------------------------
Dipl.-Ing. Stefan Mätje
System Design

esd electronics gmbh
Vahrenwalder Str. 207 - 30165 Hannover - GERMANY
Phone: +49-511-37298-146 - Fax: +49-511-37298-68
Email: Stefan.Maetje@esd.eu
Please visit our homepage https://www.esd.eu
Quality Products - Made in Germany
------------------------------------------------------------------------
Geschäftsführer: Klaus Detering
Amtsgericht Hannover HRB 51373 - VAT-ID DE 115672832
------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-17 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 18:44 [PATCH 0/1] Add support for CAN_CTRLMODE_CC_LEN8_DLC to esd_usb2 Stefan Mätje
2020-11-16 18:44 ` [PATCH 1/1] can: drivers: add len8_dlc support for esd_usb2 CAN adapter Stefan Mätje
2020-11-17  7:54   ` Marc Kleine-Budde
2020-11-17 13:14     ` Stefan Mätje

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).