Skip to content

Commit

Permalink
can: kvaser_usb: replace run-time checks with struct kvaser_usb_drive…
Browse files Browse the repository at this point in the history
…r_info

commit 49f274c upstream.

Unify and move compile-time known information into new struct
kvaser_usb_driver_info, in favor of run-time checks.

All Kvaser USBcanII supports listen-only mode and error counter
reporting.

Link: https://lore.kernel.org/all/20220603083820.800246-2-extja@kvaser.com
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
[mkl: move struct kvaser_usb_driver_info into kvaser_usb_core.c]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jimmy Assarsson authored and gregkh committed Jul 12, 2022
1 parent 79af7be commit f439d08
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 135 deletions.
22 changes: 12 additions & 10 deletions drivers/net/can/usb/kvaser_usb/kvaser_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#define KVASER_USB_RX_BUFFER_SIZE 3072
#define KVASER_USB_MAX_NET_DEVICES 5

/* USB devices features */
#define KVASER_USB_HAS_SILENT_MODE BIT(0)
#define KVASER_USB_HAS_TXRX_ERRORS BIT(1)
/* Kvaser USB device quirks */
#define KVASER_USB_QUIRK_HAS_SILENT_MODE BIT(0)
#define KVASER_USB_QUIRK_HAS_TXRX_ERRORS BIT(1)

/* Device capabilities */
#define KVASER_USB_CAP_BERR_CAP 0x01
Expand Down Expand Up @@ -65,12 +65,7 @@ struct kvaser_usb_dev_card_data_hydra {
struct kvaser_usb_dev_card_data {
u32 ctrlmode_supported;
u32 capabilities;
union {
struct {
enum kvaser_usb_leaf_family family;
} leaf;
struct kvaser_usb_dev_card_data_hydra hydra;
};
struct kvaser_usb_dev_card_data_hydra hydra;
};

/* Context for an outstanding, not yet ACKed, transmission */
Expand All @@ -84,7 +79,7 @@ struct kvaser_usb {
struct usb_device *udev;
struct usb_interface *intf;
struct kvaser_usb_net_priv *nets[KVASER_USB_MAX_NET_DEVICES];
const struct kvaser_usb_dev_ops *ops;
const struct kvaser_usb_driver_info *driver_info;
const struct kvaser_usb_dev_cfg *cfg;

struct usb_endpoint_descriptor *bulk_in, *bulk_out;
Expand Down Expand Up @@ -166,6 +161,12 @@ struct kvaser_usb_dev_ops {
int *cmd_len, u16 transid);
};

struct kvaser_usb_driver_info {
u32 quirks;
enum kvaser_usb_leaf_family family;
const struct kvaser_usb_dev_ops *ops;
};

struct kvaser_usb_dev_cfg {
const struct can_clock clock;
const unsigned int timestamp_freq;
Expand All @@ -185,4 +186,5 @@ 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);

#endif /* KVASER_USB_H */

0 comments on commit f439d08

Please sign in to comment.