All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Xunlei Pang <pang.xunlei@linaro.org>,
	linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	Alessandro Zummo <a.zummo@towertech.it>,
	Sven Schnelle <svens@stackframe.org>,
	John Stultz <john.stultz@linaro.org>,
	Arnd Bergmann <arnd.bergmann@linaro.org>
Subject: Re: [RFC PATCH 1/4] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t
Date: Fri, 28 Nov 2014 00:47:14 +0100	[thread overview]
Message-ID: <4653852.SPZ1tnKaLF@wuerfel> (raw)
In-Reply-To: <alpine.DEB.2.11.1411272350190.3961@nanos>

On Friday 28 November 2014 00:02:47 Thomas Gleixner wrote:
> 
> >  static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
> >  {
> >       struct rtc_time alarm_tm, now_tm;
> > -     unsigned long now, time;
> > +     time64_t now, time;
> >       struct platform_device *pdev = to_platform_device(dev);
> >       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
> >       void __iomem *ioaddr = pdata->ioaddr;
> >  
> >       now = get_alarm_or_time(dev, MXC_RTC_TIME);
> > -     rtc_time_to_tm(now, &now_tm);
> > +     rtc_time64_to_tm(now, &now_tm);
> 
> So here you convert that to struct rtc_time.
> 
> >       alarm_tm.tm_year = now_tm.tm_year;
> >       alarm_tm.tm_mon = now_tm.tm_mon;
> >       alarm_tm.tm_mday = now_tm.tm_mday;
> >       alarm_tm.tm_hour = alrm->tm_hour;
> >       alarm_tm.tm_min = alrm->tm_min;
> >       alarm_tm.tm_sec = alrm->tm_sec;
> > -     rtc_tm_to_time(&alarm_tm, &time);
> > +     time = rtc_tm_to_time64(&alarm_tm);
> 
> Just to convert it back and then do the reverse operation in
> set_alarm_or_time()

Apparently the code originally tried to make the alarm fire within 
the next 24 hours. What you and the author of c92182ee0b5a3
("drivers/rtc/rtc-mxc.c: make alarm work") apparently missed is that
it is taking the year/mon/mday value of today and the hour/min/sec
value from the function argument.

I think the idea was to make it work with user space that sets only
the last three fields (which would work on the typical x86 rtc),
but after that other patch, the function no longer makes any sense,
since it will set the alarm in the past half of the time.

	Arnd

  reply	other threads:[~2014-11-27 23:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 12:02 [RFC PATCH 0/4] Add rtc 64bit epoch offset for rtc hardware that only provides 32bit time Xunlei Pang
2014-11-27 12:02 ` [RFC PATCH 1/4] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t Xunlei Pang
2014-11-27 23:02   ` Thomas Gleixner
2014-11-27 23:47     ` Arnd Bergmann [this message]
2014-11-28 15:58       ` pang.xunlei
2014-11-27 12:02 ` [RFC PATCH 2/4] rtc: Convert rtc_class_ops.set_mmss() " Xunlei Pang
2014-11-27 23:05   ` Thomas Gleixner
2014-11-27 23:23     ` Arnd Bergmann
2014-11-27 23:28       ` Thomas Gleixner
2014-11-28 16:49   ` pang.xunlei
2014-11-27 12:02 ` [RFC PATCH 3/4] rtc/lib: Provide interfaces to map between 32bit hardware and 64bit time Xunlei Pang
2014-11-27 23:16   ` Thomas Gleixner
2014-11-28 16:10     ` pang.xunlei
2014-12-01 21:12       ` Thomas Gleixner
2014-11-27 12:02 ` [RFC PATCH 4/4] rtc/imxdi: Update driver to address time issues Xunlei Pang
2014-11-27 23:24   ` Thomas Gleixner
2014-11-28 16:20     ` pang.xunlei
2014-12-01  0:13       ` Alessandro Zummo

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=4653852.SPZ1tnKaLF@wuerfel \
    --to=arnd@arndb.de \
    --cc=a.zummo@towertech.it \
    --cc=arnd.bergmann@linaro.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pang.xunlei@linaro.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=svens@stackframe.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.