[RFC PATCH v2 2/2] net: include: mii: Refactor: Use bit ops for ADVERTISE_* bits

From: Csókás, Bence
Date: Thu Jun 06 2024 - 04:09:17 EST


Replace hex values with bit shift and __GENMASK() for readability

Cc: trivial@xxxxxxxxxx

Signed-off-by: "Csókás, Bence" <csokas.bence@xxxxxxxxx>
---

Notes:
Changes since v2:
* Replace BIT() with bit shift, as the macro is not exported to userspace
* Use __GENMASK(), exported into userspace in 3c7a8e190bc5

include/uapi/linux/mii.h | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/mii.h b/include/uapi/linux/mii.h
index 33e1b0c717e4..f03ac3b35850 100644
--- a/include/uapi/linux/mii.h
+++ b/include/uapi/linux/mii.h
@@ -69,23 +69,23 @@
#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */

/* Advertisement control register. */
-#define ADVERTISE_SLCT 0x001f /* Selector bits */
-#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
-#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
-#define ADVERTISE_1000XFULL 0x0020 /* Try for 1000BASE-X full-duplex */
-#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
-#define ADVERTISE_1000XHALF 0x0040 /* Try for 1000BASE-X half-duplex */
-#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
-#define ADVERTISE_1000XPAUSE 0x0080 /* Try for 1000BASE-X pause */
-#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
-#define ADVERTISE_1000XPSE_ASYM 0x0100 /* Try for 1000BASE-X asym pause */
-#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
-#define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */
-#define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */
-#define ADVERTISE_RESV 0x1000 /* Unused... */
-#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
-#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
-#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
+#define ADVERTISE_SLCT GENMASK(4, 0) /* Selector bits */
+#define ADVERTISE_CSMA BIT(0) /* Only selector supported */
+#define ADVERTISE_10HALF BIT(5) /* Try for 10mbps half-duplex */
+#define ADVERTISE_1000XFULL BIT(5) /* Try for 1000BASE-X full-duplex */
+#define ADVERTISE_10FULL BIT(6) /* Try for 10mbps full-duplex */
+#define ADVERTISE_1000XHALF BIT(6) /* Try for 1000BASE-X half-duplex */
+#define ADVERTISE_100HALF BIT(7) /* Try for 100mbps half-duplex */
+#define ADVERTISE_1000XPAUSE BIT(7) /* Try for 1000BASE-X pause */
+#define ADVERTISE_100FULL BIT(8) /* Try for 100mbps full-duplex */
+#define ADVERTISE_1000XPSE_ASYM BIT(8) /* Try for 1000BASE-X asym pause */
+#define ADVERTISE_100BASE4 BIT(9) /* Try for 100mbps 4k packets */
+#define ADVERTISE_PAUSE_CAP BIT(10) /* Try for pause */
+#define ADVERTISE_PAUSE_ASYM BIT(11) /* Try for asymmetric pause */
+#define ADVERTISE_RESV BIT(12) /* Unused... */
+#define ADVERTISE_RFAULT BIT(13) /* Say we can detect faults */
+#define ADVERTISE_LPACK BIT(14) /* Ack link partners response */
+#define ADVERTISE_NPAGE BIT(15) /* Next page bit */

#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
ADVERTISE_CSMA)
--
2.34.1