struct led_netdev_data {
spinlock_t lock;
- struct timer_list timer;
+ struct delayed_work work;
struct notifier_block notifier;
struct led_classdev *led_cdev;
led_set_brightness(trigger_data->led_cdev, LED_OFF);
if ((trigger_data->mode & (MODE_TX | MODE_RX)) != 0 && trigger_data->link_up)
- mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
+ schedule_delayed_work(&trigger_data->work, trigger_data->interval);
}
static ssize_t led_device_name_show(struct device *dev,
if (size < 0 || size >= IFNAMSIZ)
return -EINVAL;
+ cancel_delayed_work_sync(&trigger_data->work);
+
spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
strcpy(trigger_data->device_name, buf);
if (size > 0 && trigger_data->device_name[size-1] == '\n')
if (new_mode == -1)
return -EINVAL;
- spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
+ cancel_delayed_work_sync(&trigger_data->work);
+ spin_lock_bh(&trigger_data->lock);
trigger_data->mode = new_mode;
-
set_baseline_state(trigger_data);
spin_unlock_bh(&trigger_data->lock);
/* impose some basic bounds on the timer interval */
if (count == size && value >= 5 && value <= 10000) {
- spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
+ cancel_delayed_work_sync(&trigger_data->work);
+ spin_lock_bh(&trigger_data->lock);
trigger_data->interval = msecs_to_jiffies(value);
-
set_baseline_state(trigger_data); /* resets timer */
spin_unlock_bh(&trigger_data->lock);
if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER && evt != NETDEV_CHANGENAME)
return NOTIFY_DONE;
+ cancel_delayed_work_sync(&trigger_data->work);
+
spin_lock_bh(&trigger_data->lock);
if (strcmp(dev->name, trigger_data->device_name))
goto done;
- del_timer_sync(&trigger_data->timer);
-
if (evt == NETDEV_REGISTER || evt == NETDEV_CHANGENAME) {
if (trigger_data->net_dev != NULL)
dev_put(trigger_data->net_dev);
}
/* here's the real work! */
-static void netdev_trig_timer(unsigned long arg)
+static void netdev_trig_work(struct work_struct *work)
{
- struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg;
+ struct led_netdev_data *trigger_data = container_of(work, struct led_netdev_data, work.work);
struct rtnl_link_stats64 *dev_stats;
unsigned new_activity;
struct rtnl_link_stats64 temp;
}
trigger_data->last_activity = new_activity;
- mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
+ schedule_delayed_work(&trigger_data->work, trigger_data->interval);
}
static void netdev_trig_activate(struct led_classdev *led_cdev)
trigger_data->notifier.notifier_call = netdev_trig_notify;
trigger_data->notifier.priority = 10;
- setup_timer(&trigger_data->timer, netdev_trig_timer, (unsigned long) trigger_data);
+ INIT_DELAYED_WORK(&trigger_data->work, netdev_trig_work);
trigger_data->led_cdev = led_cdev;
trigger_data->net_dev = NULL;
device_remove_file(led_cdev->dev, &dev_attr_mode);
device_remove_file(led_cdev->dev, &dev_attr_interval);
+ cancel_delayed_work_sync(&trigger_data->work);
+
spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
if (trigger_data->net_dev) {
dev_put(trigger_data->net_dev);