]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rtcwake: only invoke RTC_AIE_ON/OFF ioctls in pairs
authorPaul Fox <pgf@laptop.org>
Fri, 30 Mar 2012 12:16:50 +0000 (08:16 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 2 Apr 2012 11:14:00 +0000 (13:14 +0200)
many rtc drivers don't implement the RTC_AIE_ON/OFF ioctls at all --
so if we never tried to enable the alarm interrupt, don't try to
disable it later.

Signed-off-by: Paul Fox <pgf@laptop.org>
sys-utils/rtcwake.c

index 4aa5057fe63f1ec6845feae151cf5f1042000837..57e4e8b344626d17367a50175edb5752117d3092 100644 (file)
@@ -63,6 +63,7 @@ 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[] = {
@@ -241,6 +242,7 @@ 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;
@@ -613,7 +615,8 @@ int main(int argc, char **argv)
                suspend_system(suspend);
        }
 
-       if (!dryrun && ioctl(fd, RTC_AIE_OFF, 0) < 0)
+       if (!dryrun && ioctl_aie_on && ioctl(fd, RTC_AIE_OFF, 0) < 0)
+
                warn(_("disable rtc alarm interrupt failed"));
 
        close(fd);