[LEDE-DEV] [PATCH V2 2/3] switch to the new usbport LED trigger
Mathias Kresin
dev at kresin.me
Sun Oct 16 06:12:58 PDT 2016
13.10.2016 09:44, Rafał Miłecki:
> From: Rafał Miłecki <rafal at milecki.pl>
>
> 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 at milecki.pl>
> ---
> package/base-files/files/etc/init.d/led | 13 +++--
> target/linux/apm821xx/image/Makefile | 4 +-
> target/linux/apm821xx/nand/profiles/00-default.mk | 2 +-
> target/linux/apm821xx/sata/profiles/00-default.mk | 2 +-
> target/linux/ar71xx/generic/profiles/00-default.mk | 2 +-
> target/linux/ar71xx/image/generic.mk | 14 ++---
> target/linux/ar71xx/image/legacy-devices.mk | 44 +++++++--------
> target/linux/ar71xx/image/nand.mk | 8 +--
> target/linux/ar71xx/image/tp-link.mk | 62 +++++++++++-----------
> target/linux/ar71xx/nand/profiles/00-default.mk | 2 +-
> target/linux/brcm63xx/image/Makefile | 4 +-
> target/linux/ipq806x/Makefile | 2 +-
> target/linux/lantiq/image/Makefile | 36 ++++++-------
> target/linux/lantiq/image/tp-link.mk | 6 +--
> target/linux/mcs814x/Makefile | 2 +-
> target/linux/mediatek/profiles/default.mk | 2 +-
> target/linux/mvebu/config-4.4 | 2 +-
> target/linux/oxnas/Makefile | 2 +-
> target/linux/ramips/image/mt7620.mk | 6 +--
> target/linux/ramips/image/mt7621.mk | 18 +++----
> target/linux/ramips/image/mt7628.mk | 8 +--
> target/linux/ramips/image/rt305x-legacy.mk | 12 ++---
> target/linux/ramips/image/rt305x.mk | 18 +++----
> target/linux/ramips/mt7620/profiles/00-default.mk | 2 +-
> target/linux/ramips/mt7621/profiles/00-default.mk | 2 +-
> target/linux/ramips/mt7628/profiles/00-default.mk | 2 +-
> target/linux/ramips/mt7688/profiles/00-default.mk | 2 +-
> target/linux/ramips/rt305x/profiles/00-default.mk | 2 +-
> 28 files changed, 144 insertions(+), 137 deletions(-)
>
> diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
> index 79f2904..507dcbf 100755
> --- a/package/base-files/files/etc/init.d/led
> +++ b/package/base-files/files/etc/init.d/led
> @@ -47,6 +47,8 @@ load_led() {
> echo 0 >/sys/class/leds/${sysfs}/brightness
>
> echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
> + # Backward compatibility
> + [ $trigger = "usbdev" ] && echo usbport > /sys/class/leds/${sysfs}/trigger 2> /dev/null
> ret="$?"
>
> [ $default = 1 ] &&
> @@ -72,9 +74,14 @@ load_led() {
> ;;
>
> "usbdev")
> - [ -n "$dev" ] && {
> - echo $dev > /sys/class/leds/${sysfs}/device_name
> - echo $interval > /sys/class/leds/${sysfs}/activity_interval
> + local usbport
> +
> + # Translate USB dev/port format of the old usbdev trigger
> + usbport=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p')
> + [ -z "$usbport" ] && usbport=$(echo "$dev" | sed -n 's/\./-port/p')
I'm not sure if I got the purpose of this sed call correctly. As far as
I can see, it should fixup usb ports defined as "usb1.1". Via a quick
grep I couldn't find anything like that used.
I rather would suggest to add a line which allows to use the new syntax
instead:
[ -z "$usbport" ] && usbport="${dev}"
> +
> + [ -n "$usbport" ] && {
> + echo 1 > /sys/class/leds/${sysfs}/ports/$usbport
> }
What about adding something that allows to add all or multiple usb ports
(using the new syntax of course) to a single LED (which is thanks to
your usbport trigger now possible):
[ "$usbport" = "*" ] && usbport=$(ls /sys/class/leds/${sysfs}/ports/)
for port in ${usbport}; do
echo 1 > "/sys/class/leds/${sysfs}/ports/${port}"
done
Mathias
More information about the Lede-dev
mailing list