Commit af1147b2 authored by wujunwen's avatar wujunwen Committed by Jakub Kicinski

net: ksz884x: optimize netdev_open flow and remove static variable

remove the static next_jiffies variable, and reinitialize next_jiffies
to simplify netdev_open
Signed-off-by: default avatarwujunwen <wudaemon@163.com>
Link: https://lore.kernel.org/r/20220315122857.78601-1-wudaemon@163.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a8df2166
...@@ -5225,7 +5225,6 @@ static irqreturn_t netdev_intr(int irq, void *dev_id) ...@@ -5225,7 +5225,6 @@ static irqreturn_t netdev_intr(int irq, void *dev_id)
* Linux network device functions * Linux network device functions
*/ */
static unsigned long next_jiffies;
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
static void netdev_netpoll(struct net_device *dev) static void netdev_netpoll(struct net_device *dev)
...@@ -5411,10 +5410,12 @@ static int netdev_open(struct net_device *dev) ...@@ -5411,10 +5410,12 @@ static int netdev_open(struct net_device *dev)
struct dev_info *hw_priv = priv->adapter; struct dev_info *hw_priv = priv->adapter;
struct ksz_hw *hw = &hw_priv->hw; struct ksz_hw *hw = &hw_priv->hw;
struct ksz_port *port = &priv->port; struct ksz_port *port = &priv->port;
unsigned long next_jiffies;
int i; int i;
int p; int p;
int rc = 0; int rc = 0;
next_jiffies = jiffies + HZ * 2;
priv->multicast = 0; priv->multicast = 0;
priv->promiscuous = 0; priv->promiscuous = 0;
...@@ -5428,10 +5429,7 @@ static int netdev_open(struct net_device *dev) ...@@ -5428,10 +5429,7 @@ static int netdev_open(struct net_device *dev)
if (rc) if (rc)
return rc; return rc;
for (i = 0; i < hw->mib_port_cnt; i++) { for (i = 0; i < hw->mib_port_cnt; i++) {
if (next_jiffies < jiffies) next_jiffies += HZ * 1;
next_jiffies = jiffies + HZ * 2;
else
next_jiffies += HZ * 1;
hw_priv->counter[i].time = next_jiffies; hw_priv->counter[i].time = next_jiffies;
hw->port_mib[i].state = media_disconnected; hw->port_mib[i].state = media_disconnected;
port_init_cnt(hw, i); port_init_cnt(hw, i);
...@@ -6563,6 +6561,7 @@ static void mib_read_work(struct work_struct *work) ...@@ -6563,6 +6561,7 @@ static void mib_read_work(struct work_struct *work)
struct dev_info *hw_priv = struct dev_info *hw_priv =
container_of(work, struct dev_info, mib_read); container_of(work, struct dev_info, mib_read);
struct ksz_hw *hw = &hw_priv->hw; struct ksz_hw *hw = &hw_priv->hw;
unsigned long next_jiffies;
struct ksz_port_mib *mib; struct ksz_port_mib *mib;
int i; int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment