From eb76b2ac687557ba7bce65a942fec2df95b094fd Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Thu, 6 Jul 2017 20:16:26 +0200 Subject: [PATCH] suspend: adapt script for NetworkManager integration Now the suspend script brings down all the wireless interfaces that are managed by ifupdown command (in the '/etc/network/interfaces' file) and then unloads the wireless driver. On resume the script triggers an event so udev reloads the wireless driver and then brings up the interfaces that were brought down on suspend. https://jira.digi.com/browse/DEL-4288 Signed-off-by: Javier Viguera --- .../busybox/busybox-1.24.1/ccimx6/suspend | 22 +++++++++++----- .../busybox/busybox-1.24.1/ccimx6ul/suspend | 25 ++++++++++++------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6/suspend index ceded7b74..65aeed292 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6/suspend +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6/suspend @@ -31,9 +31,12 @@ usage() { } suspend_interfaces() { - # Suspend wireless interface - if grep -qs '^wlan0' /var/run/ifstate; then - ifdown wlan0 && up_wlan_on_resume="1" && sleep 0.5 && rmmod ath6kl_sdio + # Suspend wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do + ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" + done + grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core fi # Suspend bluetooth interface @@ -43,9 +46,16 @@ suspend_interfaces() { } resume_interfaces() { - # Resume wireless interface - if ! grep -qs '^wlan0' /var/run/ifstate; then - [ -n "${up_wlan_on_resume}" ] && modprobe ath6kl_sdio && sleep 0.5 && ifup wlan0 + # Resume wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + # Trigger wireless module loading event, and wait until the interface exists + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301" + timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + + # Bring up the interfaces that were bring down on suspend + for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do + grep -qs "^${i}" /var/run/ifstate || ifup "${i}" + done fi # Resume bluetooth interface diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend index 33086f979..25b286c14 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend @@ -31,12 +31,12 @@ usage() { } suspend_interfaces() { - # Suspend wireless interface - if grep -qs '^wlan0' /var/run/ifstate; then - ifdown wlan0 && up_wlan_on_resume="1" - fi - if grep -qs '^wlan' /proc/modules; then - rmmod wlan + # Suspend wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do + ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" + done + grep -qs '^wlan' /proc/modules && rmmod wlan fi # Suspend bluetooth interface @@ -46,9 +46,16 @@ suspend_interfaces() { } resume_interfaces() { - # Resume wireless interface - if ! grep -qs '^wlan0' /var/run/ifstate; then - [ -n "${up_wlan_on_resume}" ] && ifup wlan0 + # Resume wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + # Trigger wireless module loading event, and wait until the interface exists + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A" + timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + + # Bring up the interfaces that were bring down on suspend + for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do + grep -qs "^${i}" /var/run/ifstate || ifup "${i}" + done fi # Resume bluetooth interface