@@ -107,18 +107,11 @@ void ksz_init_mib_timer(struct ksz_device *dev)
{
int i;
- /* Read MIB counters every 30 seconds to avoid overflow. */
- dev->mib_read_interval = msecs_to_jiffies(30000);
-
INIT_WORK(&dev->mib_read, ksz_mib_read_work);
timer_setup(&dev->mib_read_timer, mib_monitor, 0);
for (i = 0; i < dev->mib_port_cnt; i++)
dev->dev_ops->port_init_cnt(dev, i);
-
- /* Start the timer 2 seconds later. */
- dev->mib_read_timer.expires = jiffies + msecs_to_jiffies(2000);
- add_timer(&dev->mib_read_timer);
}
EXPORT_SYMBOL_GPL(ksz_init_mib_timer);
@@ -152,7 +145,9 @@ void ksz_adjust_link(struct dsa_switch *ds, int port,
/* Read all MIB counters when the link is going down. */
if (!phydev->link) {
p->read = true;
- schedule_work(&dev->mib_read);
+ /* timer started */
+ if (dev->mib_read_interval)
+ schedule_work(&dev->mib_read);
}
mutex_lock(&dev->dev_mutex);
if (!phydev->link)
@@ -464,6 +459,13 @@ int ksz_switch_register(struct ksz_device *dev,
return ret;
}
+ /* Read MIB counters every 30 seconds to avoid overflow. */
+ dev->mib_read_interval = msecs_to_jiffies(30000);
+
+ /* Start the MIB timer. */
+ dev->mib_read_timer.expires = jiffies;
+ add_timer(&dev->mib_read_timer);
+
return 0;
}
EXPORT_SYMBOL(ksz_switch_register);