lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220228124629.44ee8b84@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Date:   Mon, 28 Feb 2022 12:46:29 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     wudaemon <wudaemon@....com>
Cc:     davem@...emloft.net, m.grzeschik@...gutronix.de,
        chenhao288@...ilicon.com, arnd@...db.de, shenyang39@...wei.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] net: ksz884x: use time_before in netdev_open for
 compatibility and remove static variable

On Mon, 28 Feb 2022 16:29:55 +0000 wudaemon wrote:
> use time_before instead of direct compare for compatibility and remove the static next_jiffies variable
> 
> Signed-off-by: wudaemon <wudaemon@....com>

This does not build.

> diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
> index d024983815da..9d445f27abb8 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)
> @@ -5361,7 +5360,7 @@ static int prepare_hardware(struct net_device *dev)
>  	struct dev_info *hw_priv = priv->adapter;
>  	struct ksz_hw *hw = &hw_priv->hw;
>  	int rc = 0;
> -
> +	unsigned long next_jiffies = 0;

Please keep an empty line between variables and code.
The variable declaration lines should be ordered longest to shortest.
next_jiffies can be initialized to jiffies.

>  	/* Remember the network device that requests interrupts. */
>  	hw_priv->dev = dev;
>  	rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev);
> @@ -5428,7 +5427,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;
> @@ -6566,7 +6565,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];
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