Skip to contentSkip to conversation

net: phy: qcom: replace CDT poll magic numbers with named constants

PATCH In review Vinitha Vijayan 2 participants 2 messages Jan 15

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: qcom: replace CDT poll magic numbers with named constants

Replace hard-coded poll interval and timeout values in at803x_cdt_wait_for_completion() with named macros.

This improves readability and documents the timing assumptions used by the cable diagnostic test without changing behavior.

---
 drivers/net/phy/qcom/qcom-phy-lib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/phy/qcom/qcom-phy-lib.c +6 -1
index 965c2bb99a9b..cc4c6b254c62 100644
@@ -9,6 +9,9 @@
 
 #include "qcom.h"
 
+#define AT803X_CDT_POLL_INTERVAL_US             30000
+#define AT803X_CDT_TIMEOUT_US                   100000
+
 MODULE_DESCRIPTION("Qualcomm PHY driver Common Functions");
 MODULE_AUTHOR("Matus Ujhelyi");
 MODULE_AUTHOR("Christian Marangi <[email protected]>");
@@ -484,7 +487,9 @@ int at803x_cdt_wait_for_completion(struct phy_device *phydev,
 	/* One test run takes about 25ms */
 	ret = phy_read_poll_timeout(phydev, AT803X_CDT, val,
 				    !(val & cdt_en),
-				    30000, 100000, true);
+				    AT803X_CDT_POLL_INTERVAL_US,
+				    AT803X_CDT_TIMEOUT_US,
+				    true);
 
 	return ret < 0 ? ret : 0;
 }
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 4 lines · Vinitha Vijayan

Replace hard-coded poll interval and timeout values in at803x_cdt_wait_for_completion() with named macros.

This improves readability

ret = phy_read_poll_timeout(phydev, AT803X_CDT, val,
!(val & cdt_en), 30000, 100000, true);

	ret = phy_read_poll_timeout(phydev, AT803X_CDT, val,
				    !(val & cdt_en),
				    AT803X_CDT_POLL_INTERVAL_US,
				    AT803X_CDT_TIMEOUT_US,
				    true);

Is it really more readable?

The point about magic values is that you cannot easily see what they mean. With BIT(4) is hard know that that means. But all the read_poll_timeout() functions are very similar. If you know one, you know them all. I know the poll interval is 30,000us and timeout happens after 100,000us. Using macros just means i need to go find the definition of the macro to know the timers used in this polling method.

Andrew

---
pw-bot: cr