linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] net: ksz884x: use time_before in netdev_open for compatibility and remove static variable
@ 2022-03-01 15:18 wudaemon
  2022-03-05  5:49 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: wudaemon @ 2022-03-01 15:18 UTC (permalink / raw)
  To: davem, kuba, m.grzeschik, chenhao288, arnd
  Cc: wudaemon, shenyang39, netdev, linux-kernel

use time_before instead of direct compare for compatibility and remove the static next_jiffies variable

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

diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index d024983815da..ce4f5c99c1ac 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5225,7 +5225,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)
@@ -5411,10 +5410,12 @@ static int netdev_open(struct net_device *dev)
 	struct dev_info *hw_priv = priv->adapter;
 	struct ksz_hw *hw = &hw_priv->hw;
 	struct ksz_port *port = &priv->port;
+	unsigned long next_jiffies;
 	int i;
 	int p;
 	int rc = 0;
 
+	next_jiffies = jiffies;
 	priv->multicast = 0;
 	priv->promiscuous = 0;
 
@@ -5428,7 +5429,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;
@@ -6563,6 +6564,7 @@ static void mib_read_work(struct work_struct *work)
 	struct dev_info *hw_priv =
 		container_of(work, struct dev_info, mib_read);
 	struct ksz_hw *hw = &hw_priv->hw;
+	unsigned long next_jiffies;
 	struct ksz_port_mib *mib;
 	int i;
 
-- 
2.25.1


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

* Re: [PATCH v3] net: ksz884x: use time_before in netdev_open for compatibility and remove static variable
  2022-03-01 15:18 [PATCH v3] net: ksz884x: use time_before in netdev_open for compatibility and remove static variable wudaemon
@ 2022-03-05  5:49 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-03-05  5:49 UTC (permalink / raw)
  To: wudaemon
  Cc: davem, m.grzeschik, chenhao288, arnd, shenyang39, netdev, linux-kernel

On Tue,  1 Mar 2022 15:18:08 +0000 wudaemon wrote:
> use time_before instead of direct compare for compatibility and remove the static next_jiffies variable
> 
> Signed-off-by: wudaemon <wudaemon@163.com>

Oops, thought I replied to this one but apparently I haven't.
Sorry for the delay.

> diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
> index d024983815da..ce4f5c99c1ac 100644
> --- a/drivers/net/ethernet/micrel/ksz884x.c
> +++ b/drivers/net/ethernet/micrel/ksz884x.c
> @@ -5225,7 +5225,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)
> @@ -5411,10 +5410,12 @@ static int netdev_open(struct net_device *dev)
>  	struct dev_info *hw_priv = priv->adapter;
>  	struct ksz_hw *hw = &hw_priv->hw;
>  	struct ksz_port *port = &priv->port;
> +	unsigned long next_jiffies;
>  	int i;
>  	int p;
>  	int rc = 0;
>  
> +	next_jiffies = jiffies;

This should probably be:

	next_jiffies = jiffies + HZ * 2;

and then...

>  	priv->multicast = 0;
>  	priv->promiscuous = 0;
>  
> @@ -5428,7 +5429,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))

I don't think this check is needed at all any more. Since we initialize
next_jiffies to jiffies earlier in the function it's got to be in the
right ballpark.

>  				next_jiffies = jiffies + HZ * 2;
>  			else
>  				next_jiffies += HZ * 1;

Remove the if and just leave this line to move the time forward.

Thanks!


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

end of thread, other threads:[~2022-03-05  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 15:18 [PATCH v3] net: ksz884x: use time_before in netdev_open for compatibility and remove static variable wudaemon
2022-03-05  5:49 ` Jakub Kicinski

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).