diff options
author | Giacomo | 2012-09-12 19:33:39 +0200 |
---|---|---|
committer | Karel Zak | 2012-09-13 13:23:11 +0200 |
commit | 829eab67e6f279ef76e18df7d5fe36ffe43979e1 (patch) | |
tree | 98c100bcf9dfd6de87108409c75d88728ea6c04f /sys-utils/rtcwake.c | |
parent | agetty: add \4 and \6 issue file sequences to print IP addresses (diff) | |
download | kernel-qcow2-util-linux-829eab67e6f279ef76e18df7d5fe36ffe43979e1.tar.gz kernel-qcow2-util-linux-829eab67e6f279ef76e18df7d5fe36ffe43979e1.tar.xz kernel-qcow2-util-linux-829eab67e6f279ef76e18df7d5fe36ffe43979e1.zip |
rtcwake: doesn't reset wakealarm
Disable an alarm use the same logic used to enable it: first try RTC_WKALM_SET
with the "enabled" flag set to false, if it fails fall back to RTC_AIE_OFF.
Signed-off-by: Giacomo <giacomo.perale@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r-- | sys-utils/rtcwake.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 0e16bd388..a1fd6dc45 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -64,7 +64,6 @@ enum ClockMode { static unsigned verbose; static unsigned dryrun; -static unsigned ioctl_aie_on; /* ioctl(AIE_ON) succeeded */ enum ClockMode clock_mode = CM_AUTO; static struct option long_options[] = { @@ -243,7 +242,6 @@ static int setup_alarm(int fd, time_t *wakeup) warn(_("enable rtc alarm failed")); return -1; } - ioctl_aie_on = 1; } else { warn(_("set rtc wake alarm failed")); return -1; @@ -616,8 +614,25 @@ int main(int argc, char **argv) suspend_system(suspend); } - if (!dryrun && ioctl_aie_on && ioctl(fd, RTC_AIE_OFF, 0) < 0) - warn(_("disable rtc alarm interrupt failed")); + if (!dryrun) { + /* try to disable the alarm with the preferred RTC_WKALM_RD and + * RTC_WKALM_SET calls, if it fails fall back to RTC_AIE_OFF + */ + struct rtc_wkalrm wake; + + if (ioctl(fd, RTC_WKALM_RD, &wake) < 0) { + if (ioctl(fd, RTC_AIE_OFF, 0) < 0) { + warn(_("disable rtc alarm interrupt failed")); + rc = EXIT_FAILURE; + } + } else { + wake.enabled = 0; + if (ioctl(fd, RTC_WKALM_SET, &wake) < 0) { + warn(_("disable rtc alarm interrupt failed")); + rc = EXIT_FAILURE; + } + } + } close(fd); return rc; |