linux/drivers/rtc
Mark Lord 0e36a9a4a7 rtc: fix readback from /sys/class/rtc/rtc?/wakealarm
Fix readback of RTC alarms on platforms which return -1 in
non-hardware-supported RTC alarm fields.

To fill in the missing (-1) values, we grab an RTC timestamp along with the
RTC alarm value, and use the timestamp fields to populate the missing alarm
fields.

To counter field-wrap races (since the timestamp and alarm are not read
together atomically), we read the RTC timestamp both before and after
reading the RTC alarm value, and then check for wrapped fields --> if any
have wrapped, we know we have a possible inconsistency, so we loop and
reread the timestamp and alarm again.

Wrapped fields in the RTC timestamps are an issue because rtc-cmos.c, for
example, also gets/uses an RTC timestamp internally while fetching the RTC
alarm.  If our timestamp here wasn't the same (minutes and higher) as what
was used internally there, then we might end up populating the -1 fields
with inconsistent values.

This fixes readbacks from /sys/class/rtc/rtc?/wakealarm, as well as other
code paths which call rtc_read_alarm().

Signed-off-by: Mark Lord <mlord@pobox.com>
Cc: David Brownell <david-b@pacbell.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-16 09:43:13 -07:00
..
class.c RTC: periodic irq fix 2007-10-16 09:43:13 -07:00
hctosys.c rtc: remove rest of class_device 2007-05-08 11:15:18 -07:00
interface.c rtc: fix readback from /sys/class/rtc/rtc?/wakealarm 2007-10-16 09:43:13 -07:00
Kconfig rtc: RTC class driver for the ds1374 2007-10-16 09:43:13 -07:00
Makefile rtc: RTC class driver for the ds1374 2007-10-16 09:43:13 -07:00
rtc-at32ap700x.c Driver for the Atmel on-chip RTC on AT32AP700x devices 2007-07-17 10:23:09 -07:00
rtc-at91rm9200.c rtc: suspend()/resume() restores system clock 2007-05-08 11:15:18 -07:00
rtc-bfin.c Blackfin On-Chip RTC driver update for supporting BF54x 2007-07-15 02:33:26 +08:00
rtc-cmos.c rtc_irq_set_freq() requires power-of-two and associated kerneldoc 2007-10-16 09:43:13 -07:00
rtc-core.h rtc: update to class device removal patches 2007-05-08 11:15:18 -07:00
rtc-dev.c rtc-dev: no need to convert file->private_data to rtc device 2007-10-16 09:43:13 -07:00
rtc-ds1216.c RTC driver for DS1216 chips 2007-07-17 10:23:09 -07:00
rtc-ds1307.c rtc-ds1307: typo fix found by coverity 2007-07-26 11:35:16 -07:00
rtc-ds1374.c rtc: RTC class driver for the ds1374 2007-10-16 09:43:13 -07:00
rtc-ds1553.c rtc: make rtc-ds1553 driver hotplug-aware 2007-10-16 09:43:13 -07:00
rtc-ds1672.c i2c: Stop using i2c_adapter.class_dev 2007-02-13 22:09:04 +01:00
rtc-ds1742.c rtc: make rtc-ds1742 driver hotplug-aware 2007-10-16 09:43:13 -07:00
rtc-ep93xx.c [PATCH] constify rtc_class_ops: update drivers 2006-10-01 00:39:25 -07:00
rtc-isl1208.c [PATCH] constify rtc_class_ops: update drivers 2006-10-01 00:39:25 -07:00
rtc-lib.c revert "rtc: Add rtc_merge_alarm()" 2007-05-08 11:15:18 -07:00
rtc-m41t80.c correct name for rtc-m41t80 2007-08-22 19:52:45 -07:00
rtc-m48t59.c rtc-m48t59 driver NO_IRQ mode fixup 2007-07-31 15:39:44 -07:00
rtc-m48t86.c [PATCH] constify rtc_class_ops: update drivers 2006-10-01 00:39:25 -07:00
rtc-max6900.c rtc: update and use the MAX6900 century byte 2007-07-21 17:49:17 -07:00
rtc-max6902.c rtc-max6902 minor fixes 2007-08-22 19:52:47 -07:00
rtc-omap.c rtc-omap build fix 2007-05-17 05:23:05 -07:00
rtc-pcf8563.c i2c: Stop using i2c_adapter.class_dev 2007-02-13 22:09:04 +01:00
rtc-pcf8583.c rtc-pcf8583: Check for i2c adapter functionality 2007-10-16 09:43:13 -07:00
rtc-pl031.c rtc: rtc interfaces don't use class_device 2007-05-08 11:15:18 -07:00
rtc-proc.c rtc: remove rest of class_device 2007-05-08 11:15:18 -07:00
rtc-rs5c313.c rtc-rs5c313.c: add error handling to avoid hardware hangup 2007-05-11 08:29:35 -07:00
rtc-rs5c348.c [PATCH] rtc: Make rtc-rs5c348 driver hotplug-aware 2007-08-27 02:16:58 +01:00
rtc-rs5c372.c rtc-rs5c372 becomes a new-style i2c driver 2007-07-17 10:23:08 -07:00
rtc-s3c.c s3c2410: fixup after arch moves 2007-07-31 15:39:36 -07:00
rtc-sa1100.c rtc: rtc interfaces don't use class_device 2007-05-08 11:15:18 -07:00
rtc-sh.c rtc: rtc-sh: Support 4-digit year on SH7705/SH7710/SH7712. 2007-09-21 11:57:47 +09:00
rtc-stk17ta8.c fix missing arguments in drivers/rtc/rtc-stk17ta8.c 2007-07-26 11:11:56 -07:00
rtc-sysfs.c rtc: remove rest of class_device 2007-05-08 11:15:18 -07:00
rtc-test.c rtc: rtc interfaces don't use class_device 2007-05-08 11:15:18 -07:00
rtc-v3020.c RTC v3020 fixes 2007-09-11 17:21:20 -07:00
rtc-vr41xx.c [MIPS] separate platform_device registration for VR41xx RTC 2007-07-12 17:41:15 +01:00
rtc-x1205.c i2c: Delete outdated x1205 driver documentation 2007-07-12 14:12:28 +02:00