Skip to contentSkip to conversation

can: kvaser_usb: CAN clock frequency regression

PATCH Superseded Jimmy Assarsson 2 participants 7 messages Jun 2, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover can: kvaser_usb: CAN clock frequency regression

When fixing the CAN clock frequency,
fb12797ab1fe ("can: kvaser_usb: get CAN clock frequency from device"), I introduced a regression.

For Leaf devices based on M32C, the firmware expects bittiming parameters calculated for 16MHz clock. Regardless of the actual clock frequency.

This regression affects M32C based Leaf devices with non-16MHz clock.

Also correct the bittiming constants in kvaser_usb_leaf.c, where the limits are different depending on which firmware/device being used.

Once merged to mainline, I'll backport these fixes for the stable kernels.

Jimmy Assarsson (2):
can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression
can: kvaser_usb: kvaser_usb_leaf: Fix bittiming limits

 drivers/net/can/usb/kvaser_usb/kvaser_usb.h   | 17 ++++
 .../net/can/usb/kvaser_usb/kvaser_usb_core.c  | 20 +++-
 .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 14 +--
 .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 95 +++++++++++--------
 4 files changed, 89 insertions(+), 57 deletions(-)

--
2.36.1

#1 lore raw

PATCH 1/2 can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression

The firmware of M32C based Leaf devices expects bittiming parameters calculated for 16MHz clock.
Since we use the actual clock frequency of the device, the device may end up with wrong bittiming parameters, depending on user requested parameters.

This regression affects M32C based Leaf devices with non-16MHz clock.

Fixes fb12797ab1fe ("can: kvaser_usb: get CAN clock frequency from device")
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb.h   |  4 +++
 .../net/can/usb/kvaser_usb/kvaser_usb_core.c  | 20 +++++++++++----
 .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 25 ++++++++++++-------
 3 files changed, 35 insertions(+), 14 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +4 -0
index 3a49257f9fa6..cb588228d7a1 100644
@@ -44,6 +44,9 @@
 #define KVASER_USB_CAP_EXT_CAP			0x02
 #define KVASER_USB_HYDRA_CAP_EXT_CMD		0x04
 
+/* Quriks */
+#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ BIT(0)
+
 struct kvaser_usb_dev_cfg;
 
 enum kvaser_usb_leaf_family {
@@ -65,6 +68,7 @@ struct kvaser_usb_dev_card_data_hydra {
 struct kvaser_usb_dev_card_data {
 	u32 ctrlmode_supported;
 	u32 capabilities;
+	u32 quirks;
 	union {
 		struct {
 			enum kvaser_usb_leaf_family family;
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +15 -5
index e67658b53d02..5880e9719c9d 100644
@@ -94,10 +94,14 @@
 
 static inline bool kvaser_is_leaf(const struct usb_device_id *id)
 {
-	return (id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
-		id->idProduct <= USB_CAN_R_PRODUCT_ID) ||
-		(id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
-		 id->idProduct <= USB_LEAF_PRODUCT_ID_END);
+	return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
+	       id->idProduct <= USB_CAN_R_PRODUCT_ID;
+}
+
+static inline bool kvaser_is_leafimx(const struct usb_device_id *id)
+{
+	return id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
+	       id->idProduct <= USB_LEAF_PRODUCT_ID_END;
 }
 
 static inline bool kvaser_is_usbcan(const struct usb_device_id *id)
@@ -113,7 +117,7 @@ static inline bool kvaser_is_hydra(const struct usb_device_id *id)
 }
 
 static const struct usb_device_id kvaser_usb_table[] = {
-	/* Leaf USB product IDs */
+	/* Leaf M32C USB product IDs */
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_DEVEL_PRODUCT_ID) },
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_PRODUCT_ID) },
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_PRO_PRODUCT_ID),
@@ -161,6 +165,8 @@ static const struct usb_device_id kvaser_usb_table[] = {
 		.driver_info = KVASER_USB_HAS_TXRX_ERRORS },
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_CAN_R_PRODUCT_ID),
 		.driver_info = KVASER_USB_HAS_TXRX_ERRORS },
