1. 27 8月, 2011 1 次提交
    • M
      rtc: Initialized rtc_time->tm_isdst · a7402deb
      Mike Waychison 提交于
      Even though the Linux kernel does not use the tm_isdst field, it is
      exposed as part of the ABI.  This field can accidentally be left
      initialized, which is why we currently memset buffers returned to
      userland in rtc_read_time.
      
      There is a case however where the field can return garbage from the
      stack though when using the RTC_ALM_READ ioctl on the rtc device.  This
      ioctl invokes rtc_read_alarm, which is careful to memset the rtc_wkalrm
      buffer that is copied to userland, but it then uses a struct copy to
      assign to alarm->time given the return value from rtc_ktime_to_tm().
      
      rtc_ktime_to_tm() is implemented by calling rtc_time_to_tm using a
      derivative seconds counds from ktime, but rtc_time_to_tm does not assign
      a value to ->tm_isdst.  This results in garbage from rtc_ktime_to_tm()'s
      frame ending up being copied out to userland as part of the returned
      rtc_wkalrm.
      
      Fix this by initializing rtc_time->tm_isdst to 0 in rtc_time_to_tm.
      Signed-off-by: NMike Waychison <mikew@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      a7402deb
  2. 11 12月, 2010 1 次提交
    • J
      RTC: Rework RTC code to use timerqueue for events · 6610e089
      John Stultz 提交于
      This patch reworks a large portion of the generic RTC code
      to in-effect virtualize the rtc interrupt code.
      
      The current RTC interface is very much a raw hardware interface.
      Via the proc, /dev/, or sysfs interfaces, applciations can set
      the hardware to trigger interrupts in one of three modes:
      
      AIE: Alarm interrupt
      UIE: Update interrupt (ie: once per second)
      PIE: Periodic interrupt (sub-second irqs)
      
      The problem with this interface is that it limits the RTC hardware
      so it can only be used by one application at a time.
      
      The purpose of this patch is to extend the RTC code so that we can
      multiplex multiple applications event needs onto a single RTC device.
      This is done by utilizing the timerqueue infrastructure to manage
      a list of events, which cause the RTC hardware to be programmed
      to fire an interrupt for the next event in the list.
      
      In order to preserve the functionality of the exsting proc,/dev/ and
      sysfs interfaces, we emulate the different interrupt modes as follows:
      
      AIE: We create a rtc_timer dedicated to AIE mode interrupts. There is
      only one per device, so we don't change existing interface semantics.
      
      UIE: Again, a dedicated rtc_timer, set for periodic mode, is used
      to emulate UIE interrupts. Again, only one per device.
      
      PIE: Since PIE mode interrupts fire faster then the RTC's clock read
      granularity, we emulate PIE mode interrupts using a hrtimer. Again,
      one per device.
      
      With this patch, the rtctest.c application in Documentation/rtc.txt
      passes fine on x86 hardware. However, there may very well still be
      bugs, so greatly I'd appreciate any feedback or testing!
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      LKML Reference: <1290136329-18291-4-git-send-email-john.stultz@linaro.org>
      Acked-by: NAlessandro Zummo <a.zummo@towertech.it>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Richard Cochran <richardcochran@gmail.com>
      6610e089
  3. 01 4月, 2009 1 次提交
  4. 03 9月, 2008 1 次提交
    • J
      rtc_time_to_tm: fix signed/unsigned arithmetic · 73442daf
      Jan Altenberg 提交于
      commit 945185a6 ("rtc: rtc_time_to_tm: use
      unsigned arithmetic") changed the some types in rtc_time_to_tm() to
      unsigned:
      
       void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
       {
      -       register int days, month, year;
      +       unsigned int days, month, year;
      
      This doesn't work for all cases, because days is checked for < 0 later
      on:
      
      if (days < 0) {
      	year -= 1;
      	days += 365 + LEAP_YEAR(year);
      }
      
      I think the correct fix would be to keep days signed and do an appropriate
      cast later on.
      Signed-off-by: NJan Altenberg <jan.altenberg@linutronix.de>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      73442daf
  5. 13 5月, 2008 1 次提交
    • M
      rtc: rtc_time_to_tm: use unsigned arithmetic · 945185a6
      Maciej W. Rozycki 提交于
      The input argument to rtc_time_to_tm() is unsigned as well as are members of
      the output structure.  However signed arithmetic is used within for
      calculations leading to incorrect results for input values outside the signed
      positive range.  If this happens the time of day returned is out of range.
      
      Found the problem when fiddling with the RTC and the driver where year was set
      to an unexpectedly large value like 2070, e.g.:
      
      rtc0: setting system clock to 2070-01-01 1193046:71582832:26 UTC (3155760954)
      
      while it should be:
      
      rtc0: setting system clock to 2070-01-01 00:15:54 UTC (3155760954)
      
      Changing types to unsigned fixes the problem.
      
      [akpm@linux-foundation.org: remove old-fashioned `register' keyword]
      Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      945185a6
  6. 09 5月, 2007 1 次提交
  7. 11 12月, 2006 1 次提交
  8. 01 10月, 2006 1 次提交
  9. 26 6月, 2006 1 次提交
  10. 28 3月, 2006 1 次提交