netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ethernet: tlan: Convert to use jiffies macro
@ 2025-08-27  7:54 zhang.enpei
  2025-08-27 22:22 ` Jacob Keller
  2025-08-28 17:27 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: zhang.enpei @ 2025-08-27  7:54 UTC (permalink / raw)
  To: chessman; +Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

From: Zhang Enpei <zhang.enpei@zte.com.cn>

Use time_is_before_eq_jiffies macro instead of using jiffies directly to
handle wraparound.

Signed-off-by: Zhang Enpei <zhang.enpei@zte.com.cn>
---
 drivers/net/ethernet/ti/tlan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index a55b0f951181..7c5e51284942 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -1817,7 +1817,6 @@ static void tlan_timer(struct timer_list *t)
 {
 	struct tlan_priv	*priv = timer_container_of(priv, t, timer);
 	struct net_device	*dev = priv->dev;
-	u32		elapsed;
 	unsigned long	flags = 0;

 	priv->timer.function = NULL;
@@ -1844,8 +1843,7 @@ static void tlan_timer(struct timer_list *t)
 	case TLAN_TIMER_ACTIVITY:
 		spin_lock_irqsave(&priv->lock, flags);
 		if (priv->timer.function == NULL) {
-			elapsed = jiffies - priv->timer_set_at;
-			if (elapsed >= TLAN_TIMER_ACT_DELAY) {
+			if (time_is_before_eq_jiffies(priv->timer_set_at + TLAN_TIMER_ACT_DELAY)) {
 				tlan_dio_write8(dev->base_addr,
 						TLAN_LED_REG, TLAN_LED_LINK);
 			} else  {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] ethernet: tlan: Convert to use jiffies macro
  2025-08-27  7:54 [PATCH v3] ethernet: tlan: Convert to use jiffies macro zhang.enpei
@ 2025-08-27 22:22 ` Jacob Keller
  2025-08-28 17:27 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2025-08-27 22:22 UTC (permalink / raw)
  To: zhang.enpei, chessman
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1365 bytes --]



On 8/27/2025 12:54 AM, zhang.enpei@zte.com.cn wrote:
> From: Zhang Enpei <zhang.enpei@zte.com.cn>
> 
> Use time_is_before_eq_jiffies macro instead of using jiffies directly to
> handle wraparound.
> 
> Signed-off-by: Zhang Enpei <zhang.enpei@zte.com.cn>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/ti/tlan.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
> index a55b0f951181..7c5e51284942 100644
> --- a/drivers/net/ethernet/ti/tlan.c
> +++ b/drivers/net/ethernet/ti/tlan.c
> @@ -1817,7 +1817,6 @@ static void tlan_timer(struct timer_list *t)
>  {
>  	struct tlan_priv	*priv = timer_container_of(priv, t, timer);
>  	struct net_device	*dev = priv->dev;
> -	u32		elapsed;
>  	unsigned long	flags = 0;
> 
>  	priv->timer.function = NULL;
> @@ -1844,8 +1843,7 @@ static void tlan_timer(struct timer_list *t)
>  	case TLAN_TIMER_ACTIVITY:
>  		spin_lock_irqsave(&priv->lock, flags);
>  		if (priv->timer.function == NULL) {
> -			elapsed = jiffies - priv->timer_set_at;
> -			if (elapsed >= TLAN_TIMER_ACT_DELAY) {
> +			if (time_is_before_eq_jiffies(priv->timer_set_at + TLAN_TIMER_ACT_DELAY)) {
>  				tlan_dio_write8(dev->base_addr,
>  						TLAN_LED_REG, TLAN_LED_LINK);
>  			} else  {


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] ethernet: tlan: Convert to use jiffies macro
  2025-08-27  7:54 [PATCH v3] ethernet: tlan: Convert to use jiffies macro zhang.enpei
  2025-08-27 22:22 ` Jacob Keller
@ 2025-08-28 17:27 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-08-28 17:27 UTC (permalink / raw)
  To: zhang.enpei
  Cc: chessman, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Wed, Aug 27, 2025 at 03:54:55PM +0800, zhang.enpei@zte.com.cn wrote:
> From: Zhang Enpei <zhang.enpei@zte.com.cn>
> 
> Use time_is_before_eq_jiffies macro instead of using jiffies directly to
> handle wraparound.
> 
> Signed-off-by: Zhang Enpei <zhang.enpei@zte.com.cn>

Unfortunately W=1 builds fail with this patch.

GCC 15.1.o says:

In file included from ./include/linux/bitops.h:7,
                 from ./include/linux/kernel.h:23,
                 from ./include/linux/cpumask.h:11,
                 from ./include/linux/alloc_tag.h:13,
                 from ./include/linux/percpu.h:5,
                 from ./include/linux/context_tracking_state.h:5,
                 from ./include/linux/hardirq.h:5,
                 from drivers/net/ethernet/ti/tlan.c:32:
drivers/net/ethernet/ti/tlan.c: In function 'tlan_timer':
./include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
   12 |         (void)(&__dummy == &__dummy2); \
      |                         ^~
./include/linux/jiffies.h:149:10: note: in expansion of macro 'typecheck'
  149 |          typecheck(unsigned long, b) && \
      |          ^~~~~~~~~
./include/linux/jiffies.h:292:38: note: in expansion of macro 'time_after_eq'
  292 | #define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
      |                                      ^~~~~~~~~~~~~
drivers/net/ethernet/ti/tlan.c:1846:29: note: in expansion of macro 'time_is_before_eq_jiffies'
 1846 |                         if (time_is_before_eq_jiffies(priv->timer_set_at + TLAN_TIMER_ACT_DELAY)) {
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~

-- 
pw-bot: changes-requested

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-28 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27  7:54 [PATCH v3] ethernet: tlan: Convert to use jiffies macro zhang.enpei
2025-08-27 22:22 ` Jacob Keller
2025-08-28 17:27 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).