Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=90b02340dcc6ce00bf22c48f4865915f5989e5e4
Commit:     90b02340dcc6ce00bf22c48f4865915f5989e5e4
Parent:     4b550488f894c899aa54dc935c8fee47bca2b7df
Author:     Ralf Baechle <[EMAIL PROTECTED]>
AuthorDate: Thu Oct 11 23:46:09 2007 +0100
Committer:  Ralf Baechle <[EMAIL PROTECTED]>
CommitDate: Thu Oct 11 23:46:09 2007 +0100

    [MIPS] Switch from to_tm to rtc_time_to_tm
    
    This replaces the MIPS-specific to_tm function with the generic
    rtc_time_to_tm function.  The big difference between the two functions is
    that rtc_time_to_tm uses epoch 70 while to_tm uses 1970, so the result of
    rtc_time_to_tm needs to be fixed up.
    
    Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>
---
 arch/mips/Kconfig                      |    1 +
 arch/mips/kernel/time.c                |   49 --------------------------------
 arch/mips/pmc-sierra/yosemite/setup.c  |    8 ++++-
 arch/mips/sgi-ip22/ip22-time.c         |    6 ++--
 arch/mips/sibyte/swarm/rtc_m41t81.c    |    3 +-
 arch/mips/sibyte/swarm/rtc_xicor1241.c |    3 +-
 include/asm-mips/time.h                |    7 ----
 7 files changed, 14 insertions(+), 63 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c024113..0cd0f83 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -3,6 +3,7 @@ config MIPS
        default y
        # Horrible source of confusion.  Die, die, die ...
        select EMBEDDED
+       select RTC_LIB
 
 mainmenu "Linux/MIPS Kernel Configuration"
 
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 9bbbd9b..c48ebd4 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -397,52 +397,3 @@ void __init time_init(void)
 
        init_mips_clocksource();
 }
-
-#define FEBRUARY               2
-#define STARTOFTIME            1970
-#define SECDAY                 86400L
-#define SECYR                  (SECDAY * 365)
-#define leapyear(y)            ((!((y) % 4) && ((y) % 100)) || !((y) % 400))
-#define days_in_year(y)                (leapyear(y) ? 366 : 365)
-#define days_in_month(m)       (month_days[(m) - 1])
-
-static int month_days[12] = {
-       31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-void to_tm(unsigned long tim, struct rtc_time *tm)
-{
-       long hms, day, gday;
-       int i;
-
-       gday = day = tim / SECDAY;
-       hms = tim % SECDAY;
-
-       /* Hours, minutes, seconds are easy */
-       tm->tm_hour = hms / 3600;
-       tm->tm_min = (hms % 3600) / 60;
-       tm->tm_sec = (hms % 3600) % 60;
-
-       /* Number of years in days */
-       for (i = STARTOFTIME; day >= days_in_year(i); i++)
-               day -= days_in_year(i);
-       tm->tm_year = i;
-
-       /* Number of months in days left */
-       if (leapyear(tm->tm_year))
-               days_in_month(FEBRUARY) = 29;
-       for (i = 1; day >= days_in_month(i); i++)
-               day -= days_in_month(i);
-       days_in_month(FEBRUARY) = 28;
-       tm->tm_mon = i - 1;             /* tm_mon starts from 0 to 11 */
-
-       /* Days are what is left over (+1) from all that. */
-       tm->tm_mday = day + 1;
-
-       /*
-        * Determine the day of week
-        */
-       tm->tm_wday = (gday + 4) % 7;   /* 1970/1/1 was Thursday */
-}
-
-EXPORT_SYMBOL(to_tm);
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c 
b/arch/mips/pmc-sierra/yosemite/setup.c
index 56bf695..015fcc3 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -100,8 +100,12 @@ int rtc_mips_set_time(unsigned long tim)
        struct rtc_time tm;
        unsigned long flags;
 
-       /* convert to a more useful format -- note months count from 0 */
-       to_tm(sec, &tm);
+       /*
+        * Convert to a more useful format -- note months count from 0
+        * and years from 1900
+        */
+       rtc_time_to_tm(tim, &tm);
+       tm.tm_year += 1900;
        tm.tm_mon += 1;
 
        spin_lock_irqsave(&rtc_lock, flags);
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index 0387c38..c494180 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -29,7 +29,7 @@
 #include <asm/sgi/ip22.h>
 
 /*
- * note that mktime uses month from 1 to 12 while to_tm
+ * Note that mktime uses month from 1 to 12 while rtc_time_to_tm
  * uses 0 to 11.
  */
 unsigned long read_persistent_clock(void)
@@ -66,10 +66,10 @@ int rtc_mips_set_time(unsigned long tim)
        unsigned int save_control;
        unsigned long flags;
 
-       to_tm(tim, &tm);
+       rtc_time_to_tm(tim, &tm);
 
        tm.tm_mon += 1;         /* tm_mon starts at zero */
-       tm.tm_year -= 1940;
+       tm.tm_year -= 40;
        if (tm.tm_year >= 100)
                tm.tm_year -= 100;
 
diff --git a/arch/mips/sibyte/swarm/rtc_m41t81.c 
b/arch/mips/sibyte/swarm/rtc_m41t81.c
index c13914b..26fbff4 100644
--- a/arch/mips/sibyte/swarm/rtc_m41t81.c
+++ b/arch/mips/sibyte/swarm/rtc_m41t81.c
@@ -146,7 +146,8 @@ int m41t81_set_time(unsigned long t)
        struct rtc_time tm;
        unsigned long flags;
 
-       to_tm(t, &tm);
+       /* Note we don't care about the century */
+       rtc_time_to_tm(t, &tm);
 
        /*
         * Note the write order matters as it ensures the correctness.
diff --git a/arch/mips/sibyte/swarm/rtc_xicor1241.c 
b/arch/mips/sibyte/swarm/rtc_xicor1241.c
index f4a1788..ff3e5da 100644
--- a/arch/mips/sibyte/swarm/rtc_xicor1241.c
+++ b/arch/mips/sibyte/swarm/rtc_xicor1241.c
@@ -115,7 +115,8 @@ int xicor_set_time(unsigned long t)
        int tmp;
        unsigned long flags;
 
-       to_tm(t, &tm);
+       rtc_time_to_tm(t, &tm);
+       tm.tm_year += 1900;
 
        spin_lock_irqsave(&rtc_lock, flags);
        /* unlock writes to the CCR */
diff --git a/include/asm-mips/time.h b/include/asm-mips/time.h
index 74ab331..963507d 100644
--- a/include/asm-mips/time.h
+++ b/include/asm-mips/time.h
@@ -49,13 +49,6 @@ extern void (*mips_timer_ack)(void);
 extern struct clocksource clocksource_mips;
 
 /*
- * to_tm() converts system time back to (year, mon, day, hour, min, sec).
- * It is intended to help implement rtc_set_time() functions.
- * Copied from PPC implementation.
- */
-extern void to_tm(unsigned long tim, struct rtc_time *tm);
-
-/*
  * high-level timer interrupt routines.
  */
 extern irqreturn_t timer_interrupt(int irq, void *dev_id);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to