Otherwise there is no way other than reading driver code to determine
why running zzz(8) for example does not do anything on certain machines.

apm(4/arm64) for one currently does not implement suspend and resume,
i.e. it yields ENOSUPP which gets lost in userland.

This still does not make `zzz' or `apm -z' report the informative
warning, but syslog now has it:

        $ zzz
        Suspending system...
        $ tail -n3 /var/log/messages
        Mar 20 19:16:57 pine64 apmd: system suspending
        Mar 20 19:16:57 pine64 apmd: battery status: unknown. external power 
status: not known. estimated battery life 0%
        Mar 20 19:16:58 pine64 apmd: suspend: Operation not supported


Feedback? OK?

Index: apmd.c
===================================================================
RCS file: /cvs/src/usr.sbin/apmd/apmd.c,v
retrieving revision 1.101
diff -u -p -r1.101 apmd.c
--- apmd.c      16 Mar 2021 09:00:43 -0000      1.101
+++ apmd.c      20 Mar 2021 18:38:11 -0000
@@ -329,7 +329,8 @@ suspend(int ctl_fd)
        do_etc_file(_PATH_APM_ETC_SUSPEND);
        sync();
        sleep(1);
-       ioctl(ctl_fd, APM_IOC_SUSPEND, 0);
+       if (ioctl(ctl_fd, APM_IOC_SUSPEND, 0) == -1)
+               logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno));
 }
 
 void
@@ -340,7 +341,8 @@ stand_by(int ctl_fd)
        do_etc_file(_PATH_APM_ETC_STANDBY);
        sync();
        sleep(1);
-       ioctl(ctl_fd, APM_IOC_STANDBY, 0);
+       if (ioctl(ctl_fd, APM_IOC_STANDBY, 0) == -1)
+               logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno));
 }
 
 void
@@ -351,7 +353,8 @@ hibernate(int ctl_fd)
        do_etc_file(_PATH_APM_ETC_HIBERNATE);
        sync();
        sleep(1);
-       ioctl(ctl_fd, APM_IOC_HIBERNATE, 0);
+       if (ioctl(ctl_fd, APM_IOC_HIBERNATE, 0) == -1)
+               logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno));
 }
 
 void

Reply via email to