[Pm-utils] [PATCH] userspace suspend (s2disk/s2ram) support

Peter Jones pjones at redhat.com
Tue Oct 31 08:33:51 PST 2006


OK, what do you think of this for the INHIBIT stuff:

Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.27
diff -u -p -r1.27 functions
--- pm/functions        31 Oct 2006 15:40:51 -0000      1.27
+++ pm/functions        31 Oct 2006 16:28:35 -0000
@@ -7,6 +7,7 @@ HIBERNATE_RESUME_POST_VIDEO=no
 SUSPEND_MODULES=""
 # It is important to _not_ initialize RESUME_MODULES here.
 PM_LOGFILE=${PM_LOGFILE:=/var/log/pm-suspend.log}
+INHIBIT=/var/run/pm-utils.inhibit
 
 [ -f /etc/pm/config ] && . /etc/pm/config
 
@@ -21,6 +22,7 @@ add_global HIBERNATE_RESUME_POST_VIDEO
 add_global SUSPEND_MODULES
 add_global RESUME_MODULES
 add_global PM_LOGFILE
+add_global INHIBIT
 
 source_configs()
 {
@@ -113,6 +115,17 @@ get_power_status()
        return $RETVAL
 }
 
+do_suspend()
+{
+       pm-pmu --suspend || echo -n "mem" > /sys/power/state
+}
+
+do_hibernate()
+{
+       echo -n "platform" > /sys/power/disk
+       echo -n "disk" > /sys/power/state
+}
+
 pm_main()
 {
        if [ -n "$PM_LOGFILE" ]; then
@@ -120,20 +133,17 @@ pm_main()
                exec > "$PM_LOGFILE" 2>&1
        fi
        take_suspend_lock || exit 1
+
+       rm -f "$INHIBIT"
+
        run_hooks "$1"
-       sync ; sync ; sync
 
-       case "$1" in
-               suspend)
-                       pm-pmu --suspend || echo -n "mem"
> /sys/power/state
-                       run_hooks resume reverse
-                       ;;
-               hibernate)
-                       echo -n "platform" > /sys/power/disk
-                       echo -n "disk" > /sys/power/state
-                       run_hooks thaw reverse
-                       ;;
-       esac
+       if [ ! -e "$INHIBIT" -a "$(type -t "do_$1")" == "function" ]; then
+               sync ; sync ; sync
+               "do_$1"
+       fi
+
+       run_hooks "$2" reverse
 
        remove_suspend_lock 200
 
Index: src/pm-action
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-action,v
retrieving revision 1.5
diff -u -p -r1.5 pm-action
--- src/pm-action       12 Jun 2006 17:12:40 -0000      1.5
+++ src/pm-action       31 Oct 2006 16:31:08 -0000
@@ -40,6 +40,11 @@ export LC_COLLATE=C
 ACTION=$(basename "$0")
 ACTION=${ACTION#pm-}
 
-pm_main "$ACTION"
+case "$ACTION" in
+       suspend) REVERSE=resume ;;
+       hibernate) REVERSE=thaw ;;
+esac
+
+pm_main "$ACTION" "$REVERSE"
 
 exit $?


-- 
  Peter



More information about the Pm-utils mailing list