+
+	/* Leaf i.MX28 USB product IDs */
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LITE_V2_PRODUCT_ID) },
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_MINI_PCIE_HS_PRODUCT_ID) },
 	{ USB_DEVICE(KVASER_VENDOR_ID, USB_LEAF_LIGHT_HS_V2_OEM_PRODUCT_ID) },
@@ -737,6 +743,10 @@ static int kvaser_usb_probe(struct usb_interface *intf,
 	if (kvaser_is_leaf(id)) {
 		dev->card_data.leaf.family = KVASER_LEAF;
 		dev->ops = &kvaser_usb_leaf_dev_ops;
+		dev->card_data.quirks = KVASER_USB_QUIRK_IGNORE_CLK_FREQ;
+	} else if (kvaser_is_leafimx(id)) {
+		dev->card_data.leaf.family = KVASER_LEAF;
+		dev->ops = &kvaser_usb_leaf_dev_ops;
 	} else if (kvaser_is_usbcan(id)) {
 		dev->card_data.leaf.family = KVASER_USBCAN;
 		dev->ops = &kvaser_usb_leaf_dev_ops;
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +16 -9
index c805b999c543..68c698e3b2b2 100644
@@ -524,16 +524,23 @@ static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev,
 	dev->fw_version = le32_to_cpu(softinfo->fw_version);
 	dev->max_tx_urbs = le16_to_cpu(softinfo->max_outstanding_tx);
 
-	switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) {
-	case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK:
+	if (dev->card_data.quirks & KVASER_USB_QUIRK_IGNORE_CLK_FREQ) {
+		/* Firmware expects bittiming parameters calculated for 16MHz
+		 * clock, regardless of the actual clock
+		 */
 		dev->cfg = &kvaser_usb_leaf_dev_cfg_16mhz;
-		break;
-	case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK:
-		dev->cfg = &kvaser_usb_leaf_dev_cfg_24mhz;
-		break;
-	case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK:
-		dev->cfg = &kvaser_usb_leaf_dev_cfg_32mhz;
-		break;
+	} else {
+		switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) {
+		case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK:
+			dev->cfg = &kvaser_usb_leaf_dev_cfg_16mhz;
+			break;
+		case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK:
+			dev->cfg = &kvaser_usb_leaf_dev_cfg_24mhz;
+			break;
+		case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK:
+			dev->cfg = &kvaser_usb_leaf_dev_cfg_32mhz;
+			break;
+		}
 	}
 }
 
Signature · 1 line
2.36.1
#2 lore raw

Re: [PATCH 1/2] can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression

Quoted 6 lines · Jimmy Assarsson

The firmware of M32C based Leaf devices expects bittiming parameters calculated for 16MHz clock.
Since we use the actual clock frequency of the device, the device may end up with wrong bittiming parameters, depending on user requested parameters.

This regression affects M32C based Leaf devices with non-16MHz clock.

Oh. Thanks for the patch!

Quoted 14 lines
Fixes fb12797ab1fe ("can: kvaser_usb: get CAN clock frequency from device")
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb.h   |  4 +++
 .../net/can/usb/kvaser_usb/kvaser_usb_core.c  | 20 +++++++++++----
 .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 25 ++++++++++++-------
 3 files changed, 35 insertions(+), 14 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +0 -0
index 3a49257f9fa6..cb588228d7a1 100644

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

Quoted 4 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +1 -0
@@ -44,6 +44,9 @@
 #define KVASER_USB_CAP_EXT_CAP			0x02
 #define KVASER_USB_HYDRA_CAP_EXT_CMD		0x04
 
+/* Quriks */
      ^^^^^^

Typo

