From: Paul Fox <pgf@laptop.org>
To: util-linux@vger.kernel.org
Cc: Karel Zak <kzak@redhat.com>
Subject: [PATCH] rtcwake: only invoke RTC_AIE_ON/OFF ioctls in pairs
Date: Fri, 30 Mar 2012 08:48:43 -0400 [thread overview]
Message-ID: <11482.1333111723@foxharp.boston.ma.us> (raw)
on a system using the rtc-mmp.c driver (and presumably others),
rtcwake always gives a warning message when it completes:
disable rtc alarm interupt: Invalid argument
the EINVAL is because the rtc-mmp driver doesn't implement the
rtc->ops->alarm_irq_enable() member function, so ioctl(RTC_AIE_OFF)
will always fail. note that since ioctl(RTC_WKALM_SET) is preferred
over RTC_ALM_SET/RTC_AIE_ON, no corresponding call to RTC_AIE_ON was
ever made in the first place.
the patch below is probably the correct way to avoid this warning, and
to eliminate the mismatched AIE_ON/AIE_OFF pair.
a less disruptive patch would simply ignore an EINVAL error return
from that ioctl.
paul
>From 915d629a3a396ac9581c25ca7e8960782d8e7ff9 Mon Sep 17 00:00:00 2001
From: Paul Fox <pgf@laptop.org>
Date: Fri, 30 Mar 2012 08:16:50 -0400
Subject: [PATCH] rtcwake: only invoke RTC_AIE_ON/OFF ioctls in pairs
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 | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 4aa5057..4ac0964 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -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);
--
1.7.5.4
=---------------------
paul fox, pgf@laptop.org
next reply other threads:[~2012-03-30 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 12:48 Paul Fox [this message]
2012-04-02 11:22 ` [PATCH] rtcwake: only invoke RTC_AIE_ON/OFF ioctls in pairs Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11482.1333111723@foxharp.boston.ma.us \
--to=pgf@laptop.org \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox