[OpenWrt-Devel] [PATCH 1/4] base-files: add option to specify netdev led mode in configuration generation

Tal Keren kooolk at gmail.com
Wed Jan 6 19:40:45 EST 2016


This is necessary for controlling leds of RJ45 port, when one indicate the link
status and the other indicate data transfer.

Signed-off-by: Tal Keren <kooolk at gmail.com>
---
 package/base-files/files/bin/config_generate           | 7 ++++---
 package/base-files/files/lib/functions/uci-defaults.sh | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 9218788..4f257e4 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -257,11 +257,12 @@ generate_led() {
 		;;
 
 		netdev)
-			local device
-			json_get_vars device
+			local device mode
+			json_get_vars device mode
+			[ -n "$mode" ] || mode='link tx rx'
 			uci -q batch <<-EOF
 				set system.$cfg.trigger='netdev'
-				set system.$cfg.mode='link tx rx'
+				set system.$cfg.mode='$mode'
 				set system.$cfg.dev='$device'
 			EOF
 		;;
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index de3f180..c0ff98a 100755
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -355,6 +355,7 @@ ucidef_set_led_netdev() {
 	local name="$2"
 	local sysfs="$3"
 	local dev="$4"
+	local mode="$5"
 
 	json_select_object led
 
@@ -363,6 +364,7 @@ ucidef_set_led_netdev() {
 	json_add_string type netdev
 	json_add_string sysfs "$sysfs"
 	json_add_string device "$dev"
+	[ -n "$mode" ] && json_add_string mode "$mode"
 	json_select ..
 
 	json_select ..
-- 
2.6.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list