Quoted 24 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +3 -0
+#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ BIT(0)
+
 struct kvaser_usb_dev_cfg;
 
 enum kvaser_usb_leaf_family {
@@ -65,6 +68,7 @@ struct kvaser_usb_dev_card_data_hydra {
 struct kvaser_usb_dev_card_data {
 	u32 ctrlmode_supported;
 	u32 capabilities;
+	u32 quirks;
 	union {
 		struct {
 			enum kvaser_usb_leaf_family family;
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -3
index e67658b53d02..5880e9719c9d 100644
@@ -94,10 +94,14 @@
 
 static inline bool kvaser_is_leaf(const struct usb_device_id *id)
 {
-	return (id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
-		id->idProduct <= USB_CAN_R_PRODUCT_ID) ||
-		(id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&

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

Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +8 -1
-		 id->idProduct <= USB_LEAF_PRODUCT_ID_END);
+	return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
+	       id->idProduct <= USB_CAN_R_PRODUCT_ID;
+}
+
+static inline bool kvaser_is_leafimx(const struct usb_device_id *id)
+{
+	return id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
+	       id->idProduct <= USB_LEAF_PRODUCT_ID_END;
 }

Is this getting a bit complicated now?
In this driver we have:

1) struct usb_device_id::driver_info
2) kvaser_is_*()

which is used to set

3) dev->card_data.leaf.family
4) dev->ops

and now you're adding:

5) dev->card_data.quirks

which then affects

6) dev->cfg

The straight forward way would be to define a struct that describes the a device completely:

struct kvaser_driver_info {
       u32 quirks;        /* KVASER_USB_HAS_ */
       enum kvaser_usb_leaf_family;
       const struct kvaser_usb_dev_*ops;
       const struct kvaser_usb_dev_*cfg;
};

and then assign that to every device listed in the kvaser_usb_table.

Marc

Signature · 4 lines
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 |
#3 lore raw

Re: [PATCH 1/2] can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression

Quoted 27 lines · Marc Kleine-Budde
Quoted 6 lines · Jimmy Assarsson

The firmware of M32C based Leaf devices expects bittiming parameters calculated for 16MHz clock.
Since we use the actual clock frequency of the device, the device may end up with wrong bittiming parameters, depending on user requested parameters.

This regression affects M32C based Leaf devices with non-16MHz clock.

Oh. Thanks for the patch!

Quoted 17 lines
Fixes fb12797ab1fe ("can: kvaser_usb: get CAN clock frequency from device")
---
  drivers/net/can/usb/kvaser_usb/kvaser_usb.h   |  4 +++
  .../net/can/usb/kvaser_usb/kvaser_usb_core.c  | 20 +++++++++++----
  .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 25 ++++++++++++-------
  3 files changed, 35 insertions(+), 14 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +0 -0
index 3a49257f9fa6..cb588228d7a1 100644
@@ -44,6 +44,9 @@
  #define KVASER_USB_CAP_EXT_CAP			0x02
  #define KVASER_USB_HYDRA_CAP_EXT_CMD		0x04
 
Quoted 3 lines

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

Quoted 1 line
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +1 -0
+/* Quriks */
       ^^^^^^

Typo

Oops!

Quoted 57 lines
Quoted 24 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +3 -0
+#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ BIT(0)
+
  struct kvaser_usb_dev_cfg;
 
  enum kvaser_usb_leaf_family {
@@ -65,6 +68,7 @@ struct kvaser_usb_dev_card_data_hydra {
  struct kvaser_usb_dev_card_data {
  	u32 ctrlmode_supported;
  	u32 capabilities;
+	u32 quirks;
  	union {
  		struct {
  			enum kvaser_usb_leaf_family family;
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -3
index e67658b53d02..5880e9719c9d 100644
@@ -94,10 +94,14 @@
 
  static inline bool kvaser_is_leaf(const struct usb_device_id *id)
  {
-	return (id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
-		id->idProduct <= USB_CAN_R_PRODUCT_ID) ||
-		(id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&

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

Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +8 -1
-		 id->idProduct <= USB_LEAF_PRODUCT_ID_END);
+	return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
+	       id->idProduct <= USB_CAN_R_PRODUCT_ID;
+}
+
+static inline bool kvaser_is_leafimx(const struct usb_device_id *id)
+{
+	return id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
+	       id->idProduct <= USB_LEAF_PRODUCT_ID_END;
  }

Is this getting a bit complicated now?
In this driver we have:

1) struct usb_device_id::driver_info
2) kvaser_is_*()

which is used to set

3) dev->card_data.leaf.family
4) dev->ops

and now you're adding:

5) dev->card_data.quirks

which then affects

6) dev->cfg

The straight forward way would be to define a struct that describes the a device completely:

