Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge patch series "can: esd_usb: More preparation before supporting esd CAN-USB/3 (addendum)"

Frank Jungclaus <frank.jungclaus@esd.eu> 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/20230519195600.420644-1-frank.jungclaus@esd.eu

Link: https://lore.kernel.org/r/20230523173105.3175086-1-frank.jungclaus@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

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