diff mbox series

net: ksz884x: use time_before in netdev_open for compatibility

Message ID 20220220122101.5017-1-wudaemon@163.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ksz884x: use time_before in netdev_open for compatibility | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 39 this patch: 39
netdev/cc_maintainers warning 1 maintainers not CCed: m.grzeschik@pengutronix.de
netdev/build_clang success Errors and warnings before: 37 this patch: 37
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 39 this patch: 39
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Junwen Wu Feb. 20, 2022, 12:21 p.m. UTC
use time_before instead of direct compare for compatibility

Signed-off-by: wudaemon <wudaemon@163.com>
---
 drivers/net/ethernet/micrel/ksz884x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Feb. 22, 2022, 7:39 p.m. UTC | #1
On Sun, 20 Feb 2022 12:21:01 +0000 wudaemon wrote:
> use time_before instead of direct compare for compatibility
> 
> Signed-off-by: wudaemon <wudaemon@163.com>
> ---
>  drivers/net/ethernet/micrel/ksz884x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
> index d024983815da..fd3cb9ce438f 100644
> --- a/drivers/net/ethernet/micrel/ksz884x.c
> +++ b/drivers/net/ethernet/micrel/ksz884x.c
> @@ -5428,7 +5428,7 @@ static int netdev_open(struct net_device *dev)
>  		if (rc)
>  			return rc;
>  		for (i = 0; i < hw->mib_port_cnt; i++) {
> -			if (next_jiffies < jiffies)
> +			if (time_before(next_jiffies, jiffies))
>  				next_jiffies = jiffies + HZ * 2;
>  			else
>  				next_jiffies += HZ * 1;

I think this code is trying to space out the updates in time.
So neither way of doing the comparison seems great.
It'd be better to remove the static next_jiffies variable,
and just do something more akin to what mib_read_work() does
in open() as well.
Jakub Kicinski Feb. 24, 2022, 4:12 p.m. UTC | #2
On Thu, 24 Feb 2022 22:16:28 +0800 (CST) 吴俊文 wrote:
> Hi ,Jakub .I have changed my patch as your advise as follows:
> diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 7dc451f..443d7bc 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c @@ -5301,7 +5301,6 @@ static irqreturn_t netdev_intr(int irq, void *dev_id) * Linux network device functions */ -static unsigned long next_jiffies; #ifdef CONFIG_NET_POLL_CONTROLLER static void netdev_netpoll(struct net_device *dev) @@ -5492,7 +5491,7 @@ static int netdev_open(struct net_device *dev) int i; int p; int rc = 0; - + unsigned long next_jiffies=0 priv->multicast = 0; priv->promiscuous = 0; @@ -5506,7 +5505,7 @@ static int netdev_open(struct net_device *dev) if (rc) return rc; for (i = 0; i < hw->mib_port_cnt; i++) { - if (next_jiffies < jiffies) + if (time_before(next_jiffies, jiffies)) next_jiffies = jiffies + HZ * 2; else next_jiffies += HZ * 1; @@ -6642,7 +6641,7 @@ static void mib_read_work(struct work_struct *work) struct ksz_port_mib *mib; int i; - next_jiffies = jiffies; + unsigned long next_jiffies = jiffies; for (i = 0; i < hw->mib_port_cnt; i++) { mib = &hw->port_mib[i];
> 
> Do you have any other advise ?Thanks

Sorry your patch got scrambled into a single line and encoded with HTML.
Feel free to post it with git as [PATCH v2] and we'll take it from
there.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index d024983815da..fd3cb9ce438f 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5428,7 +5428,7 @@  static int netdev_open(struct net_device *dev)
 		if (rc)
 			return rc;
 		for (i = 0; i < hw->mib_port_cnt; i++) {
-			if (next_jiffies < jiffies)
+			if (time_before(next_jiffies, jiffies))
 				next_jiffies = jiffies + HZ * 2;
 			else
 				next_jiffies += HZ * 1;