diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 04db33c5d..1fe0fa4a9 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -496,19 +496,15 @@ function Kobo:initNetworkManager(NetworkMgr) -- NOTE: Cheap-ass way of checking if Wi-Fi seems to be enabled... -- Since the crux of the issues lies in race-y module unloading, this is perfectly fine for our usage. function NetworkMgr:isWifiOn() - local fd = io.open("/proc/modules", "r") - if fd then - local lsmod = fd:read("*all") - fd:close() - -- lsmod is usually empty, unless Wi-Fi or USB is enabled - -- We could alternatively check if lfs.attributes("/proc/sys/net/ipv4/conf/" .. os.getenv("INTERFACE"), "mode") == "directory" - -- c.f., also what Cervantes does via /sys/class/net/eth0/carrier to check if the interface is up. - -- That said, since we only care about whether *modules* are loaded, this does the job nicely. - if lsmod:len() > 0 then - local module = os.getenv("WIFI_MODULE") or "sdio_wifi_pwr" - if lsmod:find(module) then - return true - end + local needle = os.getenv("WIFI_MODULE") or "sdio_wifi_pwr" + local nlen = #needle + -- /proc/modules is usually empty, unless Wi-Fi or USB is enabled + -- We could alternatively check if lfs.attributes("/proc/sys/net/ipv4/conf/" .. os.getenv("INTERFACE"), "mode") == "directory" + -- c.f., also what Cervantes does via /sys/class/net/eth0/carrier to check if the interface is up. + -- That said, since we only care about whether *modules* are loaded, this does the job nicely. + for haystack in io.lines("/proc/modules") do + if haystack:sub(1, nlen) == needle then + return true end end return false diff --git a/platform/kobo/disable-wifi.sh b/platform/kobo/disable-wifi.sh index d35b6dc3c..df3dcad37 100755 --- a/platform/kobo/disable-wifi.sh +++ b/platform/kobo/disable-wifi.sh @@ -40,11 +40,11 @@ ifconfig "${INTERFACE}" down # Some sleep in between may avoid system getting hung # (we test if a module is actually loaded to avoid unneeded sleeps) -if grep -q "${WIFI_MODULE}" "/proc/modules"; then +if grep -q "^${WIFI_MODULE}" "/proc/modules"; then usleep 250000 rmmod "${WIFI_MODULE}" fi -if grep -q "sdio_wifi_pwr" "/proc/modules"; then +if grep -q "^sdio_wifi_pwr" "/proc/modules"; then # Handle the shitty DVFS switcheroo... if [ -n "${CPUFREQ_DVFS}" ]; then echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable" diff --git a/platform/kobo/enable-wifi.sh b/platform/kobo/enable-wifi.sh index af6a9a563..7cd8e112d 100755 --- a/platform/kobo/enable-wifi.sh +++ b/platform/kobo/enable-wifi.sh @@ -14,7 +14,7 @@ for fd in /proc/"$$"/fd/*; do done # Load wifi modules and enable wifi. -if ! grep -q "sdio_wifi_pwr" "/proc/modules"; then +if ! grep -q "^sdio_wifi_pwr" "/proc/modules"; then if [ -e "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko" ]; then # Handle the shitty DVFS switcheroo... if [ -n "${CPUFREQ_DVFS}" ]; then @@ -32,7 +32,7 @@ fi # Moar sleep! usleep 250000 # NOTE: Used to be exported in WIFI_MODULE_PATH before FW 4.23 -if ! grep -q "${WIFI_MODULE}" "/proc/modules"; then +if ! grep -q "^${WIFI_MODULE}" "/proc/modules"; then # Set the Wi-Fi regulatory domain properly if necessary... WIFI_COUNTRY_CODE_PARM="" if grep -q "^WifiRegulatoryDomain=" "/mnt/onboard/.kobo/Kobo/Kobo eReader.conf"; then diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index b3b4c6371..f40a49789 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -58,7 +58,7 @@ if [ "${current_cpufreq_gov}" != "interactive" ]; then # but the code in the published H2O kernel sources actually does the reverse, and is commented out ;). # It is now entirely handled by Nickel, right *before* loading/unloading that module. # (There's also a bug(?) where that behavior is inverted for the *first* Wi-Fi session after a cold boot...) - if grep -q "sdio_wifi_pwr" "/proc/modules"; then + if grep -q "^sdio_wifi_pwr" "/proc/modules"; then # Wi-Fi is enabled, make sure DVFS is on echo "userspace" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" echo "1" >"/sys/devices/platform/mxc_dvfs_core.0/enable" @@ -299,11 +299,14 @@ esac # The actual swap is done in a function, because we can disable it in the Developer settings, and we want to honor it on restart. ko_do_fbdepth() { - # On sunxi, the fb state is meaningless, and the minimal disp fb doesn't actually support 8bpp anyway, - # so just make sure we're set @ UR. + # On sunxi, the fb state is meaningless, and the minimal disp fb doesn't actually support 8bpp anyway... if [ "${PLATFORM}" = "b300-ntx" ]; then + # NOTE: The fb state is *completely* meaningless on this platform. + # This is effectively a noop, we're just keeping it for logging purposes... echo "Making sure that rotation is set to Portrait" >>crash.log 2>&1 - ./fbdepth -d 32 -R UR >>crash.log 2>&1 + ./fbdepth -R UR >>crash.log 2>&1 + # We haven't actually done anything, so don't do anything on exit either ;). + unset ORIG_FB_BPP return fi diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 3f84666b5..4b81c77a3 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -26,7 +26,7 @@ unset FBINK_FORCE_ROTA ) & # Make sure we kill the Wi-Fi first, because nickel apparently doesn't like it if it's up... (cf. #1520) -if grep -q "${WIFI_MODULE}" "/proc/modules"; then +if grep -q "^${WIFI_MODULE}" "/proc/modules"; then killall -q -TERM restore-wifi-async.sh enable-wifi.sh obtain-ip.sh cp -a "/etc/resolv.conf" "/tmp/resolv.ko" old_hash="$(md5sum "/etc/resolv.conf" | cut -f1 -d' ')" @@ -66,7 +66,7 @@ if grep -q "${WIFI_MODULE}" "/proc/modules"; then usleep 250000 rmmod "${WIFI_MODULE}" - if grep -q "sdio_wifi_pwr" "/proc/modules"; then + if grep -q "^sdio_wifi_pwr" "/proc/modules"; then if [ -n "${CPUFREQ_DVFS}" ]; then echo "0" >"/sys/devices/platform/mxc_dvfs_core.0/enable" # Leave Nickel in its usual state, don't try to use conservative