On Sun, Jul 24, 2011 at 10:53:42AM +0200, Felix Fietkau wrote:
> On 2011-07-18 3:54 PM, Daniel Golle wrote:
> > To work-around this bug, I created a simple way to initialize the wifi 
> > driver even if the device is disabled and/or there are no vifs, so they 
> > there are sane values in the webinterface from the first moment on and the 
> > users won't get too confused.
> > I guess the right way[tm] to do this would be fixing madwifi, but we all 
> > know that won't happen...
> How about putting this into a separate init script instead of adding 
> hackery to a generic script?
A seperate init script needs additional hackery in LuCI/ucitrigger to get called
once the user changes the affected config entries. That would be even more 
overkill than my previous solution ;)
I figured the most simple and non-intrusive way to achieve the desired result 
is moving things inside /lib/madwifi.sh: As scan_atheros gets called 
before enable_atheros in every case, the parts in enable_atheros to set 
countrycode, regdomain and outdoor can simply be moved over to scan_atheros.
This results in the settings being applied even if the interface is disabled or
without any vifs. Obviously, no changes to /sbin/wifi are needed to do that.

Signed-off-by: Daniel Golle <[email protected]>


Index: package/madwifi/files/lib/wifi/madwifi.sh
===================================================================
--- package/madwifi/files/lib/wifi/madwifi.sh   (revision 27690)
+++ package/madwifi/files/lib/wifi/madwifi.sh   (working copy)
@@ -6,6 +6,24 @@
        local wds
        local adhoc ahdemo sta ap monitor
        
+       config_get regdomain "$device" regdomain
+       [ -n "$regdomain" ] && echo "$regdomain" > 
/proc/sys/dev/$device/regdomain
+
+       config_get country "$device" country
+       [ -z "$country" ] && country="0"
+       echo "$country" > /proc/sys/dev/$device/countrycode
+
+       config_get_bool outdoor "$device" outdoor "0"
+       echo "$outdoor" > /proc/sys/dev/$device/outdoor
+
+       ifname=$(wlanconfig "${device}-temp" create wlandev "$device" wlanmode 
ap)
+       [ $? -ne 0 ] && {
+               echo "scan_atheros($device): Failed to set up temporary vif" >&2
+               continue
+       }
+       ifconfig "$ifname" up
+       wlanconfig "$ifname" destroy
+
        config_get vifs "$device" vifs
        for vif in $vifs; do
        
@@ -68,16 +86,6 @@
 enable_atheros() {
        local device="$1"
 
-       config_get regdomain "$device" regdomain
-       [ -n "$regdomain" ] && echo "$regdomain" > 
/proc/sys/dev/$device/regdomain
-
-       config_get country "$device" country
-       [ -z "$country" ] && country="0"
-       echo "$country" > /proc/sys/dev/$device/countrycode
-
-       config_get_bool outdoor "$device" outdoor "0"
-       echo "$outdoor" > /proc/sys/dev/$device/outdoor
-
        config_get channel "$device" channel
        config_get vifs "$device" vifs
        config_get txpower "$device" txpower
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to