This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree".
The branch, thirteen has been updated via a415ec92ea3745ac5efe32fdbfc5ef11f86408f9 (commit) via 40c7cdd3a521fa3281137ec0a182a4ae5b387856 (commit) from 1238e6d8a4b9f4c1eb94e7519315ed804f5c190e (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit a415ec92ea3745ac5efe32fdbfc5ef11f86408f9 Merge: 40c7cdd 1238e6d Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Nov 5 11:24:50 2012 +0100
Merge branch 'thirteen' of git.ipfire.org:/pub/git/ipfire-2.x into thirteen
commit 40c7cdd3a521fa3281137ec0a182a4ae5b387856 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Nov 5 11:21:53 2012 +0100
kernel: readd ledtrig-netdev.
-----------------------------------------------------------------------
Summary of changes: .../kernel/kernel.config.armv5tel-ipfire-kirkwood | 4 ++- config/kernel/kernel.config.armv5tel-ipfire-omap | 3 +- config/kernel/kernel.config.armv5tel-ipfire-rpi | 3 +- config/kernel/kernel.config.i586-ipfire | 3 +- config/kernel/kernel.config.i586-ipfire-pae | 3 +- config/rootfiles/common/armv5tel/linux-kirkwood | 3 +- config/rootfiles/common/armv5tel/linux-omap | 3 +- config/rootfiles/common/armv5tel/linux-rpi | 1 + config/rootfiles/common/i586/linux | 1 + config/rootfiles/packages/linux-pae | 1 + lfs/linux | 3 ++ ...1.patch => linux-3.2.33-ledtrig-netdev-1.patch} | 31 ++++++++++--------- 12 files changed, 37 insertions(+), 22 deletions(-) copy src/patches/{linux-2.6.32.11-netdev-1.patch => linux-3.2.33-ledtrig-netdev-1.patch} (93%)
Difference in files: diff --git a/config/kernel/kernel.config.armv5tel-ipfire-kirkwood b/config/kernel/kernel.config.armv5tel-ipfire-kirkwood index eb40528..ead83d5 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-kirkwood +++ b/config/kernel/kernel.config.armv5tel-ipfire-kirkwood @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.2.25 Kernel Configuration +# Linux/arm 3.2.33 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -2202,6 +2202,7 @@ CONFIG_I2C_VIAPRO=m # # I2C system bus drivers (mostly embedded / system-on-chip) # +CONFIG_I2C_DESIGNWARE_CORE=m CONFIG_I2C_DESIGNWARE_PCI=m CONFIG_I2C_GPIO=m CONFIG_I2C_INTEL_MID=m @@ -3572,6 +3573,7 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y # # iptables trigger is under Netfilter config (LED target) # +CONFIG_LEDS_TRIGGER_NETDEV=m # CONFIG_ACCESSIBILITY is not set # CONFIG_INFINIBAND is not set CONFIG_RTC_LIB=y diff --git a/config/kernel/kernel.config.armv5tel-ipfire-omap b/config/kernel/kernel.config.armv5tel-ipfire-omap index fe943a3..8765ae5 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-omap +++ b/config/kernel/kernel.config.armv5tel-ipfire-omap @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.2.32 Kernel Configuration +# Linux/arm 3.2.33 Kernel Configuration # CONFIG_ARM=y CONFIG_HAVE_PWM=y @@ -2928,6 +2928,7 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=m # # iptables trigger is under Netfilter config (LED target) # +CONFIG_LEDS_TRIGGER_NETDEV=m # CONFIG_ACCESSIBILITY is not set CONFIG_RTC_LIB=y CONFIG_RTC_CLASS=y diff --git a/config/kernel/kernel.config.armv5tel-ipfire-rpi b/config/kernel/kernel.config.armv5tel-ipfire-rpi index e19ea4d..2cef33d 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-rpi +++ b/config/kernel/kernel.config.armv5tel-ipfire-rpi @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.2.32 Kernel Configuration +# Linux/arm 3.2.33 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -2566,6 +2566,7 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=m # # iptables trigger is under Netfilter config (LED target) # +CONFIG_LEDS_TRIGGER_NETDEV=m # CONFIG_ACCESSIBILITY is not set CONFIG_RTC_LIB=y CONFIG_RTC_CLASS=y diff --git a/config/kernel/kernel.config.i586-ipfire b/config/kernel/kernel.config.i586-ipfire index 3b85773..97cc119 100644 --- a/config/kernel/kernel.config.i586-ipfire +++ b/config/kernel/kernel.config.i586-ipfire @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/i386 3.2.32 Kernel Configuration +# Linux/i386 3.2.33 Kernel Configuration # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -3879,6 +3879,7 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=m # # iptables trigger is under Netfilter config (LED target) # +CONFIG_LEDS_TRIGGER_NETDEV=m # CONFIG_ACCESSIBILITY is not set # CONFIG_INFINIBAND is not set # CONFIG_EDAC is not set diff --git a/config/kernel/kernel.config.i586-ipfire-pae b/config/kernel/kernel.config.i586-ipfire-pae index d56e066..e50ea0b 100644 --- a/config/kernel/kernel.config.i586-ipfire-pae +++ b/config/kernel/kernel.config.i586-ipfire-pae @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/i386 3.2.32 Kernel Configuration +# Linux/i386 3.2.33 Kernel Configuration # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -3951,6 +3951,7 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=m # # iptables trigger is under Netfilter config (LED target) # +CONFIG_LEDS_TRIGGER_NETDEV=m # CONFIG_ACCESSIBILITY is not set # CONFIG_INFINIBAND is not set # CONFIG_EDAC is not set diff --git a/config/rootfiles/common/armv5tel/linux-kirkwood b/config/rootfiles/common/armv5tel/linux-kirkwood index 6f7a8dc..404d7af 100644 --- a/config/rootfiles/common/armv5tel/linux-kirkwood +++ b/config/rootfiles/common/armv5tel/linux-kirkwood @@ -3,7 +3,7 @@ boot/System.map-KVER-ipfire-kirkwood boot/config-KVER-ipfire-kirkwood boot/uImage-ipfire-kirkwood boot/vmlinuz-KVER-ipfire-kirkwood -boot/vmlinuz-ipfire-kirkwood +#boot/vmlinuz-ipfire-kirkwood etc/modprobe.d/framebuffer etc/modprobe.d/ipv6 etc/modprobe.d/isdn @@ -563,6 +563,7 @@ lib/modules/KVER-ipfire-kirkwood #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/leds/ledtrig-backlight.ko #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/leds/ledtrig-gpio.ko #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/leds/ledtrig-heartbeat.ko +#lib/modules/KVER-ipfire-kirkwood/kernel/drivers/leds/ledtrig-netdev.ko #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/leds/ledtrig-timer.ko #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/md #lib/modules/KVER-ipfire-kirkwood/kernel/drivers/md/dm-bufio.ko diff --git a/config/rootfiles/common/armv5tel/linux-omap b/config/rootfiles/common/armv5tel/linux-omap index a0201e9..0311524 100644 --- a/config/rootfiles/common/armv5tel/linux-omap +++ b/config/rootfiles/common/armv5tel/linux-omap @@ -3,7 +3,7 @@ boot/System.map-KVER-ipfire-omap boot/config-KVER-ipfire-omap boot/uImage-ipfire-omap boot/vmlinuz-KVER-ipfire-omap -boot/vmlinuz-ipfire-omap +#boot/vmlinuz-ipfire-omap lib/modules/KVER-ipfire-omap #lib/modules/KVER-ipfire-omap/build #lib/modules/KVER-ipfire-omap/kernel @@ -380,6 +380,7 @@ lib/modules/KVER-ipfire-omap #lib/modules/KVER-ipfire-omap/kernel/drivers/leds/ledtrig-backlight.ko #lib/modules/KVER-ipfire-omap/kernel/drivers/leds/ledtrig-default-on.ko #lib/modules/KVER-ipfire-omap/kernel/drivers/leds/ledtrig-gpio.ko +#lib/modules/KVER-ipfire-omap/kernel/drivers/leds/ledtrig-netdev.ko #lib/modules/KVER-ipfire-omap/kernel/drivers/leds/ledtrig-timer.ko #lib/modules/KVER-ipfire-omap/kernel/drivers/md #lib/modules/KVER-ipfire-omap/kernel/drivers/md/dm-bufio.ko diff --git a/config/rootfiles/common/armv5tel/linux-rpi b/config/rootfiles/common/armv5tel/linux-rpi index 37e49dd..ee4668d 100644 --- a/config/rootfiles/common/armv5tel/linux-rpi +++ b/config/rootfiles/common/armv5tel/linux-rpi @@ -327,6 +327,7 @@ lib/modules/KVER-ipfire-rpi #lib/modules/KVER-ipfire-rpi/kernel/drivers/leds/ledtrig-default-on.ko #lib/modules/KVER-ipfire-rpi/kernel/drivers/leds/ledtrig-gpio.ko #lib/modules/KVER-ipfire-rpi/kernel/drivers/leds/ledtrig-heartbeat.ko +#lib/modules/KVER-ipfire-rpi/kernel/drivers/leds/ledtrig-netdev.ko #lib/modules/KVER-ipfire-rpi/kernel/drivers/leds/ledtrig-timer.ko #lib/modules/KVER-ipfire-rpi/kernel/drivers/md #lib/modules/KVER-ipfire-rpi/kernel/drivers/md/dm-bufio.ko diff --git a/config/rootfiles/common/i586/linux b/config/rootfiles/common/i586/linux index 0d91e1f..0f5498a 100644 --- a/config/rootfiles/common/i586/linux +++ b/config/rootfiles/common/i586/linux @@ -715,6 +715,7 @@ lib/modules/KVER-ipfire #lib/modules/KVER-ipfire/kernel/drivers/leds/ledtrig-default-on.ko #lib/modules/KVER-ipfire/kernel/drivers/leds/ledtrig-gpio.ko #lib/modules/KVER-ipfire/kernel/drivers/leds/ledtrig-heartbeat.ko +#lib/modules/KVER-ipfire/kernel/drivers/leds/ledtrig-netdev.ko #lib/modules/KVER-ipfire/kernel/drivers/leds/ledtrig-timer.ko #lib/modules/KVER-ipfire/kernel/drivers/lguest #lib/modules/KVER-ipfire/kernel/drivers/lguest/lg.ko diff --git a/config/rootfiles/packages/linux-pae b/config/rootfiles/packages/linux-pae index 08f1afc..7bb598d 100644 --- a/config/rootfiles/packages/linux-pae +++ b/config/rootfiles/packages/linux-pae @@ -718,6 +718,7 @@ lib/modules/KVER-ipfire-pae #lib/modules/KVER-ipfire-pae/kernel/drivers/leds/ledtrig-default-on.ko #lib/modules/KVER-ipfire-pae/kernel/drivers/leds/ledtrig-gpio.ko #lib/modules/KVER-ipfire-pae/kernel/drivers/leds/ledtrig-heartbeat.ko +#lib/modules/KVER-ipfire-pae/kernel/drivers/leds/ledtrig-netdev.ko #lib/modules/KVER-ipfire-pae/kernel/drivers/leds/ledtrig-timer.ko #lib/modules/KVER-ipfire-pae/kernel/drivers/lguest #lib/modules/KVER-ipfire-pae/kernel/drivers/lguest/lg.ko diff --git a/lfs/linux b/lfs/linux index fce7ec1..d9e617a 100644 --- a/lfs/linux +++ b/lfs/linux @@ -120,6 +120,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) # Layer7-patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/netfilter_layer7_2.22_kernel3.0.patch
+ # Add LED trigger + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.2.33-ledtrig-netdev-1.patch + # Fix uevent PHYSDEVDRIVER # cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_ipg-fix-driver-name.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.32.27_mcs7830-fix-driver-name.patch diff --git a/src/patches/linux-3.2.33-ledtrig-netdev-1.patch b/src/patches/linux-3.2.33-ledtrig-netdev-1.patch new file mode 100644 index 0000000..f42ca73 --- /dev/null +++ b/src/patches/linux-3.2.33-ledtrig-netdev-1.patch @@ -0,0 +1,479 @@ +diff -Naur linux-3.2.33.org/drivers/leds/Kconfig linux-3.2.33/drivers/leds/Kconfig +--- linux-3.2.33.org/drivers/leds/Kconfig 2012-10-31 00:27:11.000000000 +0100 ++++ linux-3.2.33/drivers/leds/Kconfig 2012-11-04 12:47:10.661589825 +0100 +@@ -457,4 +457,11 @@ + comment "iptables trigger is under Netfilter config (LED target)" + depends on LEDS_TRIGGERS + ++config LEDS_TRIGGER_NETDEV ++ tristate "LED Netdev Trigger" ++ depends on LEDS_TRIGGERS ++ help ++ This allows LEDs to be controlled by network device activity. ++ If unsure, say Y. ++ + endif # NEW_LEDS +diff -Naur linux-3.2.33.org/drivers/leds/ledtrig-netdev.c linux-3.2.33/drivers/leds/ledtrig-netdev.c +--- linux-3.2.33.org/drivers/leds/ledtrig-netdev.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-3.2.33/drivers/leds/ledtrig-netdev.c 2012-11-04 13:43:51.414865799 +0100 +@@ -0,0 +1,452 @@ ++/* ++ * LED Kernel Netdev Trigger ++ * ++ * Toggles the LED to reflect the link and traffic state of a named net device ++ * ++ * Copyright 2007 Oliver Jowett oliver@opencloud.com ++ * ++ * Derived from ledtrig-timer.c which is: ++ * Copyright 2005-2006 Openedhand Ltd. ++ * Author: Richard Purdie rpurdie@openedhand.com ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ * ++ */ ++ ++#include <linux/module.h> ++#include <linux/jiffies.h> ++#include <linux/kernel.h> ++#include <linux/init.h> ++#include <linux/list.h> ++#include <linux/spinlock.h> ++#include <linux/device.h> ++#include <linux/sysdev.h> ++#include <linux/netdevice.h> ++#include <linux/timer.h> ++#include <linux/ctype.h> ++#include <linux/leds.h> ++#include <linux/version.h> ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) ++#include <net/net_namespace.h> ++#endif ++ ++#include "leds.h" ++ ++/* ++ * Configurable sysfs attributes: ++ * ++ * device_name - network device name to monitor ++ * ++ * interval - duration of LED blink, in milliseconds ++ * ++ * mode - either "none" (LED is off) or a space separated list of one or more of: ++ * link: LED's normal state reflects whether the link is up (has carrier) or not ++ * tx: LED blinks on transmitted data ++ * rx: LED blinks on receive data ++ * ++ * Some suggestions: ++ * ++ * Simple link status LED: ++ * $ echo netdev >someled/trigger ++ * $ echo eth0 >someled/device_name ++ * $ echo link >someled/mode ++ * ++ * Ethernet-style link/activity LED: ++ * $ echo netdev >someled/trigger ++ * $ echo eth0 >someled/device_name ++ * $ echo "link tx rx" >someled/mode ++ * ++ * Modem-style tx/rx LEDs: ++ * $ echo netdev >led1/trigger ++ * $ echo ppp0 >led1/device_name ++ * $ echo tx >led1/mode ++ * $ echo netdev >led2/trigger ++ * $ echo ppp0 >led2/device_name ++ * $ echo rx >led2/mode ++ * ++ */ ++ ++#define MODE_LINK 1 ++#define MODE_TX 2 ++#define MODE_RX 4 ++ ++struct led_netdev_data { ++ rwlock_t lock; ++ ++ struct timer_list timer; ++ struct notifier_block notifier; ++ ++ struct led_classdev *led_cdev; ++ struct net_device *net_dev; ++ ++ char device_name[IFNAMSIZ]; ++ unsigned interval; ++ unsigned mode; ++ unsigned link_up; ++ unsigned last_activity; ++}; ++ ++static void set_baseline_state(struct led_netdev_data *trigger_data) ++{ ++ if ((trigger_data->mode & MODE_LINK) != 0 && trigger_data->link_up) ++ led_set_brightness(trigger_data->led_cdev, LED_FULL); ++ else ++ 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); ++ else ++ del_timer(&trigger_data->timer); ++} ++ ++static ssize_t led_device_name_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ ++ read_lock(&trigger_data->lock); ++ sprintf(buf, "%s\n", trigger_data->device_name); ++ read_unlock(&trigger_data->lock); ++ ++ return strlen(buf) + 1; ++} ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) ++extern struct net init_net; ++#endif ++ ++static ssize_t led_device_name_store(struct device *dev, ++ struct device_attribute *attr, const char *buf, size_t size) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ ++ if (size < 0 || size >= IFNAMSIZ) ++ return -EINVAL; ++ ++ write_lock(&trigger_data->lock); ++ ++ strcpy(trigger_data->device_name, buf); ++ if (size > 0 && trigger_data->device_name[size-1] == '\n') ++ trigger_data->device_name[size-1] = 0; ++ ++ if (trigger_data->device_name[0] != 0) { ++ /* check for existing device to update from */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) ++ trigger_data->net_dev = dev_get_by_name(&init_net, trigger_data->device_name); ++#else ++ trigger_data->net_dev = dev_get_by_name(trigger_data->device_name); ++#endif ++ if (trigger_data->net_dev != NULL) ++ trigger_data->link_up = (dev_get_flags(trigger_data->net_dev) & IFF_LOWER_UP) != 0; ++ set_baseline_state(trigger_data); /* updates LEDs, may start timers */ ++ } ++ ++ write_unlock(&trigger_data->lock); ++ return size; ++} ++ ++static DEVICE_ATTR(device_name, 0644, led_device_name_show, led_device_name_store); ++ ++static ssize_t led_mode_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ ++ read_lock(&trigger_data->lock); ++ ++ if (trigger_data->mode == 0) { ++ strcpy(buf, "none\n"); ++ } else { ++ if (trigger_data->mode & MODE_LINK) ++ strcat(buf, "link "); ++ if (trigger_data->mode & MODE_TX) ++ strcat(buf, "tx "); ++ if (trigger_data->mode & MODE_RX) ++ strcat(buf, "rx "); ++ strcat(buf, "\n"); ++ } ++ ++ read_unlock(&trigger_data->lock); ++ ++ return strlen(buf)+1; ++} ++ ++static ssize_t led_mode_store(struct device *dev, ++ struct device_attribute *attr, const char *buf, size_t size) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ char copybuf[1024]; ++ int new_mode = -1; ++ char *p, *token; ++ ++ /* take a copy since we don't want to trash the inbound buffer when using strsep */ ++ strncpy(copybuf, buf, sizeof(copybuf)); ++ copybuf[1023] = 0; ++ p = copybuf; ++ ++ while ((token = strsep(&p, " \t\n")) != NULL) { ++ if (!*token) ++ continue; ++ ++ if (new_mode == -1) ++ new_mode = 0; ++ ++ if (!strcmp(token, "none")) ++ new_mode = 0; ++ else if (!strcmp(token, "tx")) ++ new_mode |= MODE_TX; ++ else if (!strcmp(token, "rx")) ++ new_mode |= MODE_RX; ++ else if (!strcmp(token, "link")) ++ new_mode |= MODE_LINK; ++ else ++ return -EINVAL; ++ } ++ ++ if (new_mode == -1) ++ return -EINVAL; ++ ++ write_lock(&trigger_data->lock); ++ trigger_data->mode = new_mode; ++ set_baseline_state(trigger_data); ++ write_unlock(&trigger_data->lock); ++ ++ return size; ++} ++ ++static DEVICE_ATTR(mode, 0644, led_mode_show, led_mode_store); ++ ++static ssize_t led_interval_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ ++ read_lock(&trigger_data->lock); ++ sprintf(buf, "%u\n", jiffies_to_msecs(trigger_data->interval)); ++ read_unlock(&trigger_data->lock); ++ ++ return strlen(buf) + 1; ++} ++ ++static ssize_t led_interval_store(struct device *dev, ++ struct device_attribute *attr, const char *buf, size_t size) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(dev); ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ int ret = -EINVAL; ++ char *after; ++ unsigned long value = simple_strtoul(buf, &after, 10); ++ size_t count = after - buf; ++ ++ if (*after && isspace(*after)) ++ count++; ++ ++ /* impose some basic bounds on the timer interval */ ++ if (count == size && value >= 5 && value <= 10000) { ++ write_lock(&trigger_data->lock); ++ trigger_data->interval = msecs_to_jiffies(value); ++ set_baseline_state(trigger_data); // resets timer ++ write_unlock(&trigger_data->lock); ++ ret = count; ++ } ++ ++ return ret; ++} ++ ++static DEVICE_ATTR(interval, 0644, led_interval_show, led_interval_store); ++ ++static int netdev_trig_notify(struct notifier_block *nb, ++ unsigned long evt, ++ void *dv) ++{ ++ struct net_device *dev = dv; ++ struct led_netdev_data *trigger_data = container_of(nb, struct led_netdev_data, notifier); ++ ++ if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER) ++ return NOTIFY_DONE; ++ ++ write_lock(&trigger_data->lock); ++ ++ if (strcmp(dev->name, trigger_data->device_name)) ++ goto done; ++ ++ if (evt == NETDEV_REGISTER) { ++ if (trigger_data->net_dev != NULL) ++ dev_put(trigger_data->net_dev); ++ dev_hold(dev); ++ trigger_data->net_dev = dev; ++ trigger_data->link_up = 0; ++ goto done; ++ } ++ ++ if (evt == NETDEV_UNREGISTER && trigger_data->net_dev != NULL) { ++ dev_put(trigger_data->net_dev); ++ trigger_data->net_dev = NULL; ++ goto done; ++ } ++ ++ /* UP / DOWN / CHANGE */ ++ ++ trigger_data->link_up = (evt != NETDEV_DOWN && netif_carrier_ok(dev)); ++ set_baseline_state(trigger_data); ++ ++done: ++ write_unlock(&trigger_data->lock); ++ return NOTIFY_DONE; ++} ++ ++/* here's the real work! */ ++static void netdev_trig_timer(unsigned long arg) ++{ ++ struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg; ++ struct rtnl_link_stats64 *dev_stats; ++ unsigned new_activity; ++ struct rtnl_link_stats64 temp; ++ ++ write_lock(&trigger_data->lock); ++ ++ if (!trigger_data->link_up || !trigger_data->net_dev || (trigger_data->mode & (MODE_TX | MODE_RX)) == 0) { ++ /* we don't need to do timer work, just reflect link state. */ ++ led_set_brightness(trigger_data->led_cdev, ((trigger_data->mode & MODE_LINK) != 0 && trigger_data->link_up) ? LED_FULL : LED_OFF); ++ goto no_restart; ++ } ++ ++ dev_stats = dev_get_stats(trigger_data->net_dev, &temp); ++ new_activity = ++ ((trigger_data->mode & MODE_TX) ? dev_stats->tx_packets : 0) + ++ ((trigger_data->mode & MODE_RX) ? dev_stats->rx_packets : 0); ++ ++ if (trigger_data->mode & MODE_LINK) { ++ /* base state is ON (link present) */ ++ /* if there's no link, we don't get this far and the LED is off */ ++ ++ /* OFF -> ON always */ ++ /* ON -> OFF on activity */ ++ if (trigger_data->led_cdev->brightness == LED_OFF) { ++ led_set_brightness(trigger_data->led_cdev, LED_FULL); ++ } else if (trigger_data->last_activity != new_activity) { ++ led_set_brightness(trigger_data->led_cdev, LED_OFF); ++ } ++ } else { ++ /* base state is OFF */ ++ /* ON -> OFF always */ ++ /* OFF -> ON on activity */ ++ if (trigger_data->led_cdev->brightness == LED_FULL) { ++ led_set_brightness(trigger_data->led_cdev, LED_OFF); ++ } else if (trigger_data->last_activity != new_activity) { ++ led_set_brightness(trigger_data->led_cdev, LED_FULL); ++ } ++ } ++ ++ trigger_data->last_activity = new_activity; ++ mod_timer(&trigger_data->timer, jiffies + trigger_data->interval); ++ ++no_restart: ++ write_unlock(&trigger_data->lock); ++} ++ ++static void netdev_trig_activate(struct led_classdev *led_cdev) ++{ ++ struct led_netdev_data *trigger_data; ++ int rc; ++ ++ trigger_data = kzalloc(sizeof(struct led_netdev_data), GFP_KERNEL); ++ if (!trigger_data) ++ return; ++ ++ rwlock_init(&trigger_data->lock); ++ ++ 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); ++ ++ trigger_data->led_cdev = led_cdev; ++ trigger_data->net_dev = NULL; ++ trigger_data->device_name[0] = 0; ++ ++ trigger_data->mode = 0; ++ trigger_data->interval = msecs_to_jiffies(50); ++ trigger_data->link_up = 0; ++ trigger_data->last_activity = 0; ++ ++ led_cdev->trigger_data = trigger_data; ++ ++ rc = device_create_file(led_cdev->dev, &dev_attr_device_name); ++ if (rc) ++ goto err_out; ++ rc = device_create_file(led_cdev->dev, &dev_attr_mode); ++ if (rc) ++ goto err_out_device_name; ++ rc = device_create_file(led_cdev->dev, &dev_attr_interval); ++ if (rc) ++ goto err_out_mode; ++ ++ register_netdevice_notifier(&trigger_data->notifier); ++ return; ++ ++err_out_mode: ++ device_remove_file(led_cdev->dev, &dev_attr_mode); ++err_out_device_name: ++ device_remove_file(led_cdev->dev, &dev_attr_device_name); ++err_out: ++ led_cdev->trigger_data = NULL; ++ kfree(trigger_data); ++} ++ ++static void netdev_trig_deactivate(struct led_classdev *led_cdev) ++{ ++ struct led_netdev_data *trigger_data = led_cdev->trigger_data; ++ ++ if (trigger_data) { ++ unregister_netdevice_notifier(&trigger_data->notifier); ++ ++ device_remove_file(led_cdev->dev, &dev_attr_device_name); ++ device_remove_file(led_cdev->dev, &dev_attr_mode); ++ device_remove_file(led_cdev->dev, &dev_attr_interval); ++ ++ write_lock(&trigger_data->lock); ++ ++ if (trigger_data->net_dev) { ++ dev_put(trigger_data->net_dev); ++ trigger_data->net_dev = NULL; ++ } ++ ++ write_unlock(&trigger_data->lock); ++ ++ del_timer_sync(&trigger_data->timer); ++ ++ kfree(trigger_data); ++ } ++} ++ ++static struct led_trigger netdev_led_trigger = { ++ .name = "netdev", ++ .activate = netdev_trig_activate, ++ .deactivate = netdev_trig_deactivate, ++}; ++ ++static int __init netdev_trig_init(void) ++{ ++ return led_trigger_register(&netdev_led_trigger); ++} ++ ++static void __exit netdev_trig_exit(void) ++{ ++ led_trigger_unregister(&netdev_led_trigger); ++} ++ ++module_init(netdev_trig_init); ++module_exit(netdev_trig_exit); ++ ++MODULE_AUTHOR("Oliver Jowett oliver@opencloud.com"); ++MODULE_DESCRIPTION("Netdev LED trigger"); ++MODULE_LICENSE("GPL"); +diff -Naur linux-3.2.33.org/drivers/leds/Makefile linux-3.2.33/drivers/leds/Makefile +--- linux-3.2.33.org/drivers/leds/Makefile 2012-10-31 00:27:11.000000000 +0100 ++++ linux-3.2.33/drivers/leds/Makefile 2012-11-04 12:47:10.661589825 +0100 +@@ -54,3 +54,4 @@ + obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o + obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o + obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o ++obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
hooks/post-receive -- IPFire 2.x development tree