mac80211: support wildcard paths when matching phys
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 29 Jul 2014 09:48:07 +0000 (09:48 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 29 Jul 2014 09:48:07 +0000 (09:48 +0000)
This change introduces support for wildcard patterns in "option path"
of section "wifi-device".

Objective is to allow paths like "*/usb[0-9]/*/*" in order to claim
any usb device using the same backend type, regardless of its bus
address or phy name.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 41873

package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
package/kernel/mac80211/files/lib/wifi/mac80211.sh

index 64b0f989b76f77da98ec9c4442c08a6730244966..e6241deb5f8c115033cc9264fe9b2830e1e77c56 100644 (file)
@@ -364,9 +364,13 @@ mac80211_generate_mac() {
 
 find_phy() {
        [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
-       [ -n "$path" -a -d "/sys/devices/$path/ieee80211" ] && {
-               phy="$(ls /sys/devices/$path/ieee80211 | grep -m 1 phy)"
-               [ -n "$phy" ] && return 0
+       [ -n "$path" ] && {
+               for phy in /sys/devices/$path/ieee80211/phy*; do
+                       [ -e "$phy" ] && {
+                               phy="${phy##*/}"
+                               return 0
+                       }
+               done
        }
        [ -n "$macaddr" ] && {
                for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
index 5d3adb1511d992223066169161b03511fee252ee..a3b2199507f91fb44f5edb37d4445f0a420ea3ce 100644 (file)
@@ -8,9 +8,13 @@ lookup_phy() {
 
        local devpath
        config_get devpath "$device" path
-       [ -n "$devpath" -a -d "/sys/devices/$devpath/ieee80211" ] && {
-               phy="$(ls /sys/devices/$devpath/ieee80211 | grep -m 1 phy)"
-               [ -n "$phy" ] && return
+       [ -n "$devpath" ] && {
+               for _phy in /sys/devices/$devpath/ieee80211/phy*; do
+                       [ -e "$_phy" ] && {
+                               phy="${_phy##*/}"
+                               return
+                       }
+               done
        }
 
        local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"