1/ make sure to reset the wakealarm before
write to write a new value.
2/ We need to block suspend if it is *not* already disabled,
not if it is.
Signed-off-by: NeilBrown <neilb@suse.de>
int fd = open("/sys/class/rtc/rtc0/wakealarm", O_WRONLY);
if (fd >= 0) {
char buf[20];
+ write(fd, "0\n", 2);
sprintf(buf, "%lld\n",
(long long)state->conns->stamp - 2);
write(fd, buf, strlen(buf));
return 1;
}
/* too close to next wakeup */
- if (state->disabled) {
+ if (!state->disabled) {
suspend_block(state->disablefd);
state->disabled = 1;
}