Lines Matching defs:trigger_data
86 static void set_baseline_state(struct led_netdev_data *trigger_data)
88 if ((trigger_data->mode & MODE_LINK) != 0 && trigger_data->link_up)
89 led_set_brightness(trigger_data->led_cdev, LED_FULL);
91 led_set_brightness(trigger_data->led_cdev, LED_OFF);
93 if ((trigger_data->mode & (MODE_TX | MODE_RX)) != 0 && trigger_data->link_up)
94 mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
101 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
103 spin_lock_bh(&trigger_data->lock);
104 sprintf(buf, "%s\n", trigger_data->device_name);
105 spin_unlock_bh(&trigger_data->lock);
114 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
119 spin_lock_bh(&trigger_data->lock);
120 del_timer_sync(&trigger_data->timer);
122 strcpy(trigger_data->device_name, buf);
123 if (size > 0 && trigger_data->device_name[size-1] == '\n')
124 trigger_data->device_name[size-1] = 0;
125 trigger_data->link_up = 0;
126 trigger_data->last_activity = 0;
128 if (trigger_data->device_name[0] != 0) {
130 trigger_data->net_dev = dev_get_by_name(&init_net, trigger_data->device_name);
131 if (trigger_data->net_dev != NULL)
132 trigger_data->link_up = (dev_get_flags(trigger_data->net_dev) & IFF_LOWER_UP) != 0;
135 set_baseline_state(trigger_data);
136 spin_unlock_bh(&trigger_data->lock);
147 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
149 spin_lock_bh(&trigger_data->lock);
151 if (trigger_data->mode == 0) {
154 if (trigger_data->mode & MODE_LINK)
156 if (trigger_data->mode & MODE_TX)
158 if (trigger_data->mode & MODE_RX)
163 spin_unlock_bh(&trigger_data->lock);
172 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
204 spin_lock_bh(&trigger_data->lock);
205 del_timer_sync(&trigger_data->timer);
207 trigger_data->mode = new_mode;
209 set_baseline_state(trigger_data);
210 spin_unlock_bh(&trigger_data->lock);
221 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
223 spin_lock_bh(&trigger_data->lock);
224 sprintf(buf, "%u\n", jiffies_to_msecs(trigger_data->interval));
225 spin_unlock_bh(&trigger_data->lock);
234 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
245 spin_lock_bh(&trigger_data->lock);
246 del_timer_sync(&trigger_data->timer);
248 trigger_data->interval = msecs_to_jiffies(value);
250 set_baseline_state(trigger_data); /* resets timer */
251 spin_unlock_bh(&trigger_data->lock);
266 struct led_netdev_data *trigger_data = container_of(nb, struct led_netdev_data, notifier);
271 spin_lock_bh(&trigger_data->lock);
273 if (strcmp(dev->name, trigger_data->device_name))
276 del_timer_sync(&trigger_data->timer);
279 if (trigger_data->net_dev != NULL)
280 dev_put(trigger_data->net_dev);
283 trigger_data->net_dev = dev;
284 trigger_data->link_up = 0;
288 if (evt == NETDEV_UNREGISTER && trigger_data->net_dev != NULL) {
289 dev_put(trigger_data->net_dev);
290 trigger_data->net_dev = NULL;
296 trigger_data->link_up = (evt != NETDEV_DOWN && netif_carrier_ok(dev));
297 set_baseline_state(trigger_data);
300 spin_unlock_bh(&trigger_data->lock);
307 struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg;
312 if (!trigger_data->link_up || !trigger_data->net_dev || (trigger_data->mode & (MODE_TX | MODE_RX)) == 0) {
314 led_set_brightness(trigger_data->led_cdev, ((trigger_data->mode & MODE_LINK) != 0 && trigger_data->link_up) ? LED_FULL : LED_OFF);
318 dev_stats = dev_get_stats(trigger_data->net_dev, &temp);
320 ((trigger_data->mode & MODE_TX) ? dev_stats->tx_packets : 0) +
321 ((trigger_data->mode & MODE_RX) ? dev_stats->rx_packets : 0);
323 if (trigger_data->mode & MODE_LINK) {
329 if (trigger_data->led_cdev->brightness == LED_OFF) {
330 led_set_brightness(trigger_data->led_cdev, LED_FULL);
331 } else if (trigger_data->last_activity != new_activity) {
332 led_set_brightness(trigger_data->led_cdev, LED_OFF);
338 if (trigger_data->led_cdev->brightness == LED_FULL) {
339 led_set_brightness(trigger_data->led_cdev, LED_OFF);
340 } else if (trigger_data->last_activity != new_activity) {
341 led_set_brightness(trigger_data->led_cdev, LED_FULL);
345 trigger_data->last_activity = new_activity;
346 mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
351 struct led_netdev_data *trigger_data;
354 trigger_data = kzalloc(sizeof(struct led_netdev_data), GFP_KERNEL);
355 if (!trigger_data)
358 spin_lock_init(&trigger_data->lock);
360 trigger_data->notifier.notifier_call = netdev_trig_notify;
361 trigger_data->notifier.priority = 10;
363 setup_timer(&trigger_data->timer, netdev_trig_timer, (unsigned long) trigger_data);
365 trigger_data->led_cdev = led_cdev;
366 trigger_data->net_dev = NULL;
367 trigger_data->device_name[0] = 0;
369 trigger_data->mode = 0;
370 trigger_data->interval = msecs_to_jiffies(50);
371 trigger_data->link_up = 0;
372 trigger_data->last_activity = 0;
374 led_cdev->trigger_data = trigger_data;
386 register_netdevice_notifier(&trigger_data->notifier);
394 led_cdev->trigger_data = NULL;
395 kfree(trigger_data);
400 struct led_netdev_data *trigger_data = led_cdev->trigger_data;
402 if (trigger_data) {
403 unregister_netdevice_notifier(&trigger_data->notifier);
409 spin_lock_bh(&trigger_data->lock);
410 del_timer_sync(&trigger_data->timer);
412 if (trigger_data->net_dev) {
413 dev_put(trigger_data->net_dev);
414 trigger_data->net_dev = NULL;
417 spin_unlock_bh(&trigger_data->lock);
419 kfree(trigger_data);