831-ledtrig_netdev.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --- a/drivers/leds/trigger/Kconfig
  2. +++ b/drivers/leds/trigger/Kconfig
  3. @@ -112,4 +112,11 @@ config LEDS_TRIGGER_MORSE
  4. tristate "LED Morse Trigger"
  5. depends on LEDS_TRIGGERS
  6. +config LEDS_TRIGGER_NETDEV
  7. + tristate "LED Netdev Trigger"
  8. + depends on NET && LEDS_TRIGGERS
  9. + help
  10. + This allows LEDs to be controlled by network device activity.
  11. + If unsure, say Y.
  12. +
  13. endif # LEDS_TRIGGERS
  14. --- a/drivers/leds/Makefile
  15. +++ b/drivers/leds/Makefile
  16. @@ -63,3 +63,4 @@ obj-$(CONFIG_LEDS_DAC124S085) += leds-d
  17. # LED Triggers
  18. obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
  19. obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
  20. +obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
  21. --- a/drivers/leds/ledtrig-netdev.c
  22. +++ b/drivers/leds/ledtrig-netdev.c
  23. @@ -22,7 +22,6 @@
  24. #include <linux/list.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/device.h>
  27. -#include <linux/sysdev.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/timer.h>
  30. #include <linux/ctype.h>
  31. @@ -254,7 +253,7 @@ static int netdev_trig_notify(struct not
  32. unsigned long evt,
  33. void *dv)
  34. {
  35. - struct net_device *dev = dv;
  36. + struct net_device *dev = netdev_notifier_info_to_dev((struct netdev_notifier_info *) dv);
  37. struct led_netdev_data *trigger_data = container_of(nb, struct led_netdev_data, notifier);
  38. if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER)
  39. @@ -294,8 +293,9 @@ done:
  40. static void netdev_trig_timer(unsigned long arg)
  41. {
  42. struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg;
  43. - const struct net_device_stats *dev_stats;
  44. + struct rtnl_link_stats64 *dev_stats;
  45. unsigned new_activity;
  46. + struct rtnl_link_stats64 temp;
  47. write_lock(&trigger_data->lock);
  48. @@ -305,7 +305,7 @@ static void netdev_trig_timer(unsigned l
  49. goto no_restart;
  50. }
  51. - dev_stats = dev_get_stats(trigger_data->net_dev);
  52. + dev_stats = dev_get_stats(trigger_data->net_dev, &temp);
  53. new_activity =
  54. ((trigger_data->mode & MODE_TX) ? dev_stats->tx_packets : 0) +
  55. ((trigger_data->mode & MODE_RX) ? dev_stats->rx_packets : 0);