[PATCH 2/2] mac80211: add ath10k ledtrigger abstraction
Florian Eckert
fe at dev.tdt.de
Thu Mar 17 05:41:21 PDT 2022
This change adds an application trigger ath10k under
"/usr/libexec/led-trigger". The kernel LED API of the ath10k does not
behave like the netdev trigger. For the netdev trigger, the interface to
use can be set under /sys/class/leds/<led-device>/device_name. For the
LED ath10k, the interface is added to the supported trigger name.
So we have for one interface (phy0) the following triggers for each LED.
- phy0rx
- phy0tx
- phy0assoc
- phy0radio
- phy0tpt
To make it easier for us to configure this, there is now an application
trigger. This has additional uci options.
- device: which interface we want to use (phyX)
- function: which trigger function we want to use (rx|tx|assoc|radio|tpt)
The trigger now behaves the same way again netdev trigger.
This change is backwards compatible. If the kernel trigger names are
used (phy<X>rx | phy<X>tx | phy<X>assoc | phy<X>radio | phy<X>tpt)
this will continue to work.
With this change it is now easier to create a LUCI configuration page
without Javascript magic.
Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
package/kernel/mac80211/ath.mk | 8 +++++++
.../files/usr/libexec/led-trigger/ath10k | 24 +++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100644 package/kernel/mac80211/files/usr/libexec/led-trigger/ath10k
diff --git a/package/kernel/mac80211/ath.mk b/package/kernel/mac80211/ath.mk
index 50b1eed9c8..b42a693b8a 100644
--- a/package/kernel/mac80211/ath.mk
+++ b/package/kernel/mac80211/ath.mk
@@ -289,6 +289,14 @@ define KernelPackage/ath10k-smallbuffers
VARIANT:=smallbuffers
endef
+ifdef CONFIG_ATH10K_LEDS
+define KernelPackage/ath10k/install
+ $(INSTALL_DIR) $(1)/usr/libexec/led-trigger
+ $(INSTALL_DATA) ./files/usr/libexec/led-trigger/ath10k \
+ $(1)/usr/libexec/led-trigger
+endef
+endif #CONFIG_ATH10K_LEDS
+
define KernelPackage/carl9170
$(call KernelPackage/mac80211/Default)
TITLE:=Driver for Atheros AR9170 USB sticks
diff --git a/package/kernel/mac80211/files/usr/libexec/led-trigger/ath10k b/package/kernel/mac80211/files/usr/libexec/led-trigger/ath10k
new file mode 100644
index 0000000000..7abee76d04
--- /dev/null
+++ b/package/kernel/mac80211/files/usr/libexec/led-trigger/ath10k
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+main() {
+ . /lib/functions.sh
+ local led="$1"
+
+ local device="$(uci_get system "$led" device)"
+ local function="$(uci_get system "$led" function)"
+ local sysfs="$(uci_get system "$led" sysfs)"
+
+ [ -f "/sys/class/leds/${sysfs}/trigger" ] || {
+ logger -t "leds/ath10k" -p "warning" "LED '${sysfs}' not found"
+ return 0
+ }
+
+ [ "$(cat "/sys/class/leds/${sysfs}/trigger" | grep -q "${device}${function}")" ] && {
+ logger -t "leds/ath10k" -p "warning" "Trigger '${device}${function}' not found"
+ return 0
+ }
+
+ echo "${device}${function}" > /sys/class/leds/${sysfs}/trigger
+}
+
+main "$@"
--
2.20.1
More information about the openwrt-devel
mailing list