From: Giacomo <giacomo.perale@gmail.com>
To: util-linux@vger.kernel.org
Subject: Re: rtcwake doesn't reset wakealarm
Date: Wed, 12 Sep 2012 14:33:23 +0000 (UTC) [thread overview]
Message-ID: <loom.20120912T125253-285@post.gmane.org> (raw)
In-Reply-To: 20120912103130.GC17256@x2.net.home
Karel Zak <kzak@...> writes:
>
> On Wed, Sep 12, 2012 at 12:09:16PM +0200, Karel Zak wrote:
> >
> > Let's add Paul to CC
> >
> > On Wed, Sep 12, 2012 at 09:52:14AM +0000, Giacomo wrote:
> > > Giacomo <giacomo.perale@...> writes:
> > >
> > > > After a quick investigation I discovered that this is caused by commit
> > > > 1707576155daf644c5df3c1776b52fd297ff9318 ("rtcwake: only invoke
> > > > RTC_AIE_ON/OFF
> > > > ioctls in pairs"): my system uses RTC_WKALM_SET so ioctl_aie_on stays
false and
> > > > RTC_AIE_OFF doesn't get called.
> > > >
> > >
> > > Hi,
> > >
> > > that commit also broke "disable". This is what happens on my system:
>
> Please, test the patch below. I hope it fixes the problem.
>
> Karel
>
Hi,
it should work but I'm afraid it won't fix Paul's original problem,
because even if RTC_AIE_ON fails RTC_AIE_OFF will still be called and generate
an error.
According to "man rtc", "when using [RTC_WKALM_RD,RTC_WKALM_SET], RTC_AIE_ON and
RTC_AIE_OFF are not used", so the right thing to do should be using RTC_AIE_OFF
to clear the alarm only when RTC_ALM_SET+RTC_AIE_ON was used to set it up (that
is, when ioctl_aie_on=1), and RTC_WKALM_SET with the "enabled" flag set to false
otherwise.
The attached patch works for me (I hope it doesn't get mangled in the posting,
you can find it on pastebin too: http://pastebin.com/wugHPx3w).
Giacomo
--- sys-utils/rtcwake.c 2012-07-23 23:21:56.466320628 +0200
+++ sys-utils/rtcwake.c 2012-09-12 16:13:40.927245246 +0200
@@ -388,6 +388,8 @@
unsigned seconds = 0;
char *suspend = DEFAULT_MODE;
+ struct rtc_wkalrm wake;
+
int rc = EXIT_SUCCESS;
int t;
int fd;
@@ -616,8 +618,23 @@
suspend_system(suspend);
}
- if (!dryrun && ioctl_aie_on && ioctl(fd, RTC_AIE_OFF, 0) < 0)
- warn(_("disable rtc alarm interrupt failed"));
+ if (!dryrun) {
+ /* clear the alarm with RTC_AIE_OFF if RTC_ALM_SET+RTC_AIE_ON
+ * was used to enable it otherwise use the preferred RTC_WKALM_SET
+ */
+ if (ioctl_aie_on && ioctl(fd, RTC_AIE_OFF, 0) < 0) {
+ warn(_("disable rtc alarm interrupt failed"));
+ } else {
+ if (ioctl(fd, RTC_WKALM_RD, &wake) < 0)
+ warn(_("disable rtc alarm interrupt failed"));
+ else {
+ wake.enabled = 0;
+
+ if (ioctl(fd, RTC_WKALM_SET, &wake) < 0)
+ warn(_("disable rtc alarm interrupt failed"));
+ }
+ }
+ }
close(fd);
return rc;
next prev parent reply other threads:[~2012-09-12 14:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 11:11 rtcwake doesn't reset wakealarm Giacomo
2012-09-12 9:52 ` Giacomo
2012-09-12 10:09 ` Karel Zak
2012-09-12 10:31 ` Karel Zak
2012-09-12 14:33 ` Giacomo [this message]
2012-09-12 17:33 ` Giacomo
2012-09-13 11:25 ` Karel Zak
2012-09-13 16:31 ` Paul Fox
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=loom.20120912T125253-285@post.gmane.org \
--to=giacomo.perale@gmail.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