Skip to content

Commit 33665fd

Browse files
Frank Jungclausmarckleinebudde
authored andcommitted
can: esd_usb: Make use of kernel macros BIT() and GENMASK()
Make use of kernel macros BIT() and GENMASK(). Signed-off-by: Frank Jungclaus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent b74c3ab commit 33665fd

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/net/can/usb/esd_usb.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ MODULE_LICENSE("GPL v2");
6767
#define ESD_USB_TRIPLE_SAMPLES BIT(23)
6868

6969
/* esd IDADD message */
70-
#define ESD_USB_ID_ENABLE 0x80
70+
#define ESD_USB_ID_ENABLE BIT(7)
7171
#define ESD_USB_MAX_ID_SEGMENT 64
7272

7373
/* 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
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)
7777
#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
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)
8181

8282
/* 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
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)
8787

8888
#define ESD_USB_RX_BUFFER_SIZE 1024
8989
#define ESD_USB_MAX_RX_URBS 4
@@ -652,9 +652,9 @@ static int esd_usb_start(struct esd_usb_net_priv *priv)
652652
msg->filter.net = priv->index;
653653
msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */
654654
for (i = 0; i < ESD_USB_MAX_ID_SEGMENT; i++)
655-
msg->filter.mask[i] = cpu_to_le32(0xffffffff);
655+
msg->filter.mask[i] = cpu_to_le32(GENMASK(31, 0));
656656
/* enable 29bit extended IDs */
657-
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));
658658

659659
err = esd_usb_send_msg(dev, msg);
660660
if (err)
@@ -796,7 +796,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb,
796796
context->echo_index = i;
797797

798798
/* hnd must not be 0 - MSB is stripped in txdone handling */
799-
msg->tx.hnd = 0x80000000 | i; /* returned in TX done message */
799+
msg->tx.hnd = BIT(31) | i; /* returned in TX done message */
800800

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

0 commit comments

Comments
 (0)