base-files: add more name source to get_dt_led helper function
authorMathias Kresin <dev@kresin.me>
Fri, 26 Jan 2018 22:36:50 +0000 (23:36 +0100)
committerMathias Kresin <dev@kresin.me>
Wed, 14 Mar 2018 18:04:52 +0000 (19:04 +0100)
Not all LED driver are using the label devicetree property for the led
name. Add support for the TI/National Semiconductor LP55xx Led Drivers,
which are using the chan-name property for the led name, as fallback.

Signed-off-by: Mathias Kresin <dev@kresin.me>
package/base-files/files/lib/functions/leds.sh

index 83e775fada9ed303ec7acd6357500dbcd3b61903..e4423b4cc8d19c2e16039c5a5d643119546c857a 100644 (file)
@@ -8,7 +8,10 @@ get_dt_led() {
        local nodepath="$basepath/aliases/led-$1"
 
        [ -f "$nodepath" ] && ledpath=$(cat "$nodepath")
-       [ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label")
+       [ -n "$ledpath" ] && \
+               label=$(cat "$basepath$ledpath/label" 2>/dev/null) || \
+               label=$(cat "$basepath$ledpath/chan-name" 2>/dev/null) || \
+               echo "led label not found" 1>&2
 
        echo "$label"
 }