@@ -43,16 +43,15 @@ MODULE_LICENSE("GPL v2");
43
43
#define ESD_USB_CMD_IDADD 6 /* also used for IDADD_REPLY */
44
44
45
45
/* esd CAN message flags - dlc field */
46
- #define ESD_RTR BIT(4)
47
-
46
+ #define ESD_USB_RTR BIT(4)
48
47
49
48
/* esd CAN message flags - id field */
50
49
#define ESD_USB_EXTID BIT(29)
51
50
#define ESD_USB_EVENT BIT(30)
52
51
#define ESD_USB_IDMASK GENMASK(28, 0)
53
52
54
53
/* esd CAN event ids */
55
- #define ESD_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */
54
+ #define ESD_USB_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */
56
55
57
56
/* baudrate message flags */
58
57
#define ESD_USB_LOM BIT(30) /* Listen Only Mode */
@@ -67,23 +66,23 @@ MODULE_LICENSE("GPL v2");
67
66
#define ESD_USB_TRIPLE_SAMPLES BIT(23)
68
67
69
68
/* esd IDADD message */
70
- #define ESD_USB_ID_ENABLE 0x80
69
+ #define ESD_USB_ID_ENABLE BIT(7)
71
70
#define ESD_USB_MAX_ID_SEGMENT 64
72
71
73
72
/* SJA1000 ECC register (emulated by usb firmware) */
74
- #define ESD_USB_SJA1000_ECC_SEG 0x1F
75
- #define ESD_USB_SJA1000_ECC_DIR 0x20
76
- #define ESD_USB_SJA1000_ECC_ERR 0x06
73
+ #define ESD_USB_SJA1000_ECC_SEG GENMASK(4, 0)
74
+ #define ESD_USB_SJA1000_ECC_DIR BIT(5)
75
+ #define ESD_USB_SJA1000_ECC_ERR BIT(2, 1)
77
76
#define ESD_USB_SJA1000_ECC_BIT 0x00
78
- #define ESD_USB_SJA1000_ECC_FORM 0x40
79
- #define ESD_USB_SJA1000_ECC_STUFF 0x80
80
- #define ESD_USB_SJA1000_ECC_MASK 0xc0
77
+ #define ESD_USB_SJA1000_ECC_FORM BIT(6)
78
+ #define ESD_USB_SJA1000_ECC_STUFF BIT(7)
79
+ #define ESD_USB_SJA1000_ECC_MASK GENMASK(7, 6)
81
80
82
81
/* esd bus state event codes */
83
- #define ESD_USB_BUSSTATE_MASK 0xc0
84
- #define ESD_USB_BUSSTATE_WARN 0x40
85
- #define ESD_USB_BUSSTATE_ERRPASSIVE 0x80
86
- #define ESD_USB_BUSSTATE_BUSOFF 0xc0
82
+ #define ESD_USB_BUSSTATE_MASK GENMASK(7, 6)
83
+ #define ESD_USB_BUSSTATE_WARN BIT(6)
84
+ #define ESD_USB_BUSSTATE_ERRPASSIVE BIT(7)
85
+ #define ESD_USB_BUSSTATE_BUSOFF GENMASK(7, 6)
87
86
88
87
#define ESD_USB_RX_BUFFER_SIZE 1024
89
88
#define ESD_USB_MAX_RX_URBS 4
@@ -228,7 +227,7 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
228
227
struct sk_buff * skb ;
229
228
u32 id = le32_to_cpu (msg -> rx .id ) & ESD_USB_IDMASK ;
230
229
231
- if (id == ESD_EV_CAN_ERROR_EXT ) {
230
+ if (id == ESD_USB_EV_CAN_ERROR_EXT ) {
232
231
u8 state = msg -> rx .ev_can_err_ext .status ;
233
232
u8 ecc = msg -> rx .ev_can_err_ext .ecc ;
234
233
@@ -341,13 +340,13 @@ static void esd_usb_rx_can_msg(struct esd_usb_net_priv *priv,
341
340
}
342
341
343
342
cf -> can_id = id & ESD_USB_IDMASK ;
344
- can_frame_set_cc_len (cf , msg -> rx .dlc & ~ESD_RTR ,
343
+ can_frame_set_cc_len (cf , msg -> rx .dlc & ~ESD_USB_RTR ,
345
344
priv -> can .ctrlmode );
346
345
347
346
if (id & ESD_USB_EXTID )
348
347
cf -> can_id |= CAN_EFF_FLAG ;
349
348
350
- if (msg -> rx .dlc & ESD_RTR ) {
349
+ if (msg -> rx .dlc & ESD_USB_RTR ) {
351
350
cf -> can_id |= CAN_RTR_FLAG ;
352
351
} else {
353
352
for (i = 0 ; i < cf -> len ; i ++ )
@@ -652,9 +651,9 @@ static int esd_usb_start(struct esd_usb_net_priv *priv)
652
651
msg -> filter .net = priv -> index ;
653
652
msg -> filter .option = ESD_USB_ID_ENABLE ; /* start with segment 0 */
654
653
for (i = 0 ; i < ESD_USB_MAX_ID_SEGMENT ; i ++ )
655
- msg -> filter .mask [i ] = cpu_to_le32 (0xffffffff );
654
+ msg -> filter .mask [i ] = cpu_to_le32 (GENMASK ( 31 , 0 ) );
656
655
/* enable 29bit extended IDs */
657
- msg -> filter .mask [ESD_USB_MAX_ID_SEGMENT ] = cpu_to_le32 (0x00000001 );
656
+ msg -> filter .mask [ESD_USB_MAX_ID_SEGMENT ] = cpu_to_le32 (BIT ( 0 ) );
658
657
659
658
err = esd_usb_send_msg (dev , msg );
660
659
if (err )
@@ -767,7 +766,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb,
767
766
msg -> tx .id = cpu_to_le32 (cf -> can_id & CAN_ERR_MASK );
768
767
769
768
if (cf -> can_id & CAN_RTR_FLAG )
770
- msg -> tx .dlc |= ESD_RTR ;
769
+ msg -> tx .dlc |= ESD_USB_RTR ;
771
770
772
771
if (cf -> can_id & CAN_EFF_FLAG )
773
772
msg -> tx .id |= cpu_to_le32 (ESD_USB_EXTID );
@@ -796,7 +795,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb,
796
795
context -> echo_index = i ;
797
796
798
797
/* hnd must not be 0 - MSB is stripped in txdone handling */
799
- msg -> tx .hnd = 0x80000000 | i ; /* returned in TX done message */
798
+ msg -> tx .hnd = BIT ( 31 ) | i ; /* returned in TX done message */
800
799
801
800
usb_fill_bulk_urb (urb , dev -> udev , usb_sndbulkpipe (dev -> udev , 2 ), buf ,
802
801
msg -> hdr .len * sizeof (u32 ), /* convert to # of bytes */
0 commit comments