can: kvaser_usb: Simplify identification of physical CAN interfaces
Subsystems (5)
PATCH v2 1/11 can: kvaser_usb: Add support to control CAN LEDs on device
In reply to Jimmy AssarssonAdd support to turn on/off CAN LEDs on device.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 9 ++++ .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 51 ++++++++++++++++++ .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 54 +++++++++++++++++++ 3 files changed, 114 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +9 -0
@@ -54,6 +54,11 @@ enum kvaser_usb_leaf_family { KVASER_USBCAN, }; +enum kvaser_usb_led_state { +KVASER_USB_LED_ON =0 , +KVASER_USB_LED_OFF =1 , +}; +#define KVASER_USB_HYDRA_MAX_CMD_LEN 128struct kvaser_usb_dev_card_data_hydra {u8 channel_to_he[KVASER_USB_MAX_NET_DEVICES ];
@@ -149,6 +154,7 @@ struct kvaser_usb_net_priv {* @dev_get_software_details: get software details * @dev_get_card_info: get card info * @dev_get_capabilities: discover device capabilities +* @dev_set_led: turn on/off device LED * * @dev_set_opt_mode: set ctrlmod * @dev_start_chip: start the CAN controller
@@ -176,6 +182,9 @@ struct kvaser_usb_dev_ops {int (*dev_get_software_details)(struct kvaser_usb *dev);int (*dev_get_card_info)(struct kvaser_usb *dev);int (*dev_get_capabilities)(struct kvaser_usb *dev); +int (*dev_set_led)(struct kvaser_usb_net_priv *priv, +enum kvaser_usb_led_state state, +u16 duration_ms);int (*dev_set_opt_mode)(const struct kvaser_usb_net_priv *priv);int (*dev_start_chip)(struct kvaser_usb_net_priv *priv);int (*dev_stop_chip)(struct kvaser_usb_net_priv *priv);
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +51 -0
93 lines not on this page · raw message
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +54 -0
108 lines not on this page · raw message
Signature · 1 line
2.49.0
v2 cover can: kvaser_usb: Simplify identification of physical CAN interfaces
This patch series simplifies the process of identifying which network interface (can0..canX) corresponds to which physical CAN channel on Kvaser USB based CAN interfaces.
Changes in v2:
- New patch with devlink documentation
- New patch assigning netdev.dev_port
- Formatting and refactoring
Jimmy Assarsson (11):
can: kvaser_usb: Add support to control CAN LEDs on device
can: kvaser_usb: Add support for ethtool set_phys_id()
can: kvaser_usb: Assign netdev.dev_port based on device channel index
can: kvaser_usb: Add intermediate variables
can: kvaser_usb: Move comment regarding max_tx_urbs
can: kvaser_usb: Store the different firmware version components in a
struct
can: kvaser_usb: Store additional device information
can: kvaser_usb: Add devlink support
can: kvaser_usb: Expose device information via devlink info_get()
can: kvaser_usb: Add devlink port support
Documentation: devlink: add devlink documentation for the kvaser_usb
driver
Documentation/networking/devlink/index.rst | 1 + .../networking/devlink/kvaser_usb.rst | 33 +++++ drivers/net/can/usb/Kconfig | 1 + drivers/net/can/usb/kvaser_usb/Makefile | 2 +- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 33 ++++- .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 139 +++++++++++++----- .../can/usb/kvaser_usb/kvaser_usb_devlink.c | 88 +++++++++++ .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 63 +++++++- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 75 +++++++++- 9 files changed, 387 insertions(+), 48 deletions(-) create mode 100644 Documentation/networking/devlink/kvaser_usb.rst create mode 100644 drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c
Signature · 1 line
2.49.0
PATCH v2 2/11 can: kvaser_usb: Add support for ethtool set_phys_id()
Add support for ethtool set_phys_id(), to physically locate devices by flashing a LED on the device.
---
Changes in v2:
- Return inside the switch-case. Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#md10566c624e75c59ec735fed16d5ec4cbdb38430
.../net/can/usb/kvaser_usb/kvaser_usb_core.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +26 -0
@@ -753,6 +753,31 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,return ret; } +static int kvaser_usb_set_phys_id (struct net_device *netdev, +enum ethtool_phys_id_state state) +{ +struct kvaser_usb_net_priv *priv =netdev_priv (netdev); +const struct kvaser_usb_dev_ops *ops = priv->dev->driver_info->ops; + +switch (state) { +case ETHTOOL_ID_ACTIVE : +return 3 ;/* 3 On/Off cycles per second */ + +case ETHTOOL_ID_ON : +return ops->dev_set_led (priv,KVASER_USB_LED_ON ,1000 ); + +case ETHTOOL_ID_OFF : +return ops->dev_set_led (priv,KVASER_USB_LED_OFF ,1000 ); + +case ETHTOOL_ID_INACTIVE : +/* Turn LED off and restore standard function after 1ms */ +return ops->dev_set_led (priv,KVASER_USB_LED_OFF ,1 ); + +default : +return -EINVAL ; + } +} +static const struct net_device_ops kvaser_usb_netdev_ops = { .ndo_open = kvaser_usb_open, .ndo_stop = kvaser_usb_close,
@@ -763,6 +788,7 @@ static const struct net_device_ops kvaser_usb_netdev_ops = {static const struct ethtool_ops kvaser_usb_ethtool_ops = { .get_ts_info = can_ethtool_op_get_ts_info_hwts, + .set_phys_id = kvaser_usb_set_phys_id, };static void kvaser_usb_remove_interfaces (struct kvaser_usb *dev)
Signature · 1 line
2.49.0
PATCH v2 3/11 can: kvaser_usb: Assign netdev.dev_port based on device channel index
In reply to Jimmy AssarssonAssign netdev.dev_port based on the device channel index, to indicate the port number of the network device.
While this driver already uses netdev.dev_id for that purpose, dev_port is more appropriate. However, retain dev_id to avoid potential regressions.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +1 -0
@@ -878,6 +878,7 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel) netdev->ethtool_ops = &kvaser_usb_ethtool_ops;SET_NETDEV_DEV (netdev, &dev->intf->dev); netdev->dev_id = channel; + netdev->dev_port = channel; dev->nets[channel] = priv;
Signature · 1 line
2.49.0
PATCH v2 4/11 can: kvaser_usb: Add intermediate variables
In reply to Jimmy AssarssonAdd intermediate variables, for readability and to simplify future patches.
--- .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +13 -7
@@ -364,10 +364,13 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb) err =usb_submit_urb (urb,GFP_ATOMIC );if (err == -ENODEV ) {for (i =0 ; i < dev->nchannels; i++) { -if (!dev->nets[i]) +struct kvaser_usb_net_priv *priv; + + priv = dev->nets[i]; +if (!priv)continue ; -netif_device_detach (dev->nets[i]->netdev); +netif_device_detach (priv->netdev); } }else if (err) { dev_err(&dev->intf->dev,
@@ -795,24 +798,27 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev) {const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;int i; +struct kvaser_usb_net_priv *priv;for (i =0 ; i < dev->nchannels; i++) { -if (!dev->nets[i]) + priv = dev->nets[i]; +if (!priv)continue ; -unregister_candev (dev->nets[i]->netdev); +unregister_candev (priv->netdev); }kvaser_usb_unlink_all_urbs (dev);for (i =0 ; i < dev->nchannels; i++) { -if (!dev->nets[i]) + priv = dev->nets[i]; +if (!priv)continue ;if (ops->dev_remove_channel) - ops->dev_remove_channel (dev->nets[i]); + ops->dev_remove_channel (priv); -free_candev (dev->nets[i]->netdev); +free_candev (priv->netdev); } }
Signature · 1 line
2.49.0
PATCH v2 5/11 can: kvaser_usb: Move comment regarding max_tx_urbs
In reply to Jimmy AssarssonMove comment regarding max_tx_urbs, to where the struct member is declared.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +2 -2
@@ -101,12 +101,12 @@ struct kvaser_usb {struct usb_endpoint_descriptor *bulk_in, *bulk_out;struct usb_anchor rx_submitted; +u32 fw_version; +unsigned int nchannels;/* @max_tx_urbs: Firmware-reported maximum number of outstanding, * not yet ACKed, transmissions on this device. This value is * also used as a sentinel for marking free tx contexts. */ -u32 fw_version; -unsigned int nchannels;unsigned int max_tx_urbs;struct kvaser_usb_dev_card_data card_data;
Signature · 1 line
2.49.0
PATCH v2 6/11 can: kvaser_usb: Store the different firmware version components in a struct
In reply to Jimmy AssarssonStore firmware version in kvaser_usb_fw_version struct, specifying the different components of the version number.
And drop debug prinout of firmware version, since later patches will expose it via the devlink interface.
---
Changes in v2:
- Drop debug prinout, since it will be exposed via devlink. Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#m2003548deedfeafee5c57ee2e2f610d364220fae
drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 12 +++++++++++- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 5 ----- drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 6 +++++- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 15 +++++++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +11 -1
@@ -47,6 +47,10 @@#define KVASER_USB_CAP_EXT_CAP 0x02#define KVASER_USB_HYDRA_CAP_EXT_CMD 0x04 +#define KVASER_USB_SW_VERSION_MAJOR_MASK GENMASK(31, 24) +#define KVASER_USB_SW_VERSION_MINOR_MASK GENMASK(23, 16) +#define KVASER_USB_SW_VERSION_BUILD_MASK GENMASK(15, 0) +struct kvaser_usb_dev_cfg ;enum kvaser_usb_leaf_family {
@@ -83,6 +87,12 @@ struct kvaser_usb_tx_urb_context {u32 echo_index; }; +struct kvaser_usb_fw_version { +u8 major; +u8 minor; +u16 build; +}; +struct kvaser_usb_busparams {__le32 bitrate;u8 tseg1;
@@ -101,7 +111,7 @@ struct kvaser_usb {struct usb_endpoint_descriptor *bulk_in, *bulk_out;struct usb_anchor rx_submitted; -u32 fw_version; +struct kvaser_usb_fw_version fw_version;unsigned int nchannels;/* @max_tx_urbs: Firmware-reported maximum number of outstanding, * not yet ACKed, transmissions on this device. This value is
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -5
@@ -963,11 +963,6 @@ static int kvaser_usb_probe(struct usb_interface *intf,if (WARN_ON (!dev->cfg))return -ENODEV ; -dev_dbg (&intf->dev,"Firmware version: %d.%d.%d\n" , - ((dev->fw_version >>24 ) &0xff ), - ((dev->fw_version >>16 ) &0xff ), - (dev->fw_version &0xffff )); -dev_dbg (&intf->dev,"Max outstanding tx = %d URBs\n" , dev->max_tx_urbs); err = ops->dev_get_card_info (dev);
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +5 -1
@@ -1839,6 +1839,7 @@ static int kvaser_usb_hydra_get_software_details(struct kvaser_usb *dev)size_t cmd_len;int err;u32 flags; +u32 fw_version;struct kvaser_usb_dev_card_data *card_data = &dev->card_data; cmd =kzalloc (sizeof (*cmd),GFP_KERNEL );
@@ -1863,7 +1864,10 @@ static int kvaser_usb_hydra_get_software_details(struct kvaser_usb *dev)if (err) goto end; - dev->fw_version =le32_to_cpu (cmd->sw_detail_res.sw_version); + fw_version =le32_to_cpu (cmd->sw_detail_res.sw_version); + dev->fw_version.major =FIELD_GET (KVASER_USB_SW_VERSION_MAJOR_MASK , fw_version); + dev->fw_version.minor =FIELD_GET (KVASER_USB_SW_VERSION_MINOR_MASK , fw_version); + dev->fw_version.build =FIELD_GET (KVASER_USB_SW_VERSION_BUILD_MASK , fw_version); flags =le32_to_cpu (cmd->sw_detail_res.sw_flags);if (flags &KVASER_USB_HYDRA_SW_FLAG_FW_BAD ) {
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +13 -2
@@ -741,9 +741,13 @@ static int kvaser_usb_leaf_send_simple_cmd(const struct kvaser_usb *dev,static void kvaser_usb_leaf_get_software_info_leaf (struct kvaser_usb *dev,const struct leaf_cmd_softinfo *softinfo) { +u32 fw_version;u32 sw_options =le32_to_cpu (softinfo->sw_options); - dev->fw_version =le32_to_cpu (softinfo->fw_version); + fw_version =le32_to_cpu (softinfo->fw_version); + dev->fw_version.major =FIELD_GET (KVASER_USB_SW_VERSION_MAJOR_MASK , fw_version); + dev->fw_version.minor =FIELD_GET (KVASER_USB_SW_VERSION_MINOR_MASK , fw_version); + dev->fw_version.build =FIELD_GET (KVASER_USB_SW_VERSION_BUILD_MASK , fw_version); dev->max_tx_urbs =le16_to_cpu (softinfo->max_outstanding_tx);if (sw_options &KVASER_USB_LEAF_SWOPTION_EXT_CAP )
@@ -784,6 +788,7 @@ static int kvaser_usb_leaf_get_software_info_inner(struct kvaser_usb *dev) {struct kvaser_cmd cmd;int err; +u32 fw_version; err =kvaser_usb_leaf_send_simple_cmd (dev,CMD_GET_SOFTWARE_INFO ,0 );if (err)
@@ -798,7 +803,13 @@ static int kvaser_usb_leaf_get_software_info_inner(struct kvaser_usb *dev)kvaser_usb_leaf_get_software_info_leaf (dev, &cmd.u.leaf.softinfo);break ;case KVASER_USBCAN : - dev->fw_version =le32_to_cpu (cmd.u.usbcan.softinfo.fw_version); + fw_version =le32_to_cpu (cmd.u.usbcan.softinfo.fw_version); + dev->fw_version.major =FIELD_GET (KVASER_USB_SW_VERSION_MAJOR_MASK , + fw_version); + dev->fw_version.minor =FIELD_GET (KVASER_USB_SW_VERSION_MINOR_MASK , + fw_version); + dev->fw_version.build =FIELD_GET (KVASER_USB_SW_VERSION_BUILD_MASK , + fw_version); dev->max_tx_urbs =le16_to_cpu (cmd.u.usbcan.softinfo.max_outstanding_tx); dev->cfg = &kvaser_usb_leaf_usbcan_dev_cfg;
Signature · 1 line
2.49.0
PATCH v2 7/11 can: kvaser_usb: Store additional device information
In reply to Jimmy AssarssonStore additional device information; EAN (product number), serial_number and hardware revision.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 3 +++ drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 6 +++++- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +3 -0
@@ -111,7 +111,10 @@ struct kvaser_usb {struct usb_endpoint_descriptor *bulk_in, *bulk_out;struct usb_anchor rx_submitted; +u32 ean[2 ]; +u32 serial_number;struct kvaser_usb_fw_version fw_version; +u8 hw_revision;unsigned int nchannels;/* @max_tx_urbs: Firmware-reported maximum number of outstanding, * not yet ACKed, transmissions on this device. This value is
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +5 -1
@@ -114,7 +114,7 @@ struct kvaser_cmd_card_info {__le32 clock_res;__le32 mfg_date;__le32 ean[2 ]; -u8 hw_version; +u8 hw_revision;u8 usb_mode;u8 hw_type;u8 reserved0;
@@ -1918,6 +1918,10 @@ static int kvaser_usb_hydra_get_card_info(struct kvaser_usb *dev) err =kvaser_usb_hydra_wait_cmd (dev,CMD_GET_CARD_INFO_RESP , &cmd);if (err)return err; + dev->ean[1 ] =le32_to_cpu (cmd.card_info.ean[1 ]); + dev->ean[0 ] =le32_to_cpu (cmd.card_info.ean[0 ]); + dev->serial_number =le32_to_cpu (cmd.card_info.serial_number); + dev->hw_revision = cmd.card_info.hw_revision; dev->nchannels = cmd.card_info.nchannels;if (dev->nchannels >KVASER_USB_MAX_NET_DEVICES )
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +5 -1
@@ -138,7 +138,7 @@ struct kvaser_cmd_cardinfo {__le32 padding0;__le32 clock_resolution;__le32 mfgdate; -u8 ean[8 ]; +__le32 ean[2 ];u8 hw_revision; union { struct {
@@ -854,6 +854,10 @@ static int kvaser_usb_leaf_get_card_info(struct kvaser_usb *dev) (dev->driver_info->family ==KVASER_USBCAN && dev->nchannels > MAX_USBCAN_NET_DEVICES)) return -EINVAL; + dev->ean[1 ] =le32_to_cpu (cmd.u.cardinfo.ean[1 ]); + dev->ean[0 ] =le32_to_cpu (cmd.u.cardinfo.ean[0 ]); + dev->serial_number =le32_to_cpu (cmd.u.cardinfo.serial_number); + dev->hw_revision = cmd.u.cardinfo.hw_revision;return 0 ; }
Signature · 1 line
2.49.0
PATCH v2 8/11 can: kvaser_usb: Add devlink support
In reply to Jimmy AssarssonAdd devlink support at device level.
Example output:
$ devlink dev usb/1-1.3:1.0
$ devlink dev info
usb/1-1.3:1.0:
driver kvaser_usb---
Changes in v2:
- Add two space indentation to terminal output.
Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#m31ee4aad13ee29d5559b56fdce842609ae4f67c5
drivers/net/can/usb/Kconfig | 1 + drivers/net/can/usb/kvaser_usb/Makefile | 2 +- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 3 + .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 72 ++++++++++++------- .../can/usb/kvaser_usb/kvaser_usb_devlink.c | 10 +++ 5 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c
drivers/net/can/usb/Kconfig +1 -0
@@ -66,6 +66,7 @@ config CAN_GS_USB config CAN_KVASER_USB tristate "Kvaser CAN/USB interface" + select NET_DEVLINK help This driver adds support for Kvaser CAN/USB devices like Kvaser Leaf Light, Kvaser USBcan II and Kvaser Memorator Pro 5xHS.
drivers/net/can/usb/kvaser_usb/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o -kvaser_usb-y = kvaser_usb_core.o kvaser_usb_leaf.o kvaser_usb_hydra.o +kvaser_usb-y = kvaser_usb_core.o kvaser_usb_devlink.o kvaser_usb_leaf.o kvaser_usb_hydra.o
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +3 -0
@@ -27,6 +27,7 @@#include <linux/spinlock.h> #include <linux/types.h> #include <linux/usb.h> +#include <net/devlink.h> #include <linux/can.h> #include <linux/can/dev.h>
@@ -226,6 +227,8 @@ struct kvaser_usb_dev_cfg {extern const struct kvaser_usb_dev_ops kvaser_usb_hydra_dev_ops;extern const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops; +extern const struct devlink_ops kvaser_usb_devlink_ops; +void kvaser_usb_unlink_tx_urbs (struct kvaser_usb_net_priv *priv); int kvaser_usb_recv_cmd(const struct kvaser_usb *dev, void *cmd, int len,
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +47 -25
126 lines not on this page · raw message
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c new file +10 -0
@@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 +/* kvaser_usb devlink functions +* +* Copyright (C) 2025 KVASER AB, Sweden. All rights reserved. +*/ + +#include <net/devlink.h> + +const struct devlink_ops kvaser_usb_devlink_ops = { +};
Signature · 1 line
2.49.0
PATCH v2 9/11 can: kvaser_usb: Expose device information via devlink info_get()
In reply to Jimmy AssarssonExpose device information via devlink info_get():
* Serial number
* Firmware version
* Hardware revision
* EAN (product number)
Example output:
$ devlink dev usb/1-1.2:1.0
$ devlink dev info
usb/1-1.2:1.0:
driver kvaser_usb
serial_number 1020
versions:
fixed:
board.rev 1
board.id 7330130009653
running:
fw 3.22.527---
Changes in v2:
- Add two space indentation to terminal output.
Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#m31ee4aad13ee29d5559b56fdce842609ae4f67c5
.../can/usb/kvaser_usb/kvaser_usb_devlink.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +53 -0
@@ -6,5 +6,58 @@#include <net/devlink.h> +#include "kvaser_usb.h" + +#define KVASER_USB_EAN_MSB 0x00073301 + +static int kvaser_usb_devlink_info_get (struct devlink *devlink, +struct devlink_info_req *req, +struct netlink_ext_ack *extack) +{ +struct kvaser_usb *dev =devlink_priv (devlink); +char buf[] ="73301XXXXXXXXXX" ; +int ret; + +if (dev->serial_number) { +snprintf (buf,sizeof (buf),"%u" , dev->serial_number); + ret =devlink_info_serial_number_put (req, buf); +if (ret) +return ret; + } + +if (dev->fw_version.major) { +snprintf (buf,sizeof (buf),"%u.%u.%u" , + dev->fw_version.major, + dev->fw_version.minor, + dev->fw_version.build); + ret =devlink_info_version_running_put (req, +DEVLINK_INFO_VERSION_GENERIC_FW , + buf); +if (ret) +return ret; + } + +if (dev->hw_revision) { +snprintf (buf,sizeof (buf),"%u" , dev->hw_revision); + ret =devlink_info_version_fixed_put (req, +DEVLINK_INFO_VERSION_GENERIC_BOARD_REV , + buf); +if (ret) +return ret; + } + +if (dev->ean[1 ] ==KVASER_USB_EAN_MSB ) { +snprintf (buf,sizeof (buf),"%x%08x" , dev->ean[1 ], dev->ean[0 ]); + ret =devlink_info_version_fixed_put (req, +DEVLINK_INFO_VERSION_GENERIC_BOARD_ID , + buf); +if (ret) +return ret; + } + +return 0 ; +} +const struct devlink_ops kvaser_usb_devlink_ops = { + .info_get = kvaser_usb_devlink_info_get, };
Signature · 1 line
2.49.0
PATCH v2 10/11 can: kvaser_usb: Add devlink port support
In reply to Jimmy AssarssonRegister each CAN channel of the device as an devlink physical port. This makes it easier to get device information for a given network interface (i.e. can2).
Example output:
$ devlink dev usb/1-1.3:1.0
$ devlink port usb/1-1.3:1.0/0: type eth netdev can0 flavour physical port 0 splittable false usb/1-1.3:1.0/1: type eth netdev can1 flavour physical port 1 splittable false
$ devlink port show can1 usb/1-1.3:1.0/1: type eth netdev can1 flavour physical port 0 splittable false
$ devlink dev info
usb/1-1.3:1.0:
driver kvaser_usb
serial_number 1020
versions:
fixed:
board.rev 1
board.id 7330130009653
running:
fw 3.22.527$ ethtool -i can1 driver: kvaser_usb version: 6.12.10-arch1-1 firmware-version: 3.22.527 expansion-rom-version: bus-info: 1-1.3:1.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no
---
Changes in v2:
- Add two space indentation to terminal output.
Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#m31ee4aad13ee29d5559b56fdce842609ae4f67c5
drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 4 +++ .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 15 ++++++++--- .../can/usb/kvaser_usb/kvaser_usb_devlink.c | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +4 -0
@@ -131,6 +131,7 @@ struct kvaser_usb {struct kvaser_usb_net_priv {struct can_priv can; +struct devlink_port devlink_port;struct can_berr_counter bec;/* subdriver-specific data */
@@ -229,6 +230,9 @@ extern const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops;extern const struct devlink_ops kvaser_usb_devlink_ops; +int kvaser_usb_devlink_port_register (struct kvaser_usb_net_priv *priv); +void kvaser_usb_devlink_port_unregister (struct kvaser_usb_net_priv *priv); +void kvaser_usb_unlink_tx_urbs (struct kvaser_usb_net_priv *priv); int kvaser_usb_recv_cmd(const struct kvaser_usb *dev, void *cmd, int len,
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +12 -3
@@ -818,6 +818,7 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev)if (ops->dev_remove_channel) ops->dev_remove_channel (priv); +kvaser_usb_devlink_port_unregister (priv);free_candev (priv->netdev); } }
@@ -891,20 +892,28 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)if (ops->dev_init_channel) { err = ops->dev_init_channel (priv);if (err) - goto err; + goto candev_free; + } + + err =kvaser_usb_devlink_port_register (priv); +if (err) { +dev_err (&dev->intf->dev,"Failed to register devlink port\n" ); + goto candev_free; } err =register_candev (netdev);if (err) {dev_err (&dev->intf->dev,"Failed to register CAN device\n" ); - goto err; + goto unregister_devlink_port; }netdev_dbg (netdev,"device registered\n" );return 0 ; -err: +unregister_devlink_port: +kvaser_usb_devlink_port_unregister (priv); +candev_free:free_candev (netdev); dev->nets[channel] =NULL ;return err;
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +25 -0
@@ -4,6 +4,7 @@* Copyright (C) 2025 KVASER AB, Sweden. All rights reserved. */ +#include <linux/netdevice.h> #include <net/devlink.h> #include "kvaser_usb.h"
@@ -61,3 +62,27 @@ static int kvaser_usb_devlink_info_get(struct devlink *devlink,const struct devlink_ops kvaser_usb_devlink_ops = { .info_get = kvaser_usb_devlink_info_get, }; + +int kvaser_usb_devlink_port_register (struct kvaser_usb_net_priv *priv) +{ +int ret; +struct devlink_port_attrs attrs = { + .flavour =DEVLINK_PORT_FLAVOUR_PHYSICAL , + .phys.port_number = priv->channel, + }; +devlink_port_attrs_set (&priv->devlink_port, &attrs); + + ret =devlink_port_register (priv_to_devlink (priv->dev), + &priv->devlink_port, priv->channel); +if (ret) +return ret; + +SET_NETDEV_DEVLINK_PORT (priv->netdev, &priv->devlink_port); + +return 0 ; +} + +void kvaser_usb_devlink_port_unregister (struct kvaser_usb_net_priv *priv) +{ +devlink_port_unregister (&priv->devlink_port); +}
Signature · 1 line
2.49.0
PATCH v2 11/11 Documentation: devlink: add devlink documentation for the kvaser_usb driver
In reply to Jimmy AssarssonList the version information reported by the kvaser_usb driver through devlink.
---
Changes in v2:
- New in v2. Suggested by Vincent Mailhol [1]
[1] https://lore.kernel.org/linux-can/[email protected]/T/#mb9ede2edcf5f7adcb76bc6331f5f27bafb79294f
--- Documentation/networking/devlink/index.rst | 1 + .../networking/devlink/kvaser_usb.rst | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/networking/devlink/kvaser_usb.rst
Documentation/networking/devlink/index.rst +1 -0
@@ -85,6 +85,7 @@ parameters, info versions, and other features it supports. ionic ice ixgbe + kvaser_usb mlx4 mlx5 mlxsw
Documentation/networking/devlink/kvaser_usb.rst new file +33 -0
@@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================== +kvaser_usb devlink support +========================== + +This document describes the devlink features implemented by the +``kvaser_usb`` device driver. + +Info versions +============= + +The ``kvaser_usb`` driver reports the following versions + +.. list-table:: devlink info versions implemented + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``fw`` + - running + - Version of the firmware running on the device. Also available + through ``ethtool -i`` as ``firmware-version``. + * - ``board.rev`` + - fixed + - The device hardware revision. + * - ``board.id`` + - fixed + - The device EAN (product number). + * - ``serial_number`` + - fixed + - The device serial number.
Signature · 1 line
2.49.0
Simon Horman
reviewerRe: [PATCH v2 01/11] can: kvaser_usb: Add support to control CAN LEDs on device
In reply to Jimmy AssarssonQuoted 3 lines · Jimmy Assarsson
Add support to turn on/off CAN LEDs on device.
Signed-off-by Jimmy Assarsson <[email protected]>
...
Quoted 1 line
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +0
-0
...
Quoted 13 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +13
-0+static int kvaser_usb_hydra_set_led (struct kvaser_usb_net_priv *priv, +enum kvaser_usb_led_state state, +u16 duration_ms) +{ +struct kvaser_usb *dev = priv->dev; +struct kvaser_cmd *cmd; +int ret; + + cmd =kzalloc (sizeof (*cmd),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + + cmd->header.cmd_no =CMD_LED_ACTION_REQ ;
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +10
-0+kvaser_usb_hydra_set_cmd_dest_he (cmd, dev->card_data.hydra.sysdbg_he); +kvaser_usb_hydra_set_cmd_transid (cmd,kvaser_usb_hydra_get_next_transid (dev)); + + cmd->led_action_req.duration_ms =cpu_to_le16 (duration_ms); + cmd->led_action_req.action = state | +FIELD_PREP (KVASER_USB_HYDRA_LED_IDX_MASK , +KVASER_USB_HYDRA_LED_YELLOW_CH0_IDX + +KVASER_USB_HYDRA_LEDS_PER_CHANNEL * priv->channel); + + ret =kvaser_usb_send_cmd (dev, cmd,kvaser_usb_hydra_cmd_size (cmd));
When building this file with GCC 15.1.0 with KCFLAGS=-Warray-bounds I see the following:
In file included from ./include/linux/byteorder/little_endian.h:5,
from ./arch/x86/include/uapi/asm/byteorder.h:5,
from ./include/linux/bitfield.h:12,
from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:15:
In function 'kvaser_usb_hydra_cmd_size',
inlined from 'kvaser_usb_hydra_set_led' at drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1993:38:
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:532:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds=]
532 | ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
./include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:532:23: note: in expansion of macro 'le16_to_cpu'
532 | ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
| ^~~~~~~~~~~
In file included from ./include/linux/fs.h:46,
from ./include/linux/compat.h:17,
from ./arch/x86/include/asm/ia32.h:7,
from ./arch/x86/include/asm/elf.h:10,
from ./include/linux/elf.h:6,
from ./include/linux/module.h:19,
from ./include/linux/device/driver.h:21,
from ./include/linux/device.h:32,
from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:17:
In function 'kmalloc_noprof',
inlined from 'kzalloc_noprof' at ./include/linux/slab.h:1039:9,
inlined from 'kvaser_usb_hydra_set_led' at drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1979:8:
./include/linux/slab.h:905:24: note: object of size 32 allocated by '__kmalloc_cache_noprof'
905 | return __kmalloc_cache_noprof(
| ^~~~~~~~~~~~~~~~~~~~~~~
906 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
907 | flags, size);
| ~~~~~~~~~~~~if (cmd->header.cmd_no == CMD_EXTENDED) ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
GCC seems to know that:
* cmd was allocated sizeof(*cmd) = 32 bytes
* struct kvaser_cmd_ext is larger than this (96 bytes)
And it thinks that cmd->header.cmd_no might be CMD_EXTENDED. This is not true, becuae .cmd_no is set to CMD_LED_ACTION_REQ earlier in kvaser_usb_hydra_set_led. But still, GCC produces a big fat warning.
On the one hand we might say this is a shortcoming in GCC, a position I agree with. But on the other hand, we might follow the pattern used elsewhere in this file for similar functions, which seems to make GCC happy, I guess, and it is strictly a guess, because less context is needed for it to analyse things correctly.
That is, do this:
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +3 -1
@@ -1974,6 +1974,7 @@ static int kvaser_usb_hydra_set_led(struct kvaser_usb_net_priv *priv, {struct kvaser_usb *dev = priv->dev;struct kvaser_cmd *cmd; +size_t cmd_len;int ret; cmd =kzalloc (sizeof (*cmd),GFP_KERNEL );
@@ -1981,6 +1982,7 @@ static int kvaser_usb_hydra_set_led(struct kvaser_usb_net_priv *priv,return -ENOMEM ; cmd->header.cmd_no =CMD_LED_ACTION_REQ ; + cmd_len =kvaser_usb_hydra_cmd_size (cmd);kvaser_usb_hydra_set_cmd_dest_he (cmd, dev->card_data.hydra.sysdbg_he);kvaser_usb_hydra_set_cmd_transid (cmd,kvaser_usb_hydra_get_next_transid (dev));
@@ -1990,7 +1992,7 @@ static int kvaser_usb_hydra_set_led(struct kvaser_usb_net_priv *priv,KVASER_USB_HYDRA_LED_YELLOW_CH0_IDX + KVASER_USB_HYDRA_LEDS_PER_CHANNEL * priv->channel); - ret =kvaser_usb_send_cmd (dev, cmd,kvaser_usb_hydra_cmd_size (cmd)); + ret =kvaser_usb_send_cmd (dev, cmd, cmd_len);kfree (cmd);return ret;
Quoted 4 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +4
-0+kfree (cmd); + +return ret; +}
...
Re: [PATCH v2 09/11] can: kvaser_usb: Expose device information via devlink info_get()
In reply to Jimmy Assarsson+CC: Simon
Quoted 37 lines · Jimmy Assarsson
Expose device information via devlink
info_get():
* Serial number
* Firmware version
* Hardware revision
* EAN (product number)Example output:
$ devlink dev usb/1-1.2:1.0$ devlink dev info usb/1-1.2:1.0: driver kvaser_usb serial_number 1020 versions: fixed: board.rev 1 board.id 7330130009653 running: fw 3.22.527Signed-off-by Jimmy Assarsson <[email protected]>---
Changes in v2:
- Add two space indentation to terminal output.
Suggested by Vincent Mailhol [1][1] https://lore.kernel.org/linux-can/[email protected]/T/#m31ee4aad13ee29d5559b56fdce842609ae4f67c5
.../can/usb/kvaser_usb/kvaser_usb_devlink.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +0
-0
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c line 9
Quoted 4 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +1
-0@@ -6,5 +6,58 @@#include <net/devlink.h> +#include "kvaser_usb.h"
I guess this has the same issue as the one pointed by Simon here:
Quoted 43 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +43
-0+#define KVASER_USB_EAN_MSB 0x00073301 + +static int kvaser_usb_devlink_info_get (struct devlink *devlink, +struct devlink_info_req *req, +struct netlink_ext_ack *extack) +{ +struct kvaser_usb *dev =devlink_priv (devlink); +char buf[] ="73301XXXXXXXXXX" ; +int ret; + +if (dev->serial_number) { +snprintf (buf,sizeof (buf),"%u" , dev->serial_number); + ret =devlink_info_serial_number_put (req, buf); +if (ret) +return ret; + } + +if (dev->fw_version.major) { +snprintf (buf,sizeof (buf),"%u.%u.%u" , + dev->fw_version.major, + dev->fw_version.minor, + dev->fw_version.build); + ret =devlink_info_version_running_put (req, +DEVLINK_INFO_VERSION_GENERIC_FW , + buf); +if (ret) +return ret; + } + +if (dev->hw_revision) { +snprintf (buf,sizeof (buf),"%u" , dev->hw_revision); + ret =devlink_info_version_fixed_put (req, +DEVLINK_INFO_VERSION_GENERIC_BOARD_REV , + buf); +if (ret) +return ret; + } + +if (dev->ean[1 ] ==KVASER_USB_EAN_MSB ) { +snprintf (buf,sizeof (buf),"%x%08x" , dev->ean[1 ], dev->ean[0 ]); + ret =devlink_info_version_fixed_put (req, +DEVLINK_INFO_VERSION_GENERIC_BOARD_ID , + buf);
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c line 63
Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_devlink.c +8
-0+if (ret) +return ret; + } + +return 0 ; +} +const struct devlink_ops kvaser_usb_devlink_ops = { + .info_get = kvaser_usb_devlink_info_get, };
Yours sincerely,
Vincent Mailhol
Re: [PATCH v2 11/11] Documentation: devlink: add devlink documentation for the kvaser_usb driver
In reply to Jimmy AssarssonQuoted 20 lines · Jimmy Assarsson
List the version information reported by the
kvaser_usbdriver through devlink.Signed-off-by Jimmy Assarsson <[email protected]>---
Changes in v2:
- New in v2. Suggested by Vincent Mailhol [1][1] https://lore.kernel.org/linux-can/[email protected]/T/#mb9ede2edcf5f7adcb76bc6331f5f27bafb79294f
--- Documentation/networking/devlink/index.rst | 1 + .../networking/devlink/kvaser_usb.rst | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/networking/devlink/kvaser_usb.rstDocumentation/networking/devlink/index.rst +0
-0
Documentation/networking/devlink/index.rst parameters, info versions, and other features it supports. · line 88
Quoted 4 lines
Documentation/networking/devlink/index.rst +1
-0@@ -85,6 +85,7 @@ parameters, info versions, and other features it supports. ionic ice ixgbe + kvaser_usb
This will create a tiny merge conflict when applying both the kvaser_pciefd and this series.
I think it would be smoother if you rebase either of these on top of the other. Just add a note in the cover letter of which one should be merged first.
Yours sincerely,
Vincent Mailhol
Quoted 3 lines · Jimmy Assarsson
This patch series simplifies the process of identifying which network interface (can0..canX) corresponds to which physical CAN channel on Kvaser USB based CAN interfaces.
Same as for the kvaser_pciefd, there is a tiny transient issue on a missing header include. The rest is OK, so, for the full series:
Yours sincerely,
Vincent Mailhol
Re: [PATCH v2 01/11] can: kvaser_usb: Add support to control CAN LEDs on device
In reply to Simon HormanQuoted 84 lines · Simon Horman
Quoted 3 lines · Jimmy Assarsson
Add support to turn on/off CAN LEDs on device.
Signed-off-by Jimmy Assarsson <[email protected]>...
Quoted 1 line
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +0
-0...
Quoted 13 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +13
-0+static int kvaser_usb_hydra_set_led (struct kvaser_usb_net_priv *priv, +enum kvaser_usb_led_state state, +u16 duration_ms) +{ +struct kvaser_usb *dev = priv->dev; +struct kvaser_cmd *cmd; +int ret; + + cmd =kzalloc (sizeof (*cmd),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + + cmd->header.cmd_no =CMD_LED_ACTION_REQ ;drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +10
-0+kvaser_usb_hydra_set_cmd_dest_he (cmd, dev->card_data.hydra.sysdbg_he); +kvaser_usb_hydra_set_cmd_transid (cmd,kvaser_usb_hydra_get_next_transid (dev)); + + cmd->led_action_req.duration_ms =cpu_to_le16 (duration_ms); + cmd->led_action_req.action = state | +FIELD_PREP (KVASER_USB_HYDRA_LED_IDX_MASK , +KVASER_USB_HYDRA_LED_YELLOW_CH0_IDX + +KVASER_USB_HYDRA_LEDS_PER_CHANNEL * priv->channel); + + ret =kvaser_usb_send_cmd (dev, cmd,kvaser_usb_hydra_cmd_size (cmd));When building this file with GCC 15.1.0 with KCFLAGS=-Warray-bounds I see the following:
In file included from ./include/linux/byteorder/little_endian.h:5, from ./arch/x86/include/uapi/asm/byteorder.h:5, from ./include/linux/bitfield.h:12, from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:15: In function 'kvaser_usb_hydra_cmd_size', inlined from 'kvaser_usb_hydra_set_led' at drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1993:38: drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:532:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds=] 532 | ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len); ./include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu' 37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) | ^ drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:532:23: note: in expansion of macro 'le16_to_cpu' 532 | ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len); | ^~~~~~~~~~~ In file included from ./include/linux/fs.h:46, from ./include/linux/compat.h:17, from ./arch/x86/include/asm/ia32.h:7, from ./arch/x86/include/asm/elf.h:10, from ./include/linux/elf.h:6, from ./include/linux/module.h:19, from ./include/linux/device/driver.h:21, from ./include/linux/device.h:32, from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:17: In function 'kmalloc_noprof', inlined from 'kzalloc_noprof' at ./include/linux/slab.h:1039:9, inlined from 'kvaser_usb_hydra_set_led' at drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1979:8: ./include/linux/slab.h:905:24: note: object of size 32 allocated by '__kmalloc_cache_noprof' 905 | return __kmalloc_cache_noprof( | ^~~~~~~~~~~~~~~~~~~~~~~ 906 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index], | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 907 | flags, size); | ~~~~~~~~~~~~ if (cmd->header.cmd_no == CMD_EXTENDED) ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);GCC seems to know that:
* cmd was allocatedsizeof(*cmd)= 32 bytes
* structkvaser_cmd_extis larger than this (96 bytes)And it thinks that
cmd->header.cmd_nomight beCMD_EXTENDED. This is not true, becuae .cmd_no is set toCMD_LED_ACTION_REQearlier inkvaser_usb_hydra_set_led. But still, GCC produces a big fat warning.
Quoted 5 lines
On the one hand we might say this is a shortcoming in GCC, a position I agree with. But on the other hand, we might follow the pattern used elsewhere in this file for similar functions, which seems to make GCC happy, I guess, and it is strictly a guess, because less context is needed for it to analyse things correctly.
Thanks for finding this!
Marc Kleine-Budde actually sorted this out for other commands some years ago [1], but I had completely forgotten.
[1] https://lore.kernel.org/all/[email protected]
...
Quoted 6 lines · Vincent Mailhol
Quoted 3 lines · Jimmy Assarsson
This patch series simplifies the process of identifying which network interface (can0..canX) corresponds to which physical CAN channel on Kvaser USB based CAN interfaces.
Quoted 8 lines
Same as for the
kvaser_pciefd, there is a tiny transient issue on a missing header include. The rest is OK, so, for the full series:Reviewed-by Vincent Mailhol <[email protected]>Yours sincerely,
Vincent Mailhol
Think all issues should be resolved.
Thanks for reviewing!
Best regards,
jimmy
Simon Horman
reviewerRe: [PATCH v2 01/11] can: kvaser_usb: Add support to control CAN LEDs on device
In reply to Jimmy AssarssonQuoted 2 lines · Jimmy Assarsson
Quoted 1 line · Simon Horman
On Thu, Jul 24, 2025 at 11:24:55AM +0200, Jimmy Assarsson wrote:
...
Quoted 15 lines
Quoted 9 lines
GCC seems to know that:
* cmd was allocatedsizeof(*cmd)= 32 bytes
* structkvaser_cmd_extis larger than this (96 bytes)And it thinks that
cmd->header.cmd_nomight beCMD_EXTENDED. This is not true, becuae .cmd_no is set toCMD_LED_ACTION_REQearlier inkvaser_usb_hydra_set_led. But still, GCC produces a big fat warning.Quoted 5 lines
On the one hand we might say this is a shortcoming in GCC, a position I agree with. But on the other hand, we might follow the pattern used elsewhere in this file for similar functions, which seems to make GCC happy, I guess, and it is strictly a guess, because less context is needed for it to analyse things correctly.
Quoted 6 lines
Thanks for finding this!
Marc Kleine-Budde actually sorted this out for other commands some years ago [1], but I had completely forgotten.
Nice, thanks for digging that up.