Quoted 8 lines
struct kvaser_driver_info {
        u32 quirks;        /* KVASER_USB_HAS_ */
        enum kvaser_usb_leaf_family;
        const struct kvaser_usb_dev_*ops;
        const struct kvaser_usb_dev_*cfg;
};

and then assign that to every device listed in the kvaser_usb_table.

Thanks for the feedback!
I agree, but I prefer if we can keep assigning dev->cfg based on the information that we get from the device. So we get:

struct kvaser_driver_info {
        u32 quirks;        /* KVASER_USB_HAS_ */
        enum kvaser_usb_leaf_family;
        const struct kvaser_usb_dev_*ops;
};

And quirks and family still affect dev->cfg.

Do you think this is OK?

Best regards,
jimmy

Quoted 1 line

Marc

#4 lore raw

Re: [PATCH 1/2] can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression

Quoted 50 lines · Jimmy Assarsson
Quoted 50 lines
Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -3
index e67658b53d02..5880e9719c9d 100644
@@ -94,10 +94,14 @@
  static inline bool kvaser_is_leaf(const struct usb_device_id *id)
  {
-	return (id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
-		id->idProduct <= USB_CAN_R_PRODUCT_ID) ||
-		(id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&

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

Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +8 -1
-		 id->idProduct <= USB_LEAF_PRODUCT_ID_END);
+	return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
+	       id->idProduct <= USB_CAN_R_PRODUCT_ID;
+}
+
+static inline bool kvaser_is_leafimx(const struct usb_device_id *id)
+{
+	return id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
+	       id->idProduct <= USB_LEAF_PRODUCT_ID_END;
  }

Is this getting a bit complicated now?
In this driver we have:

1) struct usb_device_id::driver_info
2) kvaser_is_*()

which is used to set

3) dev->card_data.leaf.family
4) dev->ops

and now you're adding:

5) dev->card_data.quirks

which then affects

6) dev->cfg

The straight forward way would be to define a struct that describes the a device completely:

struct kvaser_driver_info {
        u32 quirks;        /* KVASER_USB_HAS_ */
        enum kvaser_usb_leaf_family;
        const struct kvaser_usb_dev_*ops;
        const struct kvaser_usb_dev_*cfg;
};
Quoted 5 lines
Quoted 1 line

and then assign that to every device listed in the kvaser_usb_table.

Thanks for the feedback!
I agree, but I prefer if we can keep assigning dev->cfg based on the information that we get from the device.

Ok, if you cannot tell from the USB product ID.

Quoted 3 lines

So we get:
struct kvaser_driver_info {
u32 quirks; /* KVASER_USB_HAS_ */

That holds the existing quirks and the new one.

Quoted 4 lines
        enum kvaser_usb_leaf_family;
        const struct kvaser_usb_dev_*ops;
};

And quirks and family still affect dev->cfg.

...as is depends on sw_options read from the device?

regards,
Marc

Signature · 4 lines
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 |
#5 lore raw

Re: [PATCH 1/2] can: kvaser_usb: kvaser_usb_leaf: Fix CAN clock frequency regression

Quoted 51 lines · Marc Kleine-Budde
Quoted 50 lines · Jimmy Assarsson
Quoted 50 lines
Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +0 -3
index e67658b53d02..5880e9719c9d 100644
@@ -94,10 +94,14 @@
   static inline bool kvaser_is_leaf(const struct usb_device_id *id)
   {
-	return (id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
-		id->idProduct <= USB_CAN_R_PRODUCT_ID) ||
-		(id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&

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

Quoted 10 lines
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +8 -1
-		 id->idProduct <= USB_LEAF_PRODUCT_ID_END);
+	return id->idProduct >= USB_LEAF_DEVEL_PRODUCT_ID &&
+	       id->idProduct <= USB_CAN_R_PRODUCT_ID;
+}
+
+static inline bool kvaser_is_leafimx(const struct usb_device_id *id)
+{
+	return id->idProduct >= USB_LEAF_LITE_V2_PRODUCT_ID &&
+	       id->idProduct <= USB_LEAF_PRODUCT_ID_END;
   }

Is this getting a bit complicated now?
In this driver we have:

1) struct usb_device_id::driver_info
2) kvaser_is_*()

which is used to set

3) dev->card_data.leaf.family
4) dev->ops

and now you're adding:

