Rewrite module loading and unloading to make POSIX compliant, simplify
the logic a little, and modify 50modules hook to take change in
modreload into account.
diff -U 0 -rNX diffignore pm-utils.updates/pm/functions working/pm/functions
--- pm-utils.updates/pm/functions	2008-01-27 12:42:36.000000000 -0600
+++ working/pm/functions	2008-01-27 11:26:51.000000000 -0600
@@ -179,2 +174 @@
-		echo "export RESUME_MODULES=\"$1 \$RESUME_MODULES\"" \
-						>> /var/run/pm-suspend
+		touch "/var/run/pm-suspend/module:$1"
@@ -193,7 +187,2 @@
-	local UNL=$1 RET=1
-	# the kernel only knows underscores in module names, no dashes
-	UNL=${UNL//-/_}
-	# RET is the return code.
-	# If at least one module was unloaded, return 0.
-	# if the module was not loaded, also return 0 since this is no error.
-	# if no module was unloaded successfully, return 1
+	local UNL="$(echo $1 |tr -- - _)" RET=1 
+
@@ -202,2 +191,3 @@
-		if [ "$USED" == "-" ]; then
-			_rmmod $MOD $C
+		if [ "$USED" = "-" ]; then
+			# no dependent modules, just try to remove this one.
+			_rmmod "$MOD" $C
@@ -206,6 +196,5 @@
-			USED=${USED//,/ }
-			MODS=($USED)
-			# it seems slightly more likely to rmmod in one pass,
-			# if we try backwards.
-			for I in `seq [EMAIL PROTECTED] -1 0`; do
-				MOD=${MODS[$I]}
+			# modules depend on this one.  try to remove them first.
+			MODS="${USED%%*,}"
+			while [ "${MODS}" ]; do
+				# try to unload the last one first
+				MOD="${MODS##*,}"
@@ -212,0 +202,2 @@
+				# prune the last one from the list
+				MODS="${MODS%,*}"
@@ -225,0 +217 @@
+# reload all the modules in no particular order.
@@ -228,3 +220,3 @@
-	if [ "$(eval echo \$${1}_MODULE_LOAD)" == "yes" ]; then
-		modprobe "$1" >/dev/null 2>&1
-	fi
+	for x in /var/run/pm-suspend/module:* ; do
+		[ -f "${x}" ] && modprobe "${x##*:}" >/dev/null 2>&1
+	done
diff -U 0 -rNX diffignore pm-utils.updates/pm/sleep.d/50modules working/pm/sleep.d/50modules
--- pm-utils.updates/pm/sleep.d/50modules	2008-01-27 11:58:02.000000000 -0600
+++ working/pm/sleep.d/50modules	2008-01-26 13:56:11.000000000 -0600
@@ -16,4 +16 @@
-	[ -z "$RESUME_MODULES" ] && return 0
-	for x in $RESUME_MODULES ; do
-		modprobe $x
-	done
+	modreload
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to