blob: 4ceda7333411413837244cd20a69a1bdac4c9b33 [file] [log] [blame]
From 3059bdb03918a5acf239a245f5d78f45253ebf94 Mon Sep 17 00:00:00 2001
From: Sam Leffler <sleffler@chromium.org>
Date: Wed, 10 Nov 2010 10:20:56 -0800
Subject: [PATCH 7/8] laptop-mode-tools: switch wifi support to be nl80211-only
We support only nl80211 WiFi devices; no more WEXT support:
- remove old script that used iwconfig
- add new module script that uses iw to ena/dis power save
Note this also fixes wifi power save operation for nl80211 devices as the iwconfig code never worked right due to it checking the wrong file under /sys. This means we should now have lower latency on AC because we'll turn off power save.
BUG=7138
TEST=gmerge to device; suspend+resume and check power save state of wlan0; also run sh -x laptop_mode auto force and verify the right things are happenig for wifi devices
Review URL: http://codereview.chromium.org/4675003
Change-Id: Ifac0b67c7eb6663fb911be267711c44e6e8538b0
---
.../modules/wifi-nl80211-powermgmt | 26 ++++++++++++++++++++
.../share/laptop-mode-tools/modules/wifi-powermgmt | 24 ------------------
2 files changed, 26 insertions(+), 24 deletions(-)
create mode 100755 laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-nl80211-powermgmt
delete mode 100755 laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-powermgmt
diff -ruN /dev/null laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-nl80211-powermgmt
new file mode 100755
index 0000000..934d080
--- /dev/null
+++ laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-nl80211-powermgmt
@@ -0,0 +1,26 @@
+IW=/usr/sbin/iw
+
+if [ ! -x $IW ]; then
+ log "VERBOSE" "No $IW program, WiFi power setting is disabled."
+elif [ x$CONTROL_WIFI_POWER = x1 ] ; then
+ if [ $ON_AC -eq 1 ] ; then
+ power_mgmt="off"
+ else
+ power_mgmt="on"
+ fi
+
+ for DEVICE in /sys/class/net/* ; do
+ if [ -d $DEVICE/phy80211 ]; then
+ dev=`basename $DEVICE`
+ $IW $dev set power_save $power_mgmt
+ ret=$?
+ if [ "$ret" = "0" ]; then
+ log "VERBOSE" "Power Management set to $power_mgmt for $dev."
+ else
+ log "VERBOSE" "Failed to set Power Management to $power_mgmt for $dev."
+ fi
+ fi
+ done
+else
+ log "VERBOSE" "WiFi power setting is disabled."
+fi
diff -ruN laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-powermgmt /dev/null
deleted file mode 100755
index 2efb1a6..0000000
--- laptop-mode-tools_1.57/usr/share/laptop-mode-tools/modules/wifi-powermgmt
+++ /dev/null
@@ -1,24 +0,0 @@
-IWCONFIG=iwconfig
-
-if [ x$CONTROL_WIFI_POWER = x1 ] ; then
- if [ $ON_AC -eq 1 ] ; then
- power_mgmt="off"
- else
- power_mgmt="on"
- fi
-
- for DEVICE in /sys/class/net/* ; do
- if [ -d $DEVICE/wireless ]; then
- dev=`basename $DEVICE`
- $IWCONFIG $dev power $power_mgmt
- ret=$?
- if [ "$ret" = "0" ]; then
- log "VERBOSE" "Power Management set to $power_mgmt for $dev."
- else
- log "VERBOSE" "Failed to set Power Management to $power_mgmt for $dev."
- fi
- fi
- done
-else
- log "VERBOSE" "WiFi power setting is disabled."
-fi
--
1.7.2.3