Commit cf8462a8 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

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.euSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents b74c3abf 8a99f2ad
......@@ -43,8 +43,7 @@ MODULE_LICENSE("GPL v2");
#define ESD_USB_CMD_IDADD 6 /* also used for IDADD_REPLY */
/* esd CAN message flags - dlc field */
#define ESD_RTR BIT(4)
#define ESD_USB_RTR BIT(4)
/* esd CAN message flags - id field */
#define ESD_USB_EXTID BIT(29)
......@@ -52,7 +51,7 @@ MODULE_LICENSE("GPL v2");
#define ESD_USB_IDMASK GENMASK(28, 0)
/* esd CAN event ids */
#define ESD_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */
#define ESD_USB_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */
/* baudrate message flags */
#define ESD_USB_LOM BIT(30) /* Listen Only Mode */
......@@ -67,23 +66,23 @@ MODULE_LICENSE("GPL v2");
#define ESD_USB_TRIPLE_SAMPLES BIT(23)
/* esd IDADD message */
#define ESD_USB_ID_ENABLE 0x80
#define ESD_USB_ID_ENABLE BIT(7)
#define ESD_USB_MAX_ID_SEGMENT 64
/* SJA1000 ECC register (emulated by usb firmware) */
#define ESD_USB_SJA1000_ECC_SEG 0x1F
#define ESD_USB_SJA1000_ECC_DIR 0x20
#define ESD_USB_SJA1000_ECC_ERR 0x06
#define ESD_USB_SJA1000_ECC_SEG GENMASK(4, 0)
#define ESD_USB_SJA1000_ECC_DIR BIT(5)
#define ESD_USB_SJA1000_ECC_ERR BIT(2, 1)
#define ESD_USB_SJA1000_ECC_BIT 0x00
#define ESD_USB_SJA1000_ECC_FORM 0x40
#define ESD_USB_SJA1000_ECC_STUFF 0x80
#define ESD_USB_SJA1000_ECC_MASK 0xc0
#define ESD_USB_SJA1000_ECC_FORM BIT(6)
#define ESD_USB_SJA1000_ECC_STUFF BIT(7)
#define ESD_USB_SJA1000_ECC_MASK GENMASK(7, 6)
/* esd bus state event codes */
#define ESD_USB_BUSSTATE_MASK 0xc0
#define ESD_USB_BUSSTATE_WARN 0x40
#define ESD_USB_BUSSTATE_ERRPASSIVE 0x80
#define ESD_USB_BUSSTATE_BUSOFF 0xc0
#define ESD_USB_BUSSTATE_MASK GENMASK(7, 6)
#define ESD_USB_BUSSTATE_WARN BIT(6)
#define ESD_USB_BUSSTATE_ERRPASSIVE BIT(7)
#define ESD_USB_BUSSTATE_BUSOFF GENMASK(7, 6)
#define ESD_USB_RX_BUFFER_SIZE 1024
#define ESD_USB_MAX_RX_URBS 4
......@@ -228,7 +227,7 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
struct sk_buff *skb;
u32 id = le32_to_cpu(msg->rx.id) & ESD_USB_IDMASK;
if (id == ESD_EV_CAN_ERROR_EXT) {
if (id == ESD_USB_EV_CAN_ERROR_EXT) {
u8 state = msg->rx.ev_can_err_ext.status;
u8 ecc = msg->rx.ev_can_err_ext.ecc;
......@@ -341,13 +340,13 @@ static void esd_usb_rx_can_msg(struct esd_usb_net_priv *priv,
}
cf->can_id = id & ESD_USB_IDMASK;
can_frame_set_cc_len(cf, msg->rx.dlc & ~ESD_RTR,
can_frame_set_cc_len(cf, msg->rx.dlc & ~ESD_USB_RTR,
priv->can.ctrlmode);
if (id & ESD_USB_EXTID)
cf->can_id |= CAN_EFF_FLAG;
if (msg->rx.dlc & ESD_RTR) {
if (msg->rx.dlc & ESD_USB_RTR) {
cf->can_id |= CAN_RTR_FLAG;
} else {
for (i = 0; i < cf->len; i++)
......@@ -652,9 +651,9 @@ static int esd_usb_start(struct esd_usb_net_priv *priv)
msg->filter.net = priv->index;
msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */
for (i = 0; i < ESD_USB_MAX_ID_SEGMENT; i++)
msg->filter.mask[i] = cpu_to_le32(0xffffffff);
msg->filter.mask[i] = cpu_to_le32(GENMASK(31, 0));
/* enable 29bit extended IDs */
msg->filter.mask[ESD_USB_MAX_ID_SEGMENT] = cpu_to_le32(0x00000001);
msg->filter.mask[ESD_USB_MAX_ID_SEGMENT] = cpu_to_le32(BIT(0));
err = esd_usb_send_msg(dev, msg);
if (err)
......@@ -767,7 +766,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb,
msg->tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK);
if (cf->can_id & CAN_RTR_FLAG)
msg->tx.dlc |= ESD_RTR;
msg->tx.dlc |= ESD_USB_RTR;
if (cf->can_id & CAN_EFF_FLAG)
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,
context->echo_index = i;
/* hnd must not be 0 - MSB is stripped in txdone handling */
msg->tx.hnd = 0x80000000 | i; /* returned in TX done message */
msg->tx.hnd = BIT(31) | i; /* returned in TX done message */
usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf,
msg->hdr.len * sizeof(u32), /* convert to # of bytes */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment