* [PATCH] net: phy: qcom: replace CDT poll magic numbers with named constants
@ 2026-01-15 16:57 Vinitha Vijayan
2026-01-15 17:23 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Vinitha Vijayan @ 2026-01-15 16:57 UTC (permalink / raw)
To: andrew; +Cc: netdev, kuba, davem, pabeni, linux-arm-msm, Vinitha Vijayan
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.
Signed-off-by: Vinitha Vijayan <vinithamvijayan723@gmail.com>
---
drivers/net/phy/qcom/qcom-phy-lib.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/qcom/qcom-phy-lib.c b/drivers/net/phy/qcom/qcom-phy-lib.c
index 965c2bb99a9b..cc4c6b254c62 100644
--- a/drivers/net/phy/qcom/qcom-phy-lib.c
+++ b/drivers/net/phy/qcom/qcom-phy-lib.c
@@ -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 <ansuelsmth@gmail.com>");
@@ -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;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: phy: qcom: replace CDT poll magic numbers with named constants
2026-01-15 16:57 [PATCH] net: phy: qcom: replace CDT poll magic numbers with named constants Vinitha Vijayan
@ 2026-01-15 17:23 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-01-15 17:23 UTC (permalink / raw)
To: Vinitha Vijayan; +Cc: netdev, kuba, davem, pabeni, linux-arm-msm
On Thu, Jan 15, 2026 at 10:27:18PM +0530, Vinitha Vijayan wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-15 17:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 16:57 [PATCH] net: phy: qcom: replace CDT poll magic numbers with named constants Vinitha Vijayan
2026-01-15 17:23 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox