[openwrt/openwrt] base-files: add helper functions for adding wlan device entries to board.json
LEDE Commits
lede-commits at lists.infradead.org
Fri Oct 14 04:18:57 PDT 2022
nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/7f9d3a00d8d41f2bf9fe35b30cd689b9992e7ff9
commit 7f9d3a00d8d41f2bf9fe35b30cd689b9992e7ff9
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Sep 30 19:19:51 2022 +0200
base-files: add helper functions for adding wlan device entries to board.json
These will be used to give WLAN PHYs a specific name based on path specified
in board.json. The platform board.d script can assign a specific order based
on available slots (PCIe slots, WMAC device) and device tree configuration.
This helps with maintaining config compatibility in case the device path
changes due to kernel upgrades.
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
package/base-files/files/lib/functions/system.sh | 4 ++++
package/base-files/files/lib/functions/uci-defaults.sh | 15 +++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 22eb00c515..29de2e5dd6 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -283,3 +283,7 @@ macaddr_canonicalize() {
printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null
}
+
+dt_is_enabled() {
+ grep -q okay "/proc/device-tree/$1/status"
+}
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 86f16b5125..a37e8cf824 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -646,6 +646,21 @@ ucidef_set_ntpserver() {
json_select ..
}
+ucidef_add_wlan() {
+ local path="$1"; shift
+
+ ucidef_wlan_idx=${ucidef_wlan_idx:-0}
+
+ json_select_object wlan
+ json_select_object "wl$ucidef_wlan_idx"
+ json_add_string path "$path"
+ json_add_fields "$@"
+ json_select ..
+ json_select ..
+
+ ucidef_wlan_idx="$((ucidef_wlan_idx + 1))"
+}
+
board_config_update() {
json_init
[ -f ${CFG} ] && json_load "$(cat ${CFG})"
More information about the lede-commits
mailing list