base-files: add support for speed mask to switch config init scripts
authorFelix Fietkau <nbd@openwrt.org>
Thu, 25 Feb 2016 13:31:29 +0000 (13:31 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 25 Feb 2016 13:31:29 +0000 (13:31 +0000)
This patch adds extra parameter to switch LED trigger initialization
functions.  New functionality maintains backward compatibility, so
calling functions without setting new speed_mask parameter works
as expected.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
SVN-Revision: 48776

package/base-files/files/bin/config_generate
package/base-files/files/etc/init.d/led
package/base-files/files/lib/functions/uci-defaults.sh

index 28ba0e2694bd1ffb9810131d05697bb9ed72f849..865dccc450b15c4fcca0d3048e05abab7b9ee244 100755 (executable)
@@ -296,10 +296,11 @@ generate_led() {
                ;;
 
                switch)
-                       local port_mask
-                       json_get_vars port_mask
+                       local port_mask speed_mask
+                       json_get_vars port_mask speed_mask
                        uci -q batch <<-EOF
                                set system.$cfg.port_mask='$port_mask'
+                               set system.$cfg.speed_mask='$speed_mask'
                        EOF
                ;;
 
index 84cd028bd8d28f923fa64bd6a554befbef56de1b..d1521a9a61fc96333fc25781d4f43f6ab38d553f 100755 (executable)
@@ -88,11 +88,14 @@ load_led() {
                        ;;
 
                switch[0-9]*)
-                       local port_mask
+                       local port_mask speed_mask
 
                        config_get port_mask $1 port_mask
                        [ -n "$port_mask" ] && \
                                echo $port_mask > /sys/class/leds/${sysfs}/port_mask
+                       config_get speed_mask $1 speed_mask
+                       [ -n "$speed_mask" ] && \
+                               echo $speed_mask > /sys/class/leds/${sysfs}/speed_mask
                        ;;
                esac
        }
index 84b78b84ef747f08de61a6a260015fd0b0e6ac6d..d556844e95c021ce23d5cbc7cb60e975abb5035e 100755 (executable)
@@ -410,6 +410,7 @@ ucidef_set_led_switch() {
        local sysfs="$3"
        local trigger="$4"
        local port_mask="$5"
+       local speed_mask="$6"
 
        json_select_object led
 
@@ -419,6 +420,7 @@ ucidef_set_led_switch() {
        json_add_string sysfs "$sysfs"
        json_add_string trigger "$trigger"
        json_add_string port_mask "$port_mask"
+       json_add_string speed_mask "$speed_mask"
        json_select ..
 
        json_select ..