Re: [PATCH can-next 10/15] can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/29/24 11:55, Vincent MAILHOL wrote:
On Sat. 29 June 2024 at 04:56, Jimmy Assarsson <extja@xxxxxxxxxx> wrote:
For usbcan devices (M16C), add struct usbcan_cmd_tx_acknowledge for Tx ACK
commands and struct usbcan_cmd_clk_overflow_event for clock overflow event
commands.

Signed-off-by: Jimmy Assarsson <extja@xxxxxxxxxx>
---
  .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 22 +++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index c0a8713d8cf2..98bd6cfca2ca 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -242,6 +242,13 @@ struct leaf_cmd_tx_acknowledge {
         u8 padding[2];
  } __packed;

+struct usbcan_cmd_tx_acknowledge {
+       u8 channel;
+       u8 tid;
+       __le16 time;
+       u8 padding[2];
+} __packed;
+
  struct leaf_cmd_can_error_event {
         u8 tid;
         u8 flags;
@@ -288,6 +295,12 @@ struct usbcan_cmd_error_event {
         __le16 padding;
  } __packed;

+struct usbcan_cmd_clk_overflow_event {
+       u8 tid;
+       u8 padding;
+       __le32 time;
+} __packed;
+
  struct kvaser_cmd_ctrl_mode {
         u8 tid;
         u8 channel;
@@ -363,6 +376,8 @@ struct kvaser_cmd {
                         struct usbcan_cmd_chip_state_event chip_state_event;
                         struct usbcan_cmd_can_error_event can_error_event;
                         struct usbcan_cmd_error_event error_event;
+                       struct usbcan_cmd_tx_acknowledge tx_ack;
+                       struct usbcan_cmd_clk_overflow_event clk_overflow_event;
                 } __packed usbcan;

                 struct kvaser_cmd_tx_can tx_can;
@@ -396,15 +411,14 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = {
         [CMD_START_CHIP_REPLY]          = kvaser_fsize(u.simple),
         [CMD_STOP_CHIP_REPLY]           = kvaser_fsize(u.simple),
         [CMD_GET_CARD_INFO_REPLY]       = kvaser_fsize(u.cardinfo),
-       [CMD_TX_ACKNOWLEDGE]            = kvaser_fsize(u.tx_acknowledge_header),
+       [CMD_TX_ACKNOWLEDGE]            = kvaser_fsize(u.usbcan.tx_ack),
         [CMD_GET_SOFTWARE_INFO_REPLY]   = kvaser_fsize(u.usbcan.softinfo),
         [CMD_RX_STD_MESSAGE]            = kvaser_fsize(u.usbcan.rx_can),
         [CMD_RX_EXT_MESSAGE]            = kvaser_fsize(u.usbcan.rx_can),
         [CMD_CHIP_STATE_EVENT]          = kvaser_fsize(u.usbcan.chip_state_event),
         [CMD_CAN_ERROR_EVENT]           = kvaser_fsize(u.usbcan.can_error_event),
         [CMD_ERROR_EVENT]               = kvaser_fsize(u.usbcan.error_event),
-       /* ignored events: */
-       [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY,
+       [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = kvaser_fsize(u.usbcan.clk_overflow_event),
  };

  /* Summary of a kvaser error event, for a unified Leaf/Usbcan error
@@ -1608,12 +1622,12 @@ static void kvaser_usb_leaf_handle_command(const struct kvaser_usb *dev,
                 kvaser_usb_leaf_get_busparams_reply(dev, cmd);
                 break;

-       /* Ignored commands */
         case CMD_USBCAN_CLOCK_OVERFLOW_EVENT:
                 if (dev->driver_info->family != KVASER_USBCAN)
                         goto warn;
                 break;

I did not understand this part. If the overflow event is now handled,
why do you still have the

   goto warn

?

The warning is for non-usbcan device (leaf), where this command is unexpected.

Shouldn't you dispatch the command here?

It's dispatched in the succeeding patch
can: kvaser_usb: leaf: Store MSB of timestamp [1]
I'll fix this in v2. I keep the "ignored events/commands" comments in this patch,
and move them to the proper patch.

Regards,
/jimmy

[1] https://lore.kernel.org/linux-can/20240701154936.92633-12-extja@xxxxxxxxxx/T/#u

+       /* Ignored commands */
         case CMD_FLUSH_QUEUE_REPLY:
                 if (dev->driver_info->family != KVASER_LEAF)
                         goto warn;
--
2.45.2






[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux