get_dt_led() {
local label
+ local of_path
local ledpath=$(get_dt_led_path $1)
- [ -n "$ledpath" ] && \
+ [ -n "$ledpath" ] && {
label=$(cat "$ledpath/label" 2>/dev/null) || \
label=$(cat "$ledpath/chan-name" 2>/dev/null) || \
label=$(basename "$ledpath")
+ [ -d "/sys/class/leds/$label" ] || {
+ label=""
+ for node in /sys/class/leds/*; do
+ of_path=$(grep OF_FULLNAME "$node/uevent" | cut -f2 -d'=')
+ [ "/proc/device-tree$of_path" = "$ledpath" ] && {
+ label=$(basename "$node")
+ break
+ }
+ done
+ }
+ }
+
echo "$label"
}