Skip to contentSkip to conversation

pull-request: can-next 2021-04-13

PATCH New Marc Kleine-Budde 2 participants 16 messages Apr 13, 2021

Subsystems (6)
lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

Hello Jakub, hello David,

this is a pull request of 14 patches for net-next/master.

The first patch is by Yoshihiro Shimoda and updates the DT bindings for the rcar_can driver.

Vincent Mailhol contributes 3 patches that add support for several ETAS USB CAN adapters.

The final 10 patches are by me and clean up the peak_usb CAN driver.

regards,
Marc

---

The following changes since commit 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2:

net: ethernet: ravb: Enable optional refclk (2021-04-12 14:09:59 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-5.13-20210413

for you to fetch changes up to bd573ea5720470d1ea70f3e39fb2e2efad219311:

can: peak_usb: pcan_usb: replace open coded endianness conversion of unaligned data (2021-04-13 10:15:44 +0200)

----------------------------------------------------------------
linux-can-next-for-5.13-20210413

----------------------------------------------------------------
Marc Kleine-Budde (10):
can: peak_usb: fix checkpatch warnings
can: peak_usb: pcan_usb_pro.h: remove double space in indention
can: peak_usb: remove unused variables from struct peak_usb_device
can: peak_usb: remove write only variable struct peak_usb_adapter::ts_period
can: peak_usb: peak_usb_probe(): make use of driver_info
can: peak_usb: pcan_usb_{,pro}_get_device_id(): remove unneeded check for device_id
can: peak_usb: pcan_usb_get_serial(): remove error message from error path
can: peak_usb: pcan_usb_get_serial(): make use of le32_to_cpup()
can: peak_usb: pcan_usb_get_serial(): unconditionally assign serial_number
can: peak_usb: pcan_usb: replace open coded endianness conversion of unaligned data

Vincent Mailhol (3):
can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces
can: etas_es58x: add support for ETAS ES581.4 CAN USB interface
can: etas_es58x: add support for the ETAS ES58X_FD CAN USB interfaces

Yoshihiro Shimoda (1):
dt-bindings: net: can: rcar_can: Document r8a77961 support

 .../devicetree/bindings/net/can/rcar_can.txt       |    5 +-
 drivers/net/can/usb/Kconfig                        |   10 +
 drivers/net/can/usb/Makefile                       |    1 +
 drivers/net/can/usb/etas_es58x/Makefile            |    3 +
 drivers/net/can/usb/etas_es58x/es581_4.c           |  507 +++++
 drivers/net/can/usb/etas_es58x/es581_4.h           |  207 ++
 drivers/net/can/usb/etas_es58x/es58x_core.c        | 2301 ++++++++++++++++++++
 drivers/net/can/usb/etas_es58x/es58x_core.h        |  700 ++++++
 drivers/net/can/usb/etas_es58x/es58x_fd.c          |  562 +++++
 drivers/net/can/usb/etas_es58x/es58x_fd.h          |  243 +++
 drivers/net/can/usb/peak_usb/pcan_usb.c            |   59 +-
 drivers/net/can/usb/peak_usb/pcan_usb_core.c       |   58 +-
 drivers/net/can/usb/peak_usb/pcan_usb_core.h       |    7 +-
 drivers/net/can/usb/peak_usb/pcan_usb_fd.c         |    4 -
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c        |    6 +-
 drivers/net/can/usb/peak_usb/pcan_usb_pro.h        |   76 +-
 16 files changed, 4622 insertions(+), 127 deletions(-)
 create mode 100644 drivers/net/can/usb/etas_es58x/Makefile
 create mode 100644 drivers/net/can/usb/etas_es58x/es581_4.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es581_4.h
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_core.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_core.h
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_fd.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_fd.h
author maintainer
#1 lore raw

PATCH 1/14 dt-bindings: net: can: rcar_can: Document r8a77961 support

From: Yoshihiro Shimoda <[email protected]>

Document SoC specific bindings for R-Car M3-W+ (r8a77961) SoC.

Also as R8A7796 is now called R8A77960 so that update those references.

---
 Documentation/devicetree/bindings/net/can/rcar_can.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/can/rcar_can.txt +3 -2
index 6a5956347816..90ac4fef23f5 100644
@@ -19,7 +19,8 @@ Required properties:
 	      "renesas,can-r8a7793" if CAN controller is a part of R8A7793 SoC.
 	      "renesas,can-r8a7794" if CAN controller is a part of R8A7794 SoC.
 	      "renesas,can-r8a7795" if CAN controller is a part of R8A7795 SoC.
-	      "renesas,can-r8a7796" if CAN controller is a part of R8A7796 SoC.
+	      "renesas,can-r8a7796" if CAN controller is a part of R8A77960 SoC.
+	      "renesas,can-r8a77961" if CAN controller is a part of R8A77961 SoC.
 	      "renesas,can-r8a77965" if CAN controller is a part of R8A77965 SoC.
 	      "renesas,can-r8a77990" if CAN controller is a part of R8A77990 SoC.
 	      "renesas,can-r8a77995" if CAN controller is a part of R8A77995 SoC.
@@ -40,7 +41,7 @@ Required properties:
 - pinctrl-names: must be "default".
 
 Required properties for R8A774A1, R8A774B1, R8A774C0, R8A774E1, R8A7795,
-R8A7796, R8A77965, R8A77990, and R8A77995:
+R8A77960, R8A77961, R8A77965, R8A77990, and R8A77995:
 For the denoted SoCs, "clkp2" can be CANFD clock. This is a div6 clock and can
 be used by both CAN and CAN FD controller at the same time. It needs to be
 scaled to maximum frequency if any of these controllers use it. This is done

base-commit: 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2

Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH 2/14 can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces

In reply to Marc Kleine-Budde

From: Vincent Mailhol <[email protected]>

This patch adds the core support for various USB CAN interfaces from ETAS GmbH (https://www.etas.com/en/products/es58x.php). The next patches add the glue code drivers for the individual interfaces.

---
 drivers/net/can/usb/Kconfig                 |   10 +
 drivers/net/can/usb/Makefile                |    1 +
 drivers/net/can/usb/etas_es58x/Makefile     |    3 +
 drivers/net/can/usb/etas_es58x/es58x_core.c | 2281 +++++++++++++++++++
 drivers/net/can/usb/etas_es58x/es58x_core.h |  693 ++++++
 5 files changed, 2988 insertions(+)
 create mode 100644 drivers/net/can/usb/etas_es58x/Makefile
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_core.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_core.h
drivers/net/can/usb/Kconfig +10 -0
index 538f4d9adb91..3deb9f1cd292 100644
@@ -20,6 +20,16 @@ config CAN_ESD_USB2
 	  This driver supports the CAN-USB/2 interface
 	  from esd electronic system design gmbh (http://www.esd.eu).
 
+config CAN_ETAS_ES58X
+	tristate "ETAS ES58X CAN/USB interfaces"
+	select CRC16
+	help
+	  This driver supports the ES581.4, ES582.1 and ES584.1 interfaces
+	  from ETAS GmbH (https://www.etas.com/en/products/es58x.php).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called etas_es58x.
+
 config CAN_GS_USB
 	tristate "Geschwister Schneider UG interfaces"
 	help
drivers/net/can/usb/Makefile +1 -0
index aa0f17c0b2ed..748cf31a0d53 100644
@@ -6,6 +6,7 @@
 obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
 obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
 obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
+obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x/
 obj-$(CONFIG_CAN_GS_USB) += gs_usb.o
 obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb/
 obj-$(CONFIG_CAN_MCBA_USB) += mcba_usb.o
drivers/net/can/usb/etas_es58x/Makefile new file +3 -0
new file mode 100644
index 000000000000..60a1ac935a69
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o
+etas_es58x-y = es58x_core.o
drivers/net/can/usb/etas_es58x/es58x_core.c new file +2281 -0

2,281 lines not on this page · raw message

drivers/net/can/usb/etas_es58x/es58x_core.h new file +693 -0

693 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#3 lore raw

PATCH 3/14 can: etas_es58x: add support for ETAS ES581.4 CAN USB interface

In reply to Marc Kleine-Budde

From: Vincent Mailhol <[email protected]>

This patch adds support for the ES581.4 interface from ETAS GmbH (https://www.etas.com/en/products/es58x.php).

---
 drivers/net/can/usb/etas_es58x/Makefile     |   2 +-
 drivers/net/can/usb/etas_es58x/es581_4.c    | 507 ++++++++++++++++++++
 drivers/net/can/usb/etas_es58x/es581_4.h    | 207 ++++++++
 drivers/net/can/usb/etas_es58x/es58x_core.c |   9 +-
 drivers/net/can/usb/etas_es58x/es58x_core.h |   5 +-
 5 files changed, 726 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/can/usb/etas_es58x/es581_4.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es581_4.h
drivers/net/can/usb/etas_es58x/Makefile +1 -1
index 60a1ac935a69..e4753ec9cb60 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o
-etas_es58x-y = es58x_core.o
+etas_es58x-y = es58x_core.o es581_4.o
drivers/net/can/usb/etas_es58x/es581_4.c new file +507 -0

507 lines not on this page · raw message

drivers/net/can/usb/etas_es58x/es581_4.h new file +207 -0

207 lines not on this page · raw message

drivers/net/can/usb/etas_es58x/es58x_core.c +7 -2
index da7f9d1d1162..2d79d4e7e0b2 100644
@@ -27,10 +27,15 @@ MODULE_LICENSE("GPL v2");
 
 #define ES58X_MODULE_NAME "etas_es58x"
 #define ES58X_VENDOR_ID 0x108C
+#define ES581_4_PRODUCT_ID 0x0159
 
 /* Table of devices which work with this driver. */
 static const struct usb_device_id es58x_id_table[] = {
 	{
+		/* ETAS GmbH ES581.4 USB dual-channel CAN Bus Interface module. */
+		USB_DEVICE(ES58X_VENDOR_ID, ES581_4_PRODUCT_ID),
+		.driver_info = ES58X_DUAL_CHANNEL
+	}, {
 		/* Terminating entry */
 	}
 };
@@ -2162,8 +2167,8 @@ static int es58x_init_es58x_dev(struct usb_interface *intf,
 		return -ENODEV;
 		/* Place holder for es58x_fd glue code. */
 	} else {
-		return -ENODEV;
-		/* Place holder for es581_4 glue code. */
+		param = &es581_4_param;
+		ops = &es581_4_ops;
 	}
 
 	es58x_dev = kzalloc(es58x_sizeof_es58x_device(param), GFP_KERNEL);
drivers/net/can/usb/etas_es58x/es58x_core.h +4 -1
index ccced39d5d81..0e7a7dcc48d4 100644
@@ -18,11 +18,13 @@
 #include <linux/can.h>
 #include <linux/can/dev.h>
 
+#include "es581_4.h"
+
 /* Driver constants */
 #define ES58X_RX_URBS_MAX 5	/* Empirical value */
 #define ES58X_TX_URBS_MAX 6	/* Empirical value */
 
-#define ES58X_MAX(param) 0
+#define ES58X_MAX(param) (ES581_4_##param)
 #define ES58X_TX_BULK_MAX ES58X_MAX(TX_BULK_MAX)
 #define ES58X_RX_BULK_MAX ES58X_MAX(RX_BULK_MAX)
 #define ES58X_ECHO_BULK_MAX ES58X_MAX(ECHO_BULK_MAX)
@@ -210,6 +212,7 @@ enum es58x_ret_type {
 };
 
 union es58x_urb_cmd {
+	struct es581_4_urb_cmd es581_4_urb_cmd;
 	struct {		/* Common header parts of all variants */
 		__le16 sof;
 		u8 cmd_type;
Signature · 1 line
2.30.2
author maintainer
#4 lore raw

PATCH 4/14 can: etas_es58x: add support for the ETAS ES58X_FD CAN USB interfaces

In reply to Marc Kleine-Budde

From: Vincent Mailhol <[email protected]>

This patch add support for the ES582.1 and ES584.1 interfaces from ETAS GmbH (https://www.etas.com/en/products/es58x.php).

---
 drivers/net/can/usb/etas_es58x/Makefile     |   2 +-
 drivers/net/can/usb/etas_es58x/es58x_core.c |  19 +-
 drivers/net/can/usb/etas_es58x/es58x_core.h |   6 +-
 drivers/net/can/usb/etas_es58x/es58x_fd.c   | 562 ++++++++++++++++++++
 drivers/net/can/usb/etas_es58x/es58x_fd.h   | 243 +++++++++
 5 files changed, 828 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_fd.c
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_fd.h
drivers/net/can/usb/etas_es58x/Makefile +1 -1
index e4753ec9cb60..a129b4aa0215 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o
-etas_es58x-y = es58x_core.o es581_4.o
+etas_es58x-y = es58x_core.o es581_4.o es58x_fd.o
drivers/net/can/usb/etas_es58x/es58x_core.c +17 -2
index 2d79d4e7e0b2..7222b3b6ca46 100644
@@ -28,6 +28,11 @@ MODULE_LICENSE("GPL v2");
 #define ES58X_MODULE_NAME "etas_es58x"
 #define ES58X_VENDOR_ID 0x108C
 #define ES581_4_PRODUCT_ID 0x0159
+#define ES582_1_PRODUCT_ID 0x0168
+#define ES584_1_PRODUCT_ID 0x0169
+
+/* ES58X FD has some interface protocols unsupported by this driver. */
+#define ES58X_FD_INTERFACE_PROTOCOL 0
 
 /* Table of devices which work with this driver. */
 static const struct usb_device_id es58x_id_table[] = {
@@ -35,6 +40,16 @@ static const struct usb_device_id es58x_id_table[] = {
 		/* ETAS GmbH ES581.4 USB dual-channel CAN Bus Interface module. */
 		USB_DEVICE(ES58X_VENDOR_ID, ES581_4_PRODUCT_ID),
 		.driver_info = ES58X_DUAL_CHANNEL
+	}, {
+		/* ETAS GmbH ES582.1 USB dual-channel CAN FD Bus Interface module. */
+		USB_DEVICE_INTERFACE_PROTOCOL(ES58X_VENDOR_ID, ES582_1_PRODUCT_ID,
+					      ES58X_FD_INTERFACE_PROTOCOL),
+		.driver_info = ES58X_DUAL_CHANNEL | ES58X_FD_FAMILY
+	}, {
+		/* ETAS GmbH ES584.1 USB single-channel CAN FD Bus Interface module. */
+		USB_DEVICE_INTERFACE_PROTOCOL(ES58X_VENDOR_ID, ES584_1_PRODUCT_ID,
+					      ES58X_FD_INTERFACE_PROTOCOL),
+		.driver_info = ES58X_FD_FAMILY
 	}, {
 		/* Terminating entry */
 	}
@@ -2164,8 +2179,8 @@ static int es58x_init_es58x_dev(struct usb_interface *intf,
 		return ret;
 
 	if (driver_info & ES58X_FD_FAMILY) {
-		return -ENODEV;
-		/* Place holder for es58x_fd glue code. */
+		param = &es58x_fd_param;
+		ops = &es58x_fd_ops;
 	} else {
 		param = &es581_4_param;
 		ops = &es581_4_ops;
drivers/net/can/usb/etas_es58x/es58x_core.h +5 -1
index 0e7a7dcc48d4..5f4e7dc5be35 100644
@@ -19,12 +19,15 @@
 #include <linux/can/dev.h>
 
 #include "es581_4.h"
+#include "es58x_fd.h"
 
 /* Driver constants */
 #define ES58X_RX_URBS_MAX 5	/* Empirical value */
 #define ES58X_TX_URBS_MAX 6	/* Empirical value */
 
-#define ES58X_MAX(param) (ES581_4_##param)
+#define ES58X_MAX(param)				\
+	(ES581_4_##param > ES58X_FD_##param ?		\
+		ES581_4_##param : ES58X_FD_##param)
 #define ES58X_TX_BULK_MAX ES58X_MAX(TX_BULK_MAX)
 #define ES58X_RX_BULK_MAX ES58X_MAX(RX_BULK_MAX)
 #define ES58X_ECHO_BULK_MAX ES58X_MAX(ECHO_BULK_MAX)
@@ -213,6 +216,7 @@ enum es58x_ret_type {
 
 union es58x_urb_cmd {
 	struct es581_4_urb_cmd es581_4_urb_cmd;
+	struct es58x_fd_urb_cmd es58x_fd_urb_cmd;
 	struct {		/* Common header parts of all variants */
 		__le16 sof;
 		u8 cmd_type;
drivers/net/can/usb/etas_es58x/es58x_fd.c new file +562 -0

562 lines not on this page · raw message

drivers/net/can/usb/etas_es58x/es58x_fd.h new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#5 lore raw

PATCH 5/14 can: peak_usb: fix checkpatch warnings

In reply to Marc Kleine-Budde

This patch cleans several checkpatch warnings in the peak_usb driver.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c      | 4 ++--
 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 1 +
 drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 +-
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c  | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +2 -2
index ba509aed7b4c..e23049c81159 100644
@@ -401,7 +401,7 @@ static int pcan_usb_update_ts(struct pcan_usb_msg_context *mc)
 {
 	__le16 tmp16;
 
-	if ((mc->ptr+2) > mc->end)
+	if ((mc->ptr + 2) > mc->end)
 		return -EINVAL;
 
 	memcpy(&tmp16, mc->ptr, 2);
@@ -1039,7 +1039,7 @@ const struct peak_usb_adapter pcan_usb = {
 			      CAN_CTRLMODE_BERR_REPORTING |
 			      CAN_CTRLMODE_CC_LEN8_DLC,
 	.clock = {
-		.freq = PCAN_USB_CRYSTAL_HZ / 2 ,
+		.freq = PCAN_USB_CRYSTAL_HZ / 2,
 	},
 	.bittiming_const = &pcan_usb_const,
 
drivers/net/can/usb/peak_usb/pcan_usb_core.c +1 -0
index e69b005be068..7dff77a6ef70 100644
@@ -624,6 +624,7 @@ static int peak_usb_ndo_stop(struct net_device *netdev)
 	/* can set bus off now */
 	if (dev->adapter->dev_set_bus) {
 		int err = dev->adapter->dev_set_bus(dev, 0);
+
 		if (err)
 			return err;
 	}
drivers/net/can/usb/peak_usb/pcan_usb_core.h +1 -1
index e15b4c78f309..59afe880a481 100644
@@ -31,7 +31,7 @@
 /* usb adapters maximum channels per usb interface */
 #define PCAN_USB_MAX_CHANNEL		2
 
-/* maximum length of the usb commands sent to/received from  the devices */
+/* maximum length of the usb commands sent to/received from the devices */
 #define PCAN_USB_MAX_CMD_LEN		32
 
 struct peak_usb_device;
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -1
index 2d1b645af76c..ecb08359f719 100644
@@ -290,7 +290,7 @@ static int pcan_usb_pro_wait_rsp(struct peak_usb_device *dev,
 					   pr->data_type);
 
 			/* check if channel in response corresponds too */
-			else if ((req_channel != 0xff) && \
+			else if ((req_channel != 0xff) &&
 				(pr->bus_act.channel != req_channel))
 				netdev_err(dev->netdev,
 					"got rsp %xh but on chan%u: ignored\n",
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

PATCH 6/14 can: peak_usb: pcan_usb_pro.h: remove double space in indention

In reply to Marc Kleine-Budde

This patch replaces the double space indention after the u8 with a single space in pcan_usb_pro.h.

---
 drivers/net/can/usb/peak_usb/pcan_usb_pro.h | 76 ++++++++++-----------
 1 file changed, 38 insertions(+), 38 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_pro.h +38 -38
index 6f4504300e23..5d4cf14eb9d9 100644
@@ -34,11 +34,11 @@
 /* PCAN_USBPRO_INFO_BL vendor request record type */
 struct __packed pcan_usb_pro_blinfo {
 	__le32 ctrl_type;
-	u8  version[4];
-	u8  day;
-	u8  month;
-	u8  year;
-	u8  dummy;
+	u8 version[4];
+	u8 day;
+	u8 month;
+	u8 year;
+	u8 dummy;
 	__le32 serial_num_hi;
 	__le32 serial_num_lo;
 	__le32 hw_type;
@@ -48,11 +48,11 @@ struct __packed pcan_usb_pro_blinfo {
 /* PCAN_USBPRO_INFO_FW vendor request record type */
 struct __packed pcan_usb_pro_fwinfo {
 	__le32 ctrl_type;
-	u8  version[4];
-	u8  day;
-	u8  month;
-	u8  year;
-	u8  dummy;
+	u8 version[4];
+	u8 day;
+	u8 month;
+	u8 year;
+	u8 dummy;
 	__le32 fw_type;
 };
 
@@ -78,39 +78,39 @@ struct __packed pcan_usb_pro_fwinfo {
 
 /* record structures */
 struct __packed pcan_usb_pro_btr {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 dummy;
 	__le32 CCBT;
 };
 
 struct __packed pcan_usb_pro_busact {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 onoff;
 };
 
 struct __packed pcan_usb_pro_silent {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 onoff;
 };
 
 struct __packed pcan_usb_pro_filter {
-	u8  data_type;
-	u8  dummy;
+	u8 data_type;
+	u8 dummy;
 	__le16 filter_mode;
 };
 
 struct __packed pcan_usb_pro_setts {
-	u8  data_type;
-	u8  dummy;
+	u8 data_type;
+	u8 dummy;
 	__le16 mode;
 };
 
 struct __packed pcan_usb_pro_devid {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 dummy;
 	__le32 serial_num;
 };
@@ -122,21 +122,21 @@ struct __packed pcan_usb_pro_devid {
 #define PCAN_USBPRO_LED_OFF		0x04
 
 struct __packed pcan_usb_pro_setled {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 mode;
 	__le32 timeout;
 };
 
 struct __packed pcan_usb_pro_rxmsg {
-	u8  data_type;
-	u8  client;
-	u8  flags;
-	u8  len;
+	u8 data_type;
+	u8 client;
+	u8 flags;
+	u8 len;
 	__le32 ts32;
 	__le32 id;
 
-	u8  data[8];
+	u8 data[8];
 };
 
 #define PCAN_USBPRO_STATUS_ERROR	0x0001
@@ -145,26 +145,26 @@ struct __packed pcan_usb_pro_rxmsg {
 #define PCAN_USBPRO_STATUS_QOVERRUN	0x0008
 
 struct __packed pcan_usb_pro_rxstatus {
-	u8  data_type;
-	u8  channel;
+	u8 data_type;
+	u8 channel;
 	__le16 status;
 	__le32 ts32;
 	__le32 err_frm;
 };
 
 struct __packed pcan_usb_pro_rxts {
-	u8  data_type;
-	u8  dummy[3];
+	u8 data_type;
+	u8 dummy[3];
 	__le32 ts64[2];
 };
 
 struct __packed pcan_usb_pro_txmsg {
-	u8  data_type;
-	u8  client;
-	u8  flags;
-	u8  len;
+	u8 data_type;
+	u8 client;
+	u8 flags;
+	u8 len;
 	__le32 id;
-	u8  data[8];
+	u8 data[8];
 };
 
 union pcan_usb_pro_rec {
Signature · 1 line
2.30.2
author maintainer
#7 lore raw

PATCH 7/14 can: peak_usb: remove unused variables from struct peak_usb_device

In reply to Marc Kleine-Budde

This patch removes the unused variables struct peak_usb_device::echo_skb and struct peak_usb_device::bus_load from the driver.

---
 drivers/net/can/usb/peak_usb/pcan_usb_core.h | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_core.h +0 -4
index 59afe880a481..64c4c22bb296 100644
@@ -114,8 +114,6 @@ struct peak_usb_device {
 	unsigned int ctrl_idx;
 	u32 state;
 
-	struct sk_buff *echo_skb[PCAN_USB_MAX_TX_URBS];
-
 	struct usb_device *udev;
 	struct net_device *netdev;
 
@@ -132,8 +130,6 @@ struct peak_usb_device {
 	u8 ep_msg_in;
 	u8 ep_msg_out;
 
-	u16 bus_load;
-
 	struct peak_usb_device *prev_siblings;
 	struct peak_usb_device *next_siblings;
 };
Signature · 1 line
2.30.2
author maintainer
#8 lore raw

PATCH 8/14 can: peak_usb: remove write only variable struct peak_usb_adapter::ts_period

In reply to Marc Kleine-Budde

The variable struct peak_usb_adapter::ts_period is only ever written to. This patch removes it from the driver.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c      | 1 -
 drivers/net/can/usb/peak_usb/pcan_usb_core.h | 1 -
 drivers/net/can/usb/peak_usb/pcan_usb_fd.c   | 4 ----
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c  | 1 -
 4 files changed, 7 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +0 -1
index e23049c81159..38bee69ff48a 100644
@@ -1050,7 +1050,6 @@ const struct peak_usb_adapter pcan_usb = {
 
 	/* timestamps usage */
 	.ts_used_bits = 16,
-	.ts_period = 24575, /* calibration period in ts. */
 	.us_per_ts_scale = PCAN_USB_TS_US_PER_TICK, /* us=(ts*scale) */
 	.us_per_ts_shift = PCAN_USB_TS_DIV_SHIFTER, /*  >> shift     */
 
drivers/net/can/usb/peak_usb/pcan_usb_core.h +0 -1
index 64c4c22bb296..b00a4811bf61 100644
@@ -73,7 +73,6 @@ struct peak_usb_adapter {
 	u8 ep_msg_in;
 	u8 ep_msg_out[PCAN_USB_MAX_CHANNEL];
 	u8 ts_used_bits;
-	u32 ts_period;
 	u8 us_per_ts_shift;
 	u32 us_per_ts_scale;
 
drivers/net/can/usb/peak_usb/pcan_usb_fd.c +0 -4
index 6f62b6f51051..b11eabad575b 100644
@@ -1081,7 +1081,6 @@ const struct peak_usb_adapter pcan_usb_fd = {
 
 	/* timestamps usage */
 	.ts_used_bits = 32,
-	.ts_period = 1000000, /* calibration period in ts. */
 	.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
 	.us_per_ts_shift = 0,
 
@@ -1156,7 +1155,6 @@ const struct peak_usb_adapter pcan_usb_chip = {
 
 	/* timestamps usage */
 	.ts_used_bits = 32,
-	.ts_period = 1000000, /* calibration period in ts. */
 	.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
 	.us_per_ts_shift = 0,
 
@@ -1231,7 +1229,6 @@ const struct peak_usb_adapter pcan_usb_pro_fd = {
 
 	/* timestamps usage */
 	.ts_used_bits = 32,
-	.ts_period = 1000000, /* calibration period in ts. */
 	.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
 	.us_per_ts_shift = 0,
 
@@ -1306,7 +1303,6 @@ const struct peak_usb_adapter pcan_usb_x6 = {
 
 	/* timestamps usage */
 	.ts_used_bits = 32,
-	.ts_period = 1000000, /* calibration period in ts. */
 	.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
 	.us_per_ts_shift = 0,
 
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +0 -1
index ecb08359f719..589ba797fb33 100644
@@ -1058,7 +1058,6 @@ const struct peak_usb_adapter pcan_usb_pro = {
 
 	/* timestamps usage */
 	.ts_used_bits = 32,
-	.ts_period = 1000000, /* calibration period in ts. */
 	.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
 	.us_per_ts_shift = 0,
 
Signature · 1 line
2.30.2
author maintainer
#9 lore raw

PATCH 9/14 can: peak_usb: peak_usb_probe(): make use of driver_info

In reply to Marc Kleine-Budde

There's no need to iterate over all supported adapters to find the struct peak_usb_adapter that describes the currently probed devices's capabilities. The driver core gives us the information for free, if we assign it to the struct usb_device_id::driver_info.

This patch assigns the usb_device_id::driver_info and converts peak_usb_probe() to make use of it. This reduces the driver size by 100 bytes on ARCH=arm.

| add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-124 (-124)
| Function                                     old     new   delta
| peak_usb_adapters_list                        24       -     -24
| peak_usb_probe                               236     136    -100
| Total: Before=25263, After=25139, chg -0.49%
---
 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 57 +++++++++-----------
 1 file changed, 24 insertions(+), 33 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_core.c +24 -33
index 7dff77a6ef70..e8f43ed90b72 100644
@@ -27,28 +27,32 @@ MODULE_DESCRIPTION("CAN driver for PEAK-System USB adapters");
 MODULE_LICENSE("GPL v2");
 
 /* Table of devices that work with this driver */
-static struct usb_device_id peak_usb_table[] = {
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USB_PRODUCT_ID)},
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)},
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID)},
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID)},
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBCHIP_PRODUCT_ID)},
-	{USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID)},
-	{} /* Terminating entry */
+static const struct usb_device_id peak_usb_table[] = {
+	{
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USB_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb,
+	}, {
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb_pro,
+	}, {
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBFD_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb_fd,
+	}, {
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPROFD_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb_pro_fd,
+	}, {
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBCHIP_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb_chip,
+	}, {
+		USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBX6_PRODUCT_ID),
+		.driver_info = (kernel_ulong_t)&pcan_usb_x6,
+	}, {
+		/* Terminating entry */
+	}
 };
 
 MODULE_DEVICE_TABLE(usb, peak_usb_table);
 
-/* List of supported PCAN-USB adapters (NULL terminated list) */
-static const struct peak_usb_adapter *const peak_usb_adapters_list[] = {
-	&pcan_usb,
-	&pcan_usb_pro,
-	&pcan_usb_fd,
-	&pcan_usb_pro_fd,
-	&pcan_usb_chip,
-	&pcan_usb_x6,
-};
-
 /*
  * dump memory
  */
@@ -928,24 +932,11 @@ static void peak_usb_disconnect(struct usb_interface *intf)
 static int peak_usb_probe(struct usb_interface *intf,
 			  const struct usb_device_id *id)
 {
-	struct usb_device *usb_dev = interface_to_usbdev(intf);
-	const u16 usb_id_product = le16_to_cpu(usb_dev->descriptor.idProduct);
-	const struct peak_usb_adapter *peak_usb_adapter = NULL;
+	const struct peak_usb_adapter *peak_usb_adapter;
 	int i, err = -ENOMEM;
 
 	/* get corresponding PCAN-USB adapter */
-	for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
-		if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
-			peak_usb_adapter = peak_usb_adapters_list[i];
-			break;
-		}
-
-	if (!peak_usb_adapter) {
-		/* should never come except device_id bad usage in this file */
-		pr_err("%s: didn't find device id. 0x%x in devices list\n",
-			PCAN_USB_DRIVER_NAME, usb_id_product);
-		return -ENODEV;
-	}
+	peak_usb_adapter = (const struct peak_usb_adapter *)id->driver_info;
 
 	/* got corresponding adapter: check if it handles current interface */
 	if (peak_usb_adapter->intf_probe) {
Signature · 1 line
2.30.2
author maintainer
#10 lore raw

PATCH 10/14 can: peak_usb: pcan_usb_{,pro}_get_device_id(): remove unneeded check for device_id

In reply to Marc Kleine-Budde

The callback struct peak_usb_adapter::dev_get_device_id, which is implemented by the functions pcan_usb_{,pro}_get_device_id() is only ever called with a valid device_id pointer.

This patch removes the unneeded check if the device_id pointer is valid.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c     | 4 ++--
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +2 -2
index 38bee69ff48a..671d589b48c1 100644
@@ -388,8 +388,8 @@ static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id)
 	err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_DEVID, PCAN_USB_GET, args);
 	if (err)
 		netdev_err(dev->netdev, "getting device id failure: %d\n", err);
-	else if (device_id)
-		*device_id = args[0];
+
+	*device_id = args[0];
 
 	return err;
 }
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -2
index 589ba797fb33..858ab22708fc 100644
@@ -439,8 +439,7 @@ static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev,
 		return err;
 
 	pdn = (struct pcan_usb_pro_devid *)pc;
-	if (device_id)
-		*device_id = le32_to_cpu(pdn->serial_num);
+	*device_id = le32_to_cpu(pdn->serial_num);
 
 	return err;
 }
Signature · 1 line
2.30.2
author maintainer
#11 lore raw

PATCH 11/14 can: peak_usb: pcan_usb_get_serial(): remove error message from error path

In reply to Marc Kleine-Budde

The caller of pcan_usb_get_serial() already prints an error message, so remove this one and return immediately.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +5 -4
index 671d589b48c1..fd5ea95fd55d 100644
@@ -365,16 +365,17 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)
 	int err;
 
 	err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_SN, PCAN_USB_GET, args);
-	if (err) {
-		netdev_err(dev->netdev, "getting serial failure: %d\n", err);
-	} else if (serial_number) {
+	if (err)
+		return err;
+
+	if (serial_number) {
 		__le32 tmp32;
 
 		memcpy(&tmp32, args, 4);
 		*serial_number = le32_to_cpu(tmp32);
 	}
 
-	return err;
+	return 0;
 }
 
 /*
Signature · 1 line
2.30.2
author maintainer
#12 lore raw

PATCH 12/14 can: peak_usb: pcan_usb_get_serial(): make use of le32_to_cpup()

In reply to Marc Kleine-Budde

This patch replaces the memcpy() + le32_to_cpu() by le32_to_cpup().

---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +2 -6
index fd5ea95fd55d..ffb01c3a3827 100644
@@ -368,12 +368,8 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)
 	if (err)
 		return err;
 
-	if (serial_number) {
-		__le32 tmp32;
-
-		memcpy(&tmp32, args, 4);
-		*serial_number = le32_to_cpu(tmp32);
-	}
+	if (serial_number)
+		*serial_number = le32_to_cpup((__le32 *)args);
 
 	return 0;
 }
Signature · 1 line
2.30.2
author maintainer
#13 lore raw

PATCH 13/14 can: peak_usb: pcan_usb_get_serial(): unconditionally assign serial_number

In reply to Marc Kleine-Budde

The function serial_number is only called from one location with a valid serial_number pointer. Remove not needed NULL pointer check.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +1 -3
index ffb01c3a3827..929cc1b05aa2 100644
@@ -367,9 +367,7 @@ static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number)
 	err = pcan_usb_wait_rsp(dev, PCAN_USB_CMD_SN, PCAN_USB_GET, args);
 	if (err)
 		return err;
-
-	if (serial_number)
-		*serial_number = le32_to_cpup((__le32 *)args);
+	*serial_number = le32_to_cpup((__le32 *)args);
 
 	return 0;
 }
Signature · 1 line
2.30.2
author maintainer
#14 lore raw

PATCH 14/14 can: peak_usb: pcan_usb: replace open coded endianness conversion of unaligned data

In reply to Marc Kleine-Budde

This patch replaces the open coded endianness conversion of unaligned data by the appropriate get/put_unaligned_leXX() variants.

---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 37 ++++++++-----------------
 1 file changed, 11 insertions(+), 26 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +11 -26
index 929cc1b05aa2..1d6f77252f01 100644
@@ -394,14 +394,10 @@ static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id)
  */
 static int pcan_usb_update_ts(struct pcan_usb_msg_context *mc)
 {
-	__le16 tmp16;
-
 	if ((mc->ptr + 2) > mc->end)
 		return -EINVAL;
 
-	memcpy(&tmp16, mc->ptr, 2);
-
-	mc->ts16 = le16_to_cpu(tmp16);
+	mc->ts16 = get_unaligned_le16(mc->ptr);
 
 	if (mc->rec_idx > 0)
 		peak_usb_update_ts_now(&mc->pdev->time_ref, mc->ts16);
@@ -418,16 +414,13 @@ static int pcan_usb_decode_ts(struct pcan_usb_msg_context *mc, u8 first_packet)
 {
 	/* only 1st packet supplies a word timestamp */
 	if (first_packet) {
-		__le16 tmp16;
-
 		if ((mc->ptr + 2) > mc->end)
 			return -EINVAL;
 
-		memcpy(&tmp16, mc->ptr, 2);
-		mc->ptr += 2;
-
-		mc->ts16 = le16_to_cpu(tmp16);
+		mc->ts16 = get_unaligned_le16(mc->ptr);
 		mc->prev_ts8 = mc->ts16 & 0x00ff;
+
+		mc->ptr += 2;
 	} else {
 		u8 ts8;
 
@@ -717,25 +710,17 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
 		return -ENOMEM;
 
 	if (status_len & PCAN_USB_STATUSLEN_EXT_ID) {
-		__le32 tmp32;
-
 		if ((mc->ptr + 4) > mc->end)
 			goto decode_failed;
 
-		memcpy(&tmp32, mc->ptr, 4);
+		cf->can_id = get_unaligned_le32(mc->ptr) >> 3 | CAN_EFF_FLAG;
 		mc->ptr += 4;
-
-		cf->can_id = (le32_to_cpu(tmp32) >> 3) | CAN_EFF_FLAG;
 	} else {
-		__le16 tmp16;
-
 		if ((mc->ptr + 2) > mc->end)
 			goto decode_failed;
 
-		memcpy(&tmp16, mc->ptr, 2);
+		cf->can_id = get_unaligned_le16(mc->ptr) >> 5;
 		mc->ptr += 2;
-
-		cf->can_id = le16_to_cpu(tmp16) >> 5;
 	}
 
 	can_frame_set_cc_len(cf, rec_len, mc->pdev->dev.can.ctrlmode);
@@ -849,15 +834,15 @@ static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb,
 
 	/* can id */
 	if (cf->can_id & CAN_EFF_FLAG) {
-		__le32 tmp32 = cpu_to_le32((cf->can_id & CAN_ERR_MASK) << 3);
-
 		*pc |= PCAN_USB_STATUSLEN_EXT_ID;
-		memcpy(++pc, &tmp32, 4);
+		pc++;
+
+		put_unaligned_le32((cf->can_id & CAN_ERR_MASK) << 3, pc);
 		pc += 4;
 	} else {
-		__le16 tmp16 = cpu_to_le16((cf->can_id & CAN_ERR_MASK) << 5);
+		pc++;
 
-		memcpy(++pc, &tmp16, 2);
+		put_unaligned_le16((cf->can_id & CAN_ERR_MASK) << 5, pc);
 		pc += 2;
 	}
 
Signature · 1 line
2.30.2
#15 lore raw
In reply to Marc Kleine-Budde
This pull request was applied to netdev/net-next.git (refs/heads/master):

Hello:

This pull request was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Tue, 13 Apr 2021 11:51:47 +0200 you wrote:

Hello Jakub, hello David,

this is a pull request of 14 patches for net-next/master.

The first patch is by Yoshihiro Shimoda and updates the DT bindings for the rcar_can driver.

[...]

Here is the summary with links:
- pull-request: can-next 2021-04-13

    https://git.kernel.org/netdev/net-next/c/9fb434bcf825
  - [net-next,02/14] can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces
    https://git.kernel.org/netdev/net-next/c/8537257874e9
  - [net-next,03/14] can: etas_es58x: add support for ETAS ES581.4 CAN USB interface
    https://git.kernel.org/netdev/net-next/c/1dfb6005a60b
  - [net-next,04/14] can: etas_es58x: add support for the ETAS ES58X_FD CAN USB interfaces
    https://git.kernel.org/netdev/net-next/c/c664e2137a27
  - [net-next,05/14] can: peak_usb: fix checkpatch warnings
    https://git.kernel.org/netdev/net-next/c/bc256b95971f
  - [net-next,06/14] can: peak_usb: pcan_usb_pro.h: remove double space in indention
    https://git.kernel.org/netdev/net-next/c/fa34e0a18f8a
  - [net-next,07/14] can: peak_usb: remove unused variables from struct peak_usb_device
    https://git.kernel.org/netdev/net-next/c/c779e1271a9e
  - [net-next,08/14] can: peak_usb: remove write only variable struct peak_usb_adapter::ts_period
    https://git.kernel.org/netdev/net-next/c/1a5a5eedf807
  - [net-next,09/14] can: peak_usb: peak_usb_probe(): make use of driver_info
    https://git.kernel.org/netdev/net-next/c/592bf5a09d19
  - [net-next,10/14] can: peak_usb: pcan_usb_{,pro}_get_device_id(): remove unneeded check for device_id
    https://git.kernel.org/netdev/net-next/c/426718f3fe0e
  - [net-next,11/14] can: peak_usb: pcan_usb_get_serial(): remove error message from error path
    https://git.kernel.org/netdev/net-next/c/5e164a4f0aae
  - [net-next,12/14] can: peak_usb: pcan_usb_get_serial(): make use of le32_to_cpup()
    https://git.kernel.org/netdev/net-next/c/0a7d6cdf90c0
  - [net-next,13/14] can: peak_usb: pcan_usb_get_serial(): unconditionally assign serial_number
    https://git.kernel.org/netdev/net-next/c/b7a29d35a984
  - [net-next,14/14] can: peak_usb: pcan_usb: replace open coded endianness conversion of unaligned data
    https://git.kernel.org/netdev/net-next/c/bd573ea57204

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html