[PATCH] net: stmmac: use us_to_ktime() where appropriate

Xichao Zhao posted 1 patch 1 month, 1 week ago
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] net: stmmac: use us_to_ktime() where appropriate
Posted by Xichao Zhao 1 month, 1 week ago
STMMAC_COAL_TIMER(x) is more suitable for using the us_to_ktime().
This can make the code more concise and enhance readability.
Therefore, replace ns_to_ktime() with us_to_ktime().

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f1abf4242cd2..dcbd180c1985 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -144,7 +144,7 @@ static void stmmac_init_fs(struct net_device *dev);
 static void stmmac_exit_fs(struct net_device *dev);
 #endif
 
-#define STMMAC_COAL_TIMER(x) (ns_to_ktime((x) * NSEC_PER_USEC))
+#define STMMAC_COAL_TIMER(x) (us_to_ktime(x))
 
 int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled)
 {
-- 
2.34.1
Re: [PATCH] net: stmmac: use us_to_ktime() where appropriate
Posted by Andrew Lunn 1 month, 1 week ago
On Wed, Aug 27, 2025 at 10:07:55AM +0800, Xichao Zhao wrote:
> STMMAC_COAL_TIMER(x) is more suitable for using the us_to_ktime().
> This can make the code more concise and enhance readability.
> Therefore, replace ns_to_ktime() with us_to_ktime().
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f1abf4242cd2..dcbd180c1985 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -144,7 +144,7 @@ static void stmmac_init_fs(struct net_device *dev);
>  static void stmmac_exit_fs(struct net_device *dev);
>  #endif
>  
> -#define STMMAC_COAL_TIMER(x) (ns_to_ktime((x) * NSEC_PER_USEC))
> +#define STMMAC_COAL_TIMER(x) (us_to_ktime(x))

Now that the macro does nothing, please just use us_time_ktime()
inline and remove the macro.

Also:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html


    Andrew

---
pw-bot: cr