Skip to content

Commit 280eba3

Browse files
Jimmy Assarssonmarckleinebudde
authored andcommitted
can: kvaser_usb: Store the different firmware version components in a struct
Store 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. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://patch.msgid.link/20250725123452.41-7-extja@kvaser.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 7506789 commit 280eba3

4 files changed

Lines changed: 29 additions & 9 deletions

File tree

drivers/net/can/usb/kvaser_usb/kvaser_usb.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#define KVASER_USB_CAP_EXT_CAP 0x02
4848
#define KVASER_USB_HYDRA_CAP_EXT_CMD 0x04
4949

50+
#define KVASER_USB_SW_VERSION_MAJOR_MASK GENMASK(31, 24)
51+
#define KVASER_USB_SW_VERSION_MINOR_MASK GENMASK(23, 16)
52+
#define KVASER_USB_SW_VERSION_BUILD_MASK GENMASK(15, 0)
53+
5054
struct kvaser_usb_dev_cfg;
5155

5256
enum kvaser_usb_leaf_family {
@@ -83,6 +87,12 @@ struct kvaser_usb_tx_urb_context {
8387
u32 echo_index;
8488
};
8589

90+
struct kvaser_usb_fw_version {
91+
u8 major;
92+
u8 minor;
93+
u16 build;
94+
};
95+
8696
struct kvaser_usb_busparams {
8797
__le32 bitrate;
8898
u8 tseg1;
@@ -101,7 +111,7 @@ struct kvaser_usb {
101111
struct usb_endpoint_descriptor *bulk_in, *bulk_out;
102112
struct usb_anchor rx_submitted;
103113

104-
u32 fw_version;
114+
struct kvaser_usb_fw_version fw_version;
105115
unsigned int nchannels;
106116
/* @max_tx_urbs: Firmware-reported maximum number of outstanding,
107117
* not yet ACKed, transmissions on this device. This value is

drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,6 @@ static int kvaser_usb_probe(struct usb_interface *intf,
963963
if (WARN_ON(!dev->cfg))
964964
return -ENODEV;
965965

966-
dev_dbg(&intf->dev, "Firmware version: %d.%d.%d\n",
967-
((dev->fw_version >> 24) & 0xff),
968-
((dev->fw_version >> 16) & 0xff),
969-
(dev->fw_version & 0xffff));
970-
971966
dev_dbg(&intf->dev, "Max outstanding tx = %d URBs\n", dev->max_tx_urbs);
972967

973968
err = ops->dev_get_card_info(dev);

drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,7 @@ static int kvaser_usb_hydra_get_software_details(struct kvaser_usb *dev)
18391839
size_t cmd_len;
18401840
int err;
18411841
u32 flags;
1842+
u32 fw_version;
18421843
struct kvaser_usb_dev_card_data *card_data = &dev->card_data;
18431844

18441845
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
@@ -1863,7 +1864,10 @@ static int kvaser_usb_hydra_get_software_details(struct kvaser_usb *dev)
18631864
if (err)
18641865
goto end;
18651866

1866-
dev->fw_version = le32_to_cpu(cmd->sw_detail_res.sw_version);
1867+
fw_version = le32_to_cpu(cmd->sw_detail_res.sw_version);
1868+
dev->fw_version.major = FIELD_GET(KVASER_USB_SW_VERSION_MAJOR_MASK, fw_version);
1869+
dev->fw_version.minor = FIELD_GET(KVASER_USB_SW_VERSION_MINOR_MASK, fw_version);
1870+
dev->fw_version.build = FIELD_GET(KVASER_USB_SW_VERSION_BUILD_MASK, fw_version);
18671871
flags = le32_to_cpu(cmd->sw_detail_res.sw_flags);
18681872

18691873
if (flags & KVASER_USB_HYDRA_SW_FLAG_FW_BAD) {

drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,13 @@ static int kvaser_usb_leaf_send_simple_cmd(const struct kvaser_usb *dev,
741741
static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev,
742742
const struct leaf_cmd_softinfo *softinfo)
743743
{
744+
u32 fw_version;
744745
u32 sw_options = le32_to_cpu(softinfo->sw_options);
745746

746-
dev->fw_version = le32_to_cpu(softinfo->fw_version);
747+
fw_version = le32_to_cpu(softinfo->fw_version);
748+
dev->fw_version.major = FIELD_GET(KVASER_USB_SW_VERSION_MAJOR_MASK, fw_version);
749+
dev->fw_version.minor = FIELD_GET(KVASER_USB_SW_VERSION_MINOR_MASK, fw_version);
750+
dev->fw_version.build = FIELD_GET(KVASER_USB_SW_VERSION_BUILD_MASK, fw_version);
747751
dev->max_tx_urbs = le16_to_cpu(softinfo->max_outstanding_tx);
748752

749753
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)
784788
{
785789
struct kvaser_cmd cmd;
786790
int err;
791+
u32 fw_version;
787792

788793
err = kvaser_usb_leaf_send_simple_cmd(dev, CMD_GET_SOFTWARE_INFO, 0);
789794
if (err)
@@ -798,7 +803,13 @@ static int kvaser_usb_leaf_get_software_info_inner(struct kvaser_usb *dev)
798803
kvaser_usb_leaf_get_software_info_leaf(dev, &cmd.u.leaf.softinfo);
799804
break;
800805
case KVASER_USBCAN:
801-
dev->fw_version = le32_to_cpu(cmd.u.usbcan.softinfo.fw_version);
806+
fw_version = le32_to_cpu(cmd.u.usbcan.softinfo.fw_version);
807+
dev->fw_version.major = FIELD_GET(KVASER_USB_SW_VERSION_MAJOR_MASK,
808+
fw_version);
809+
dev->fw_version.minor = FIELD_GET(KVASER_USB_SW_VERSION_MINOR_MASK,
810+
fw_version);
811+
dev->fw_version.build = FIELD_GET(KVASER_USB_SW_VERSION_BUILD_MASK,
812+
fw_version);
802813
dev->max_tx_urbs =
803814
le16_to_cpu(cmd.u.usbcan.softinfo.max_outstanding_tx);
804815
dev->cfg = &kvaser_usb_leaf_usbcan_dev_cfg;

0 commit comments

Comments
 (0)