[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-2-e0b9f7c18b37@redhat.com>
Date: Thu, 24 Aug 2023 13:32:53 -0500
From: Andrew Halaney <ahalaney@...hat.com>
To: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Richard Cochran <richardcochran@...il.com>
Cc: netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Andrew Halaney <ahalaney@...hat.com>
Subject: [PATCH net-next 2/7] net: stmmac: Use NSEC_PER_SEC for hwtstamp
calculations
This makes it more clear what unit conversions are happening.
Signed-off-by: Andrew Halaney <ahalaney@...hat.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 6dcf8582a70e..29fd51bb853d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -36,12 +36,12 @@ static void config_sub_second_increment(void __iomem *ioaddr,
* to mid-range = 2^31 when the remainder of this division is zero,
* which will make the accumulator overflow once every 2 ptp_clock
* cycles, adding twice the number of nanoseconds of a clock cycle :
- * 2000000000ULL / ptp_clock.
+ * 2 * NSEC_PER_SEC / ptp_clock.
*/
if (value & PTP_TCR_TSCFUPDT)
- data = (2000000000ULL / ptp_clock);
+ data = (2 * NSEC_PER_SEC / ptp_clock);
else
- data = (1000000000ULL / ptp_clock);
+ data = (NSEC_PER_SEC / ptp_clock);
/* 0.465ns accuracy */
if (!(value & PTP_TCR_TSCTRLSSR))
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 67e4f65f0f68..ba38ca284e26 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -849,7 +849,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
stmmac_config_sub_second_increment(priv, priv->ptpaddr,
priv->plat->clk_ptp_rate,
xmac, &sub_second_inc);
- temp = div_u64(1000000000ULL, sub_second_inc);
+ temp = div_u64(NSEC_PER_SEC, sub_second_inc);
/* Store sub second increment for later use */
priv->sub_second_inc = sub_second_inc;
--
2.41.0
Powered by blists - more mailing lists