summaryrefslogtreecommitdiff
path: root/package/base-files/files
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2016-10-19 12:09:45 +0200
committerRafał Miłecki <rafal@milecki.pl>2016-10-19 12:09:45 +0200
commit0658527e1ebe666cabde9267b6afbe543314160c (patch)
tree9afe96f78fd33c15b80786f418ca77a32135b20a /package/base-files/files
parent1ffb7e47be92e32a08d866399af83d4136e28e06 (diff)
downloadmtk-20170518-0658527e1ebe666cabde9267b6afbe543314160c.zip
mtk-20170518-0658527e1ebe666cabde9267b6afbe543314160c.tar.gz
mtk-20170518-0658527e1ebe666cabde9267b6afbe543314160c.tar.bz2
switch to the new usbport LED trigger
This makes init.d script handle existing UCI entries using the new trigger. It also switches all targets to use its package. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/base-files/files')
-rwxr-xr-xpackage/base-files/files/etc/init.d/led21
1 files changed, 16 insertions, 5 deletions
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index 79f2904..9a793e9 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -8,6 +8,7 @@ load_led() {
local sysfs
local trigger
local dev
+ local ports
local mode
local default
local delayon
@@ -34,6 +35,15 @@ load_led() {
return
fi
+ [ "$trigger" = "usbdev" ] && {
+ # Backward compatibility: translate to the new trigger
+ trigger="usbport"
+ # Translate port of root hub, e.g. 4-1 -> usb4-port1
+ ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p')
+ # Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4
+ [ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p')
+ }
+
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
@@ -71,11 +81,12 @@ load_led() {
echo $delayoff > /sys/class/leds/${sysfs}/delay_off
;;
- "usbdev")
- [ -n "$dev" ] && {
- echo $dev > /sys/class/leds/${sysfs}/device_name
- echo $interval > /sys/class/leds/${sysfs}/activity_interval
- }
+ "usbport")
+ local p
+
+ for p in $ports; do
+ echo 1 > /sys/class/leds/${sysfs}/ports/$p
+ done
;;
"port_state")