[LEDE-DEV] [PATCH 2/2] x86: Add board configs for the PC Engines APU2

David Woodhouse dwmw2 at infradead.org
Mon Feb 13 03:40:11 PST 2017


On Mon, 2017-02-13 at 02:01 -0600, Chris Blake wrote:
> 
> +get_status_led() {
> +        case $(x86_board_name) in
> +        pc-engines-apu2)
> +                status_led="apu2:green:power"
> +                ;;
> +        esac
> +}

Ick. Why hard-code that and have board-specific stuff in more than one
place, instead of just configuring it with everything else, then
deferring to the configuration? Can't we do something like this
instead?

diff --git a/target/linux/x86/base-files/etc/diag.sh b/target/linux/x86/base-files/etc/diag.sh
index 2426161..c51d080 100755
--- a/target/linux/x86/base-files/etc/diag.sh
+++ b/target/linux/x86/base-files/etc/diag.sh
@@ -3,15 +3,26 @@
 # Copyright © 2017 OpenWrt.org
 #
 
+. /lib/functions.sh
 . /lib/functions/leds.sh
 . /lib/x86.sh
 
+match_diag_led() {
+	local name
+	local default
+	local sysfs
+	config_get name "$1" name
+	config_get default "$1" default
+	config_get sysfs "$1" sysfs
+
+	if [ "$name" = "DIAG" -a "$default" = "1" ]; then
+		status_led="$sysfs"
+	fi
+}
+
 get_status_led() {
-        case $(x86_board_name) in
-        pc-engines-apu2)
-                status_led="apu2:green:power"
-                ;;
-        esac
+	config_load system
+	config_foreach match_diag_led led
 }
 
 set_state() {
diff --git a/target/linux/x86/base-files/etc/board.d/01_leds b/target/linux/x86/base-files/etc/board.d/01_leds
index 05ddc71..50eac33 100755
--- a/target/linux/x86/base-files/etc/board.d/01_leds
+++ b/target/linux/x86/base-files/etc/board.d/01_leds
@@ -14,11 +14,12 @@ case "$board" in
 pc-engines-apu2)
 	ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0"
 	ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "eth1"
+	ucidef_set_led_default "diag" "DIAG" "apu2:green:power" "1"
 	;;
 traverse-technologies-geos)
 	ucidef_set_led_netdev "lan" "LAN" "geos:1" "br-lan" "tx rx"
 	ucidef_set_led_netdev "wlan" "WiFi" "geos:2" "phy0tpt"
-	ucidef_set_led_default "diag" "DIAG" "geos:3" "0"
+	ucidef_set_led_default "diag" "DIAG" "geos:3" "1"
 	;;
 esac
 board_config_flush
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4938 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170213/83f1b783/attachment.bin>


More information about the Lede-dev mailing list