OSDN Git Service

init.sh: remove wl driver if it's not used
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 13 Jun 2019 09:05:50 +0000 (17:05 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 13 Jun 2019 09:05:50 +0000 (17:05 +0800)
Sometimes the Broadcom wl driver is loaded unexpectedly. Unload it
if it's not being used.

init.sh

diff --git a/init.sh b/init.sh
index dc6b004..aee4614 100644 (file)
--- a/init.sh
+++ b/init.sh
@@ -15,6 +15,13 @@ function set_prop_if_empty()
        [ -z "$(getprop $1)" ] && set_property "$1" "$2"
 }
 
        [ -z "$(getprop $1)" ] && set_property "$1" "$2"
 }
 
+function rmmod_if_exist()
+{
+       for m in $*; do
+               [ -d /sys/module/$m ] && rmmod $m
+       done
+}
+
 function init_misc()
 {
        # device information
 function init_misc()
 {
        # device information
@@ -30,6 +37,13 @@ function init_misc()
        # enable sdcardfs if /data is not mounted on tmpfs or 9p
        mount | grep /data\ | grep -qE 'tmpfs|9p'
        [ $? -ne 0 ] && modprobe sdcardfs
        # enable sdcardfs if /data is not mounted on tmpfs or 9p
        mount | grep /data\ | grep -qE 'tmpfs|9p'
        [ $? -ne 0 ] && modprobe sdcardfs
+
+       # remove wl if it's not used
+       local wifi
+       if [ -d /sys/class/net/wlan0 ]; then
+               wifi=$(basename `readlink /sys/class/net/wlan0/device/driver`)
+               [ "$wifi" != "wl" ] && rmmod_if_exist wl
+       fi
 }
 
 function init_hal_audio()
 }
 
 function init_hal_audio()