base-files/leds: merging code sequences that belongs together
authorFlorian Eckert <fe@dev.tdt.de>
Thu, 1 Feb 2024 10:31:20 +0000 (11:31 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Wed, 7 Feb 2024 14:34:43 +0000 (15:34 +0100)
Setting the trigger and checking whether the trigger can be set belong
together and should not be interrupted by other lines of code.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
package/base-files/files/etc/init.d/led

index d7fee9ebb2eb136af460a1c96f23ba85431d9731..4d3feddf649ba935f8ba2ade5b6a22ae6c9a3243 100755 (executable)
@@ -65,12 +65,11 @@ load_led() {
                [ "$default" = 0 ] &&
                        echo 0 >/sys/class/leds/${sysfs}/brightness
 
-               echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
-               ret="$?"
-
                [ $default = 1 ] &&
                        cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness
 
+               echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
+               ret="$?"
                [ $ret = 0 ] || {
                        echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module"
                        return 1