[OpenWrt-Devel] [PATCH] base-files: led input trigger error message if kernel module is not loaded
Lars Kruse
lists at sumpfralle.de
Mon Dec 29 10:54:50 EST 2014
Hi,
I use a custom made image (for our local wifi community) with a TL-WDR4300.
Recently I disabled the config line CONFIG_PACKAGE_kmod-ledtrig-usbdev.
The absence of this module causes a bootup error message:
root at AP-1-203:/etc/rc.d# /etc/init.d/led start setting up led USB1
sh: write error: Invalid argument
/etc/rc.common: eval: line 1: can't create /sys/class/leds/tp-link:green:usb1/device_name: nonexistent directory
/etc/rc.common: eval: line 1: can't create /sys/class/leds/tp-link:green:usb1/activity_interval: nonexistent directory
setting up led USB2
sh: write error: Invalid argument
/etc/rc.common: eval: line 1: can't create /sys/class/leds/tp-link:green:usb2/device_name: nonexistent directory
/etc/rc.common: eval: line 1: can't create /sys/class/leds/tp-link:green:usb2/activity_interval: nonexistent directory
setting up led WLAN2G
After installing and loading the "ledtrig-usbdev" module the above runs fine
without error messages.
Attached you find a patch that checks the result of the trigger attempt and
emits a graceful error message with an explanation regarding the missing kernel
module instead of the rather mysterious error messages above.
Cheers,
Lars
Verify the support of the led trigger input source and complain in a helpful
way if modules are missing during bootup.
Signed-off-by: Lars Kruse <devel at sumpfralle.de>
---
diff -ruN a/openwrt/package/base-files/files/etc/init.d/led b/openwrt/package/base-files/files/etc/init.d/led
--- a/openwrt/package/base-files/files/etc/init.d/led
+++ b/openwrt/package/base-files/files/etc/init.d/led
@@ -40,7 +40,11 @@
[ $default -eq 1 ] ||
echo 0 >/sys/class/leds/${sysfs}/brightness
}
- echo $trigger > /sys/class/leds/${sysfs}/trigger
+ # this may fail if the module is not loaded
+ if ! echo $trigger > /sys/class/leds/${sysfs}/trigger 2>/dev/null; then
+ echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module"
+ return 0
+ fi
case "$trigger" in
"netdev")
[ -n "$dev" ] && {
--
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list