[PATCH xserver 03/25] hw/kdrive: Use passed-in fd for kdrive/linux APM monitoring [v2]
Keith Packard
keithp at keithp.com
Wed May 25 05:38:40 UTC 2016
This is a cleanup, proposed by Adam Jackson, but wasn't merged with
the original NotifyFD changes.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
hw/kdrive/linux/linux.c | 64 ++++++++++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index a52bdef..bc48d8d 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -174,41 +174,39 @@ static Bool LinuxApmRunning;
static void
LinuxApmNotify(int fd, int mask, void *blockData)
{
- if (LinuxApmFd >= 0) {
- apm_event_t event;
- Bool running = LinuxApmRunning;
- int cmd = APM_IOC_SUSPEND;
-
- while (read(LinuxApmFd, &event, sizeof(event)) == sizeof(event)) {
- switch (event) {
- case APM_SYS_STANDBY:
- case APM_USER_STANDBY:
- running = FALSE;
- cmd = APM_IOC_STANDBY;
- break;
- case APM_SYS_SUSPEND:
- case APM_USER_SUSPEND:
- case APM_CRITICAL_SUSPEND:
- running = FALSE;
- cmd = APM_IOC_SUSPEND;
- break;
- case APM_NORMAL_RESUME:
- case APM_CRITICAL_RESUME:
- case APM_STANDBY_RESUME:
- running = TRUE;
- break;
- }
- }
- if (running && !LinuxApmRunning) {
- KdResume();
- LinuxApmRunning = TRUE;
- }
- else if (!running && LinuxApmRunning) {
- KdSuspend();
- LinuxApmRunning = FALSE;
- ioctl(LinuxApmFd, cmd, 0);
+ apm_event_t event;
+ Bool running = LinuxApmRunning;
+ int cmd = APM_IOC_SUSPEND;
+
+ while (read(fd, &event, sizeof(event)) == sizeof(event)) {
+ switch (event) {
+ case APM_SYS_STANDBY:
+ case APM_USER_STANDBY:
+ running = FALSE;
+ cmd = APM_IOC_STANDBY;
+ break;
+ case APM_SYS_SUSPEND:
+ case APM_USER_SUSPEND:
+ case APM_CRITICAL_SUSPEND:
+ running = FALSE;
+ cmd = APM_IOC_SUSPEND;
+ break;
+ case APM_NORMAL_RESUME:
+ case APM_CRITICAL_RESUME:
+ case APM_STANDBY_RESUME:
+ running = TRUE;
+ break;
}
}
+ if (running && !LinuxApmRunning) {
+ KdResume();
+ LinuxApmRunning = TRUE;
+ }
+ else if (!running && LinuxApmRunning) {
+ KdSuspend();
+ LinuxApmRunning = FALSE;
+ ioctl(fd, cmd, 0);
+ }
}
#ifdef FNONBLOCK
--
2.8.0.rc3
More information about the xorg-devel
mailing list