Skip to contentSkip to conversation

net: ch9200: use BIT macro for bitmask constants

PATCH In review Qasim Ijaz 2 participants 4 messages Jun 6, 2025

Subsystems (4)
lore
Share & tools
lore

Qasim Ijaz

author
#0 lore raw

PATCH 1/1 net: ch9200: use BIT macro for bitmask constants

Use the BIT() macro for bitmask constants.

---
 drivers/net/usb/ch9200.c | 50 ++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 25 deletions(-)
drivers/net/usb/ch9200.c +25 -25
index a206ffa76f1b..bfe27a7dcbb4 100644
@@ -59,42 +59,42 @@
  *
  * Note: bits 13 and 15 are reserved
  */
-#define LOOPBACK		(0x01 << 14)
-#define BASE100X		(0x01 << 12)
-#define MBPS_10			(0x01 << 11)
-#define DUPLEX_MODE		(0x01 << 10)
-#define PAUSE_FRAME		(0x01 << 9)
-#define PROMISCUOUS		(0x01 << 8)
-#define MULTICAST		(0x01 << 7)
-#define BROADCAST		(0x01 << 6)
-#define HASH			(0x01 << 5)
-#define APPEND_PAD		(0x01 << 4)
-#define APPEND_CRC		(0x01 << 3)
-#define TRANSMITTER_ACTION	(0x01 << 2)
-#define RECEIVER_ACTION		(0x01 << 1)
-#define DMA_ACTION		(0x01 << 0)
+#define LOOPBACK		BIT(14)
+#define BASE100X		BIT(12)
+#define MBPS_10			BIT(11)
+#define DUPLEX_MODE		BIT(10)
+#define PAUSE_FRAME		BIT(9)
+#define PROMISCUOUS		BIT(8)
+#define MULTICAST		BIT(7)
+#define BROADCAST		BIT(6)
+#define HASH			BIT(5)
+#define APPEND_PAD		BIT(4)
+#define APPEND_CRC		BIT(3)
+#define TRANSMITTER_ACTION	BIT(2)
+#define RECEIVER_ACTION		BIT(1)
+#define DMA_ACTION		BIT(0)
 
 /* Status register bits
  *
  * Note: bits 7-15 are reserved
  */
-#define ALIGNMENT		(0x01 << 6)
-#define FIFO_OVER_RUN		(0x01 << 5)
-#define FIFO_UNDER_RUN		(0x01 << 4)
-#define RX_ERROR		(0x01 << 3)
-#define RX_COMPLETE		(0x01 << 2)
-#define TX_ERROR		(0x01 << 1)
-#define TX_COMPLETE		(0x01 << 0)
+#define ALIGNMENT		BIT(6)
+#define FIFO_OVER_RUN		BIT(5)
+#define FIFO_UNDER_RUN		BIT(4)
+#define RX_ERROR		BIT(3)
+#define RX_COMPLETE		BIT(2)
+#define TX_ERROR		BIT(1)
+#define TX_COMPLETE		BIT(0)
 
 /* FIFO depth register bits
  *
  * Note: bits 6 and 14 are reserved
  */
 
-#define ETH_TXBD		(0x01 << 15)
-#define ETN_TX_FIFO_DEPTH	(0x01 << 8)
-#define ETH_RXBD		(0x01 << 7)
-#define ETH_RX_FIFO_DEPTH	(0x01 << 0)
+#define ETH_TXBD		BIT(15)
+#define ETN_TX_FIFO_DEPTH	BIT(8)
+#define ETH_RXBD		BIT(7)
+#define ETH_RX_FIFO_DEPTH	BIT(0)
 
 static int control_read(struct usbnet *dev,
 			unsigned char request, unsigned short value,
Signature · 1 line
2.39.5
#1 lore raw
Quoted 1 line · Qasim Ijaz

Use the BIT() macro for bitmask constants.

What you fail to answer is the question 'Why?'.

This driver is old and stable. It has in fact had no feature development work done on it since 2015. All the patches since then have been tree wide sort of changes.

Most would consider your change just pointless churn. It does not fix anything which is broken. So why make this change?

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#clean-up-patches

Do you have the hardware? If you do, maybe consider porting it to phylib?

Andrew

author
#2 lore raw
Quoted 4 lines · Andrew Lunn
Quoted 1 line · Qasim Ijaz

Use the BIT() macro for bitmask constants.

What you fail to answer is the question 'Why?'.

I made this change mainly as a small clean-up, it makes the code a tad bit easier to read.

Quoted 7 lines

This driver is old and stable. It has in fact had no feature development work done on it since 2015. All the patches since then have been tree wide sort of changes.

Most would consider your change just pointless churn. It does not fix anything which is broken. So why make this change?

Yea that makes sense.

Quoted 2 lines

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#clean-up-patches

Ah i see thank you, I will keep this in mind next time.

Quoted 4 lines

Do you have the hardware? If you do, maybe consider porting it to phylib?

I don't, I did try to buy it but after searching for it but I couldn't find it anywhere. I do however have the hardware for the this:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/usb/dm9601.c

Would the phylib porting apply to this too? If so I would love to work on it.

Thanks
Qasim

Quoted 1 line

Andrew

#3 lore raw
Quoted 7 lines

I don't, I did try to buy it but after searching for it but I couldn't find it anywhere. I do however have the hardware for the this:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/usb/dm9601.c

Would the phylib porting apply to this too? If so I would love to work on it.

Yes, please do work on that. Having the hardware makes a big difference. And you are likely to learn a lot more with hardware you can test with.

Andrew