Skip to content

Commit 49f274c

Browse files
Jimmy Assarssonmarckleinebudde
authored andcommitted
can: kvaser_usb: replace run-time checks with struct kvaser_usb_driver_info
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/[email protected] Suggested-by: Marc Kleine-Budde <[email protected]> Cc: [email protected] Signed-off-by: Jimmy Assarsson <[email protected]> [mkl: move struct kvaser_usb_driver_info into kvaser_usb_core.c] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 4c33336 commit 49f274c

File tree

3 files changed

+172
-148
lines changed

3 files changed

+172
-148
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#define KVASER_USB_RX_BUFFER_SIZE 3072
3636
#define KVASER_USB_MAX_NET_DEVICES 5
3737

38-
/* USB devices features */
39-
#define KVASER_USB_HAS_SILENT_MODE BIT(0)
40-
#define KVASER_USB_HAS_TXRX_ERRORS BIT(1)
38+
/* Kvaser USB device quirks */
39+
#define KVASER_USB_QUIRK_HAS_SILENT_MODE BIT(0)
40+
#define KVASER_USB_QUIRK_HAS_TXRX_ERRORS BIT(1)
4141

4242
/* Device capabilities */
4343
#define KVASER_USB_CAP_BERR_CAP 0x01
@@ -65,12 +65,7 @@ struct kvaser_usb_dev_card_data_hydra {
6565
struct kvaser_usb_dev_card_data {
6666
u32 ctrlmode_supported;
6767
u32 capabilities;
68-
union {
69-
struct {
70-
enum kvaser_usb_leaf_family family;
71-
} leaf;
72-
struct kvaser_usb_dev_card_data_hydra hydra;
73-
};
68+
struct kvaser_usb_dev_card_data_hydra hydra;
7469
};
7570

7671
/* Context for an outstanding, not yet ACKed, transmission */
@@ -83,7 +78,7 @@ struct kvaser_usb {
8378
struct usb_device *udev;
8479
struct usb_interface *intf;
8580
struct kvaser_usb_net_priv *nets[KVASER_USB_MAX_NET_DEVICES];
86-
const struct kvaser_usb_dev_ops *ops;
81+
const struct kvaser_usb_driver_info *driver_info;
8782
const struct kvaser_usb_dev_cfg *cfg;
8883

8984
struct usb_endpoint_descriptor *bulk_in, *bulk_out;
@@ -165,6 +160,12 @@ struct kvaser_usb_dev_ops {
165160
u16 transid);
166161
};
167162

163+
struct kvaser_usb_driver_info {
164+
u32 quirks;
165+
enum kvaser_usb_leaf_family family;
166+
const struct kvaser_usb_dev_ops *ops;
167+
};
168+
168169
struct kvaser_usb_dev_cfg {
169170
const struct can_clock clock;
170171
const unsigned int timestamp_freq;
@@ -184,4 +185,5 @@ int kvaser_usb_send_cmd_async(struct kvaser_usb_net_priv *priv, void *cmd,
184185
int len);
185186

186187
int kvaser_usb_can_rx_over_error(struct net_device *netdev);
188+
187189
#endif /* KVASER_USB_H */

0 commit comments

Comments
 (0)