5) dev->card_data.quirks

which then affects

6) dev->cfg

The straight forward way would be to define a struct that describes the a device completely:

struct kvaser_driver_info {
         u32 quirks;        /* KVASER_USB_HAS_ */
         enum kvaser_usb_leaf_family;
         const struct kvaser_usb_dev_*ops;
         const struct kvaser_usb_dev_*cfg;
};
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

and then assign that to every device listed in the kvaser_usb_table.

Thanks for the feedback!
I agree, but I prefer if we can keep assigning dev->cfg based on the information that we get from the device.

Ok, if you cannot tell from the USB product ID.

It should be possible, but it will eliminate the risk of me setting wrong cfg. I don't got access to all the different devices, especially not the old ones.

Quoted 5 lines
Quoted 3 lines

So we get:
struct kvaser_driver_info {
u32 quirks; /* KVASER_USB_HAS_ */

That holds the existing quirks and the new one.

Yep!

Quoted 6 lines
Quoted 4 lines
         enum kvaser_usb_leaf_family;
         const struct kvaser_usb_dev_*ops;
};

And quirks and family still affect dev->cfg.

...as is depends on sw_options read from the device?

Correct.

Best regards,
jimmy

#6 lore raw

PATCH 2/2 can: kvaser_usb: kvaser_usb_leaf: Fix bittiming limits

In reply to Jimmy Assarsson

Use correct bittiming limits depending on device. For devices based on USBcanII, Leaf M32C or Leaf i.MX28.

Fixes 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
Fixes b4f20130af23 ("can: kvaser_usb: add support for Kvaser Leaf v2 and usb mini PCIe")
Fixes f5d4abea3ce0 ("can: kvaser_usb: Add support for the USBcan-II family")
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb.h   | 13 ++++
 .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 14 +---
 .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 76 +++++++++++--------
 3 files changed, 57 insertions(+), 46 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +13 -0
index cb588228d7a1..8069a67881bb 100644
@@ -28,6 +28,7 @@
 
 #include <linux/can.h>
 #include <linux/can/dev.h>
+#include <linux/can/netlink.h>
 
 #define KVASER_USB_MAX_RX_URBS			4
 #define KVASER_USB_MAX_TX_URBS			128
@@ -188,4 +189,16 @@ int kvaser_usb_send_cmd_async(struct kvaser_usb_net_priv *priv, void *cmd,
 			      int len);
 
 int kvaser_usb_can_rx_over_error(struct net_device *netdev);
+
+static const struct can_bittiming_const kvaser_usb_flexc_bittiming_const = {
+	.name = "kvaser_usb_flex",
+	.tseg1_min = 4,
+	.tseg1_max = 16,
+	.tseg2_min = 2,
+	.tseg2_max = 8,
+	.sjw_max = 4,
+	.brp_min = 1,
+	.brp_max = 256,
+	.brp_inc = 1,
+};
 #endif /* KVASER_USB_H */
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +1 -13
index a26823c5b62a..faf901e7e568 100644
@@ -375,18 +375,6 @@ static const struct can_bittiming_const kvaser_usb_hydra_kcan_bittiming_c = {
 	.brp_inc = 1,
 };
 
-static const struct can_bittiming_const kvaser_usb_hydra_flexc_bittiming_c = {
-	.name = "kvaser_usb_flex",
-	.tseg1_min = 4,
-	.tseg1_max = 16,
-	.tseg2_min = 2,
-	.tseg2_max = 8,
-	.sjw_max = 4,
-	.brp_min = 1,
-	.brp_max = 256,
-	.brp_inc = 1,
-};
-
 static const struct can_bittiming_const kvaser_usb_hydra_rt_bittiming_c = {
 	.name = "kvaser_usb_rt",
 	.tseg1_min = 2,
@@ -2052,7 +2040,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_flexc = {
 		.freq = 24 * MEGA /* Hz */,
 	},
 	.timestamp_freq = 1,
-	.bittiming_const = &kvaser_usb_hydra_flexc_bittiming_c,
+	.bittiming_const = &kvaser_usb_flexc_bittiming_const,
 };
 
 static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_rt = {
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +43 -33

131 lines not on this page · raw message

Signature · 1 line
2.36.1