|
From: <sle...@us...> - 2007-03-10 00:20:35
|
Revision: 903
http://svn.sourceforge.net/hackndev/?rev=903&view=rev
Author: sleep_walker
Date: 2007-03-09 16:20:31 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
l4p: RTC Palm problem fix candidate
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/Kconfig
linux4palm/linux/trunk/drivers/rtc/Kconfig
linux4palm/linux/trunk/drivers/rtc/rtc-lib.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/Kconfig
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/Kconfig 2007-03-10 00:13:47 UTC (rev 902)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/Kconfig 2007-03-10 00:20:31 UTC (rev 903)
@@ -184,13 +184,6 @@
to work around certain bootloaders overwriting them
during resume.
-config PXA_RTC_EPOCH
- int "PXA RTC epoch year"
- default "1970"
- help
- The default Linux epoch Jan 1st 1970, however to
- operate alongside PalmOS nicely, change this to 1904.
-
config PXA_SUSPEND_SAVE_EXTRA_REGS
bool
help
Modified: linux4palm/linux/trunk/drivers/rtc/Kconfig
===================================================================
--- linux4palm/linux/trunk/drivers/rtc/Kconfig 2007-03-10 00:13:47 UTC (rev 902)
+++ linux4palm/linux/trunk/drivers/rtc/Kconfig 2007-03-10 00:20:31 UTC (rev 903)
@@ -37,6 +37,13 @@
The RTC device that will be used as the source for
the system time, usually rtc0.
+config RTC_EPOCH
+ int "RTC epoch year"
+ default "1970"
+ help
+ The default Linux epoch Jan 1st 1970, however to
+ operate alongside PalmOS nicely, change this to 1904.
+
config RTC_DEBUG
bool "RTC debug support"
depends on RTC_CLASS = y
Modified: linux4palm/linux/trunk/drivers/rtc/rtc-lib.c
===================================================================
--- linux4palm/linux/trunk/drivers/rtc/rtc-lib.c 2007-03-10 00:13:47 UTC (rev 902)
+++ linux4palm/linux/trunk/drivers/rtc/rtc-lib.c 2007-03-10 00:20:31 UTC (rev 903)
@@ -28,6 +28,12 @@
#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
#define LEAP_YEAR(year) ((!(year % 4) && (year % 100)) || !(year % 400))
+#ifdef CONFIG_RTC_EPOCH
+#define EPOCH_YEAR CONFIG_RTC_EPOCH
+#else
+#define EPOCH_YEAR 1970
+#endif
+
/*
* The number of days in the month.
*/
@@ -46,8 +52,14 @@
}
EXPORT_SYMBOL(rtc_year_days);
+#define EPOCH_YEAR_DAYS_DIFFERENCE ((1970 - EPOCH_YEAR) * 365 - LEAPS_THRU_END_OF(EPOCH_YEAR - 1))
+
+
/*
* Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
+
+ * Added support for other years than 1970
+ * needed for example for Palm PDAs
*/
void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
{
@@ -57,12 +69,14 @@
time -= days * 86400;
/* day of the week, 1970-01-01 was a Thursday */
- tm->tm_wday = (days + 4) % 7;
+ /* and between 1970-01-01 and EPOCH_YEAR was EPOCH_YEAR_DAYS_DIFFERENCE days */
+ tm->tm_wday = (days + EPOCH_YEAR_DAYS_DIFFERENCE + 4) % 7;
- year = 1970 + days / 365;
- days -= (year - 1970) * 365
- + LEAPS_THRU_END_OF(year - 1)
- - LEAPS_THRU_END_OF(1970 - 1);
+ year = EPOCH_YEAR + days / 365;
+ days -= (year - EPOCH_YEAR) * 365
+ + LEAPS_THRU_END_OF(year - 1)
+ - LEAPS_THRU_END_OF(EPOCH_YEAR - 1);
+
if (days < 0) {
year -= 1;
days += 365 + LEAP_YEAR(year);
@@ -93,8 +107,7 @@
*/
int rtc_valid_tm(struct rtc_time *tm)
{
- if (tm->tm_year < 70
- || ((unsigned)tm->tm_mon) >= 12
+ if (((unsigned)tm->tm_mon) >= 12
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900)
|| ((unsigned)tm->tm_hour) >= 24
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|