Skip to content

Commit cf8462a

Browse files
Merge patch series "can: esd_usb: More preparation before supporting esd CAN-USB/3 (addendum)"
Frank Jungclaus <[email protected]> says: While trying to again merge my code changes for CAN-USB/3, I came across some more places where it could make sense to change them analogous to the previous clean-up patch series [1]. [1] [PATCH v2 0/6] can: esd_usb: More preparation before supporting esd CAN-USB/3 Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2 parents b74c3ab + 8a99f2a commit cf8462a

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

drivers/net/can/usb/esd_usb.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@ MODULE_LICENSE("GPL v2");
4343
#define ESD_USB_CMD_IDADD 6 /* also used for IDADD_REPLY */
4444

4545
/* esd CAN message flags - dlc field */
46-
#define ESD_RTR BIT(4)
47-
46+
#define ESD_USB_RTR BIT(4)
4847

4948
/* esd CAN message flags - id field */
5049
#define ESD_USB_EXTID BIT(29)
5150
#define ESD_USB_EVENT BIT(30)
5251
#define ESD_USB_IDMASK GENMASK(28, 0)
5352

5453
/* 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 */
5655

5756
/* baudrate message flags */
5857
#define ESD_USB_LOM BIT(30) /* Listen Only Mode */
@@ -67,23 +66,23 @@ MODULE_LICENSE("GPL v2");
6766
#define ESD_USB_TRIPLE_SAMPLES BIT(23)
6867

6968
/* esd IDADD message */
70-
#define ESD_USB_ID_ENABLE 0x80
69+
#define ESD_USB_ID_ENABLE BIT(7)
7170
#define ESD_USB_MAX_ID_SEGMENT 64
7271

7372
/* 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)
7776
#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)
8180

8281
/* 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)
8786

8887
#define ESD_USB_RX_BUFFER_SIZE 1024
8988
#define ESD_USB_MAX_RX_URBS 4
@@ -228,7 +227,7 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
228227
struct sk_buff *skb;
229228
u32 id = le32_to_cpu(msg->rx.id) & ESD_USB_IDMASK;
230229

231-
if (id == ESD_EV_CAN_ERROR_EXT) {
230+
if (id == ESD_USB_EV_CAN_ERROR_EXT) {
232231
u8 state = msg->rx.ev_can_err_ext.status;
233232
u8 ecc = msg->rx.ev_can_err_ext.ecc;
234233

@@ -341,13 +340,13 @@ static void esd_usb_rx_can_msg(struct esd_usb_net_priv *priv,
341340
}
342341

343342
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,
345344
priv->can.ctrlmode);
346345

347346
if (id & ESD_USB_EXTID)
348347
cf->can_id |= CAN_EFF_FLAG;
349348

350-
if (msg->rx.dlc & ESD_RTR) {
349+
if (msg->rx.dlc & ESD_USB_RTR) {
351350
cf->can_id |= CAN_RTR_FLAG;
352351
} else {
353352
for (i = 0; i < cf->len; i++)
@@ -652,9 +651,9 @@ static int esd_usb_start(struct esd_usb_net_priv *priv)
652651
msg->filter.net = priv->index;
653652
msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */
654653
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));
656655
/* 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));
658657

659658
err = esd_usb_send_msg(dev, msg);
660659
if (err)
@@ -767,7 +766,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb,
767766
msg->tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK);
768767

769768
if (cf->can_id & CAN_RTR_FLAG)
770-
msg->tx.dlc |= ESD_RTR;
769+
msg->tx.dlc |= ESD_USB_RTR;
771770

772771
if (cf->can_id & CAN_EFF_FLAG)
773772
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,
796795
context->echo_index = i;
797796

798797
/* 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 */
800799

801800
usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf,
802801
msg->hdr.len * sizeof(u32), /* convert to # of bytes */

0 commit comments

Comments
 (0)