The following patch fixes two things: First, DEVICE_SUSPEND errors are
no longer ignored. Since we have defaults for methods we should no
longer ignore these errors. Also, DEVICE_RESUME wasn't done when the
apm_suspend_system event failed.

Second, in the ordering of DEVICE_* and apm_hook_* is not symmetric for
suspend and resume. The patch reverses the resume case as well to be

        apm_hook_resume(...)
        DEVICE_RESUME(root)

Send me some feedback on this. I've mailed the people mentioned in the
head of the file, but so far got no response. I would like to make sure
we get this right when USB devices are used. Some of them don't suspend
and the suspend should be refused in that case.

Nick

--
[EMAIL PROTECTED]
[EMAIL PROTECTED]                                          USB project
http://www.etla.net/~n_hibma/

--- /usr/src/sys/i386/apm/apm.c Thu Dec  2 03:13:00 1999
+++ /heidi/usr/current/src/sys/i386/apm/apm.c   Sun Jan 23 14:07:49 2000
@@ -473,19 +473,19 @@
 
        if (sc->initialized) {
                error = DEVICE_SUSPEND(root_bus);
-               /*
-                * XXX Shouldn't ignore the error like this, but should
-                * instead fix the newbus code.  Until that happens,
-                * I'm doing this to get suspend working again.
-                */
-               if (error)
-                       printf("DEVICE_SUSPEND error %d, ignored\n", error);
-               apm_execute_hook(hook[APM_HOOK_SUSPEND]);
-               if (apm_suspend_system(PMST_SUSPEND) == 0)
-                       apm_processevent();
-               else
-                       /* Failure, 'resume' the system again */
-                       apm_execute_hook(hook[APM_HOOK_RESUME]);
+               if (error) {
+                       printf("Suspend failed, error %d\n", error);
+                       DEVICE_RESUME(root_bus);
+               } else {
+                       apm_execute_hook(hook[APM_HOOK_SUSPEND]);
+                       if (apm_suspend_system(PMST_SUSPEND) == 0)
+                               apm_processevent();
+                       else {
+                               /* Failure, 'resume' the system again */
+                               apm_execute_hook(hook[APM_HOOK_RESUME]);
+                               DEVICE_RESUME(root_bus);
+                       }
+               }
        }
 }
 
@@ -593,8 +593,8 @@
                return;
 
        if (sc->initialized) {
-               DEVICE_RESUME(root_bus);
                apm_execute_hook(hook[APM_HOOK_RESUME]);
+               DEVICE_RESUME(root_bus);
        }
 }
 

Reply via email to