Linux MIPS Architecture development
 help / color / mirror / Atom feed
* a patch for generic MIPS RTC
@ 2005-08-18  8:54 Sergey Podstavin
  2005-09-05  4:54 ` Atsushi Nemoto
  0 siblings, 1 reply; 7+ messages in thread
From: Sergey Podstavin @ 2005-08-18  8:54 UTC (permalink / raw)
  To: linux-mips; +Cc: Ralf Baechle

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Hi!

genrtc doesn't work as a module because functions for module defined in
wrong place. Most architectures define these functions in <asm/rtc.h>,
so make MIPS follow their example.
It makes the generic MIPS RTC working as a module for MIPS.

Best wishes,
Sergey Podstavin

[-- Attachment #2: fix_genrtc_as_a_module.patch --]
[-- Type: text/x-patch, Size: 3853 bytes --]

Source: MontaVista Software, Inc. Sergey Podstavin <spodstavin@ru.mvista.com>
Type: Defect Fix
Disposition: submit to linux-mips@linux-mips.org
Description:
    genrtc doesn't work as a module because functions for module defined in wrong place.	
Most architectures define these functions in <asm/rtc.h>, so make MIPS follow their example.

Signed-off-by: Tom Rini <trini@kernel.crashing.org>
Signed-off-by: Sergey Podstavin <spodstavin@ru.mvista.com>

Index: linux/arch/mips/kernel/genrtc.c
===================================================================
--- linux.orig/arch/mips/kernel/genrtc.c
+++ linux/arch/mips/kernel/genrtc.c
@@ -1,64 +1 @@
-/*
- * A glue layer that provides RTC read/write to drivers/char/genrtc.c driver
- * based on MIPS internal RTC routines.  It does take care locking
- * issues so that we are SMP/Preemption safe.
- *
- * Copyright (C) 2004 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * Please read the COPYING file for all license details.
- */
-
-#include <linux/spinlock.h>
-
-#include <asm/rtc.h>
-#include <asm/time.h>
-
-static DEFINE_SPINLOCK(mips_rtc_lock);
-
-unsigned int get_rtc_time(struct rtc_time *time)
-{
-	unsigned long nowtime;
-
-	spin_lock(&mips_rtc_lock);
-	nowtime = rtc_get_time();
-	to_tm(nowtime, time);
-	time->tm_year -= 1900;
-	spin_unlock(&mips_rtc_lock);
-
-	return RTC_24H;
-}
-
-int set_rtc_time(struct rtc_time *time)
-{
-	unsigned long nowtime;
-	int ret;
-
-	spin_lock(&mips_rtc_lock);
-	nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
-			time->tm_mday, time->tm_hour, time->tm_min,
-			time->tm_sec);
-	ret = rtc_set_time(nowtime);
-	spin_unlock(&mips_rtc_lock);
-
-	return ret;
-}
-
-unsigned int get_rtc_ss(void)
-{
-	struct rtc_time h;
-
-	get_rtc_time(&h);
-	return h.tm_sec;
-}
-
-int get_rtc_pll(struct rtc_pll_info *pll)
-{
-	return -EINVAL;
-}
-
-int set_rtc_pll(struct rtc_pll_info *pll)
-{
-	return -EINVAL;
-}
 
Index: linux/arch/mips/kernel/Makefile
===================================================================
--- linux.orig/arch/mips/kernel/Makefile
+++ linux/arch/mips/kernel/Makefile
@@ -57,8 +57,6 @@
 
 obj-$(CONFIG_64BIT)		+= cpu-bugs64.o
 
-obj-$(CONFIG_GEN_RTC)		+= genrtc.o
-
 CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
 CFLAGS_ioctl32.o	+= -Ifs/
 
Index: linux/include/asm-mips/rtc.h
===================================================================
--- linux.orig/include/asm-mips/rtc.h
+++ linux/include/asm-mips/rtc.h
@@ -14,7 +14,9 @@
 
 #ifdef __KERNEL__
 
+#include <linux/spinlock.h>
 #include <linux/rtc.h>
+#include <asm/time.h>
 
 #define RTC_PIE 0x40            /* periodic interrupt enable */
 #define RTC_AIE 0x20            /* alarm interrupt enable */
@@ -33,5 +35,52 @@
 int get_rtc_pll(struct rtc_pll_info *pll);
 int set_rtc_pll(struct rtc_pll_info *pll);
 
+static DEFINE_SPINLOCK(mips_rtc_lock);
+
+static inline unsigned int get_rtc_time(struct rtc_time *time)
+{
+	unsigned long nowtime;
+
+	spin_lock(&mips_rtc_lock);
+	nowtime = rtc_get_time();
+	to_tm(nowtime, time);
+	time->tm_year -= 1900;
+	spin_unlock(&mips_rtc_lock);
+
+	return RTC_24H;
+}
+
+static inline int set_rtc_time(struct rtc_time *time)
+{
+	unsigned long nowtime;
+	int ret;
+
+	spin_lock(&mips_rtc_lock);
+	nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
+			time->tm_mday, time->tm_hour, time->tm_min,
+			time->tm_sec);
+	ret = rtc_set_time(nowtime);
+	spin_unlock(&mips_rtc_lock);
+
+	return ret;
+}
+
+static inline unsigned int get_rtc_ss(void)
+{
+	struct rtc_time h;
+
+	get_rtc_time(&h);
+	return h.tm_sec;
+}
+
+static inline int get_rtc_pll(struct rtc_pll_info *pll)
+{
+	return -EINVAL;
+}
+
+static inline int set_rtc_pll(struct rtc_pll_info *pll)
+{
+	return -EINVAL;
+}
 #endif
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-09-19 16:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18  8:54 a patch for generic MIPS RTC Sergey Podstavin
2005-09-05  4:54 ` Atsushi Nemoto
2005-09-05 11:08   ` Maciej W. Rozycki
2005-09-05 13:45     ` Atsushi Nemoto
2005-09-05 15:25       ` Maciej W. Rozycki
2005-09-06 15:55         ` Atsushi Nemoto
2005-09-19 16:48           ` Atsushi Nemoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox