diff options
author | Felix Fietkau <nbd@nbd.name> | 2019-10-31 12:36:55 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2019-11-05 12:09:36 +0100 |
commit | 8b15e7f661b4263a7b9fb6a410a5f58263b72caa (patch) | |
tree | d59c3a68ab5b2004cb42d6d2f77cc4dd51613f82 /package/kernel/mac80211/files/lib/netifd/mac80211.sh | |
parent | d64daf7026ce47788f12130462a3107bdab8718f (diff) | |
download | upstream-8b15e7f661b4263a7b9fb6a410a5f58263b72caa.tar.gz upstream-8b15e7f661b4263a7b9fb6a410a5f58263b72caa.tar.bz2 upstream-8b15e7f661b4263a7b9fb6a410a5f58263b72caa.zip |
mac80211: add support for multiple wiphys behind a single device
The device path will be the same for the first phy. For all subsequent
phys, the path gets an extra +1, +2, ...
Move the code for converting path to phy and vice versa to a separate
library script shared by config detection code and the netifd wireless
handler script
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/kernel/mac80211/files/lib/netifd/mac80211.sh')
-rw-r--r-- | package/kernel/mac80211/files/lib/netifd/mac80211.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/package/kernel/mac80211/files/lib/netifd/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/mac80211.sh new file mode 100644 index 0000000000..92e5c0e395 --- /dev/null +++ b/package/kernel/mac80211/files/lib/netifd/mac80211.sh @@ -0,0 +1,36 @@ +mac80211_phy_to_path() { + local phy="$1" + + [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${phy} ] || return + + local path="$(readlink -f /sys/class/ieee80211/${phy}/device)" + [ -n "$path" ] || return + + path="${path##/sys/devices/}" + case "$path" in + platform*/pci*) path="${path##platform/}";; + esac + + local p + local seq="" + for p in $(ls /sys/class/ieee80211/$phy/device/ieee80211); do + [ "$p" = "$phy" ] && { + echo "$path${seq:++$seq}" + break + } + + seq=$((${seq:-0} + 1)) + done +} + +mac80211_path_to_phy() { + local path="$1" + + local p + for p in $(ls /sys/class/ieee80211); do + local cur="$(mac80211_phy_to_path "$p")" + case "$cur" in + *$path) echo "$p"; return;; + esac + done +} |