[PATCH 17/22] Fix m32r irqflags

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Howells
Date: Thursday, August 26, 2010 - 7:00 pm

---

 arch/m32r/include/asm/irqflags.h |  105 ++++++++++++++++++++++++++++++++++++++
 arch/m32r/include/asm/system.h   |   66 ------------------------
 2 files changed, 106 insertions(+), 65 deletions(-)
 create mode 100644 arch/m32r/include/asm/irqflags.h

diff --git a/arch/m32r/include/asm/irqflags.h b/arch/m32r/include/asm/irqflags.h
new file mode 100644
index 0000000..e465339
--- /dev/null
+++ b/arch/m32r/include/asm/irqflags.h
@@ -0,0 +1,105 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001  Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
+ * Copyright (C) 2004, 2006  Hirokazu Takata <takata at linux-m32r.org>
+ */
+
+#ifndef _ASM_M32R_IRQFLAGS_H
+#define _ASM_M32R_IRQFLAGS_H
+
+#include <linux/types.h>
+
+static inline unsigned long arch_local_save_flags(void)
+{
+	unsigned long flags;
+	asm volatile("mvfc %0,psw" : "=r"(flags));
+	return flags;
+}
+
+static inline void arch_local_irq_disable(void)
+{
+#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
+	asm volatile (
+		"clrpsw #0x40 -> nop"
+		: : :"memory");
+#else
+	unsigned long tmpreg0, tmpreg1;
+	asm volatile (
+		"ld24	%0, #0	; Use 32-bit insn.			\n\t"
+		"mvfc	%1, psw	; No interrupt can be accepted here.	\n\t"
+		"mvtc	%0, psw						\n\t"
+		"and3	%0, %1, #0xffbf					\n\t"
+		"mvtc	%0, psw						\n\t"
+		: "=&r" (tmpreg0), "=&r" (tmpreg1)
+		:
+		: "cbit", "memory");
+#endif
+}
+
+static inline void arch_local_irq_enable(void)
+{
+#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
+	asm volatile (
+		"setpsw #0x40 -> nop"
+		: : :"memory");
+#else
+	unsigned long tmpreg;
+	asm volatile (
+		"mvfc	%0, psw;		\n\t"
+		"or3	%0, %0, #0x0040;	\n\t"
+		"mvtc	%0, psw;		\n\t"
+		: "=&r" (tmpreg)
+		:
+		: "cbit", "memory");
+#endif
+}
+
+static inline unsigned long arch_local_irq_save(void)
+{
+	unsigned long flags;
+
+#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
+	asm volatile (
+  		"mvfc	%0, psw;	\n\t"
+	  	"clrpsw	#0x40 -> nop;	\n\t"
+  		: "=r" (flags)
+		:
+		: "memory");
+#else
+	unsigned long tmpreg;
+	asm volatile (
+		"ld24	%1, #0		\n\t"
+		"mvfc	%0, psw		\n\t"
+		"mvtc	%1, psw		\n\t"
+		"and3	%1, %0, #0xffbf	\n\t"
+		"mvtc	%1, psw		\n\t"
+		: "=r" (flags), "=&r" (tmpreg)
+		:
+		: "cbit", "memory");
+#endif
+	return flags;
+}
+
+static inline void arch_local_irq_restore(unsigned long flags)
+{
+	asm volatile("mvtc %0,psw"
+		     :
+		     : "r" (flags)
+		     : "cbit", "memory");
+}
+
+static inline bool arch_irqs_disabled_flags(unsigned long flags)
+{
+	return !(flags & 0x40);
+}
+
+static inline bool arch_irqs_disabled(void)
+{
+	return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
+#endif /* _ASM_M32R_IRQFLAGS_H */
+
diff --git a/arch/m32r/include/asm/system.h b/arch/m32r/include/asm/system.h
index c980f5b..13c4679 100644
--- a/arch/m32r/include/asm/system.h
+++ b/arch/m32r/include/asm/system.h
@@ -11,6 +11,7 @@
  */
 
 #include <linux/compiler.h>
+#include <linux/irqflags.h>
 #include <asm/assembler.h>
 
 #ifdef __KERNEL__
@@ -54,71 +55,6 @@
 	); \
 } while(0)
 
-/* Interrupt Control */
-#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
-#define local_irq_enable() \
-	__asm__ __volatile__ ("setpsw #0x40 -> nop": : :"memory")
-#define local_irq_disable() \
-	__asm__ __volatile__ ("clrpsw #0x40 -> nop": : :"memory")
-#else	/* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
-static inline void local_irq_enable(void)
-{
-	unsigned long tmpreg;
-	__asm__ __volatile__(
-		"mvfc	%0, psw;		\n\t"
-		"or3	%0, %0, #0x0040;	\n\t"
-		"mvtc	%0, psw;		\n\t"
-	: "=&r" (tmpreg) : : "cbit", "memory");
-}
-
-static inline void local_irq_disable(void)
-{
-	unsigned long tmpreg0, tmpreg1;
-	__asm__ __volatile__(
-		"ld24	%0, #0	; Use 32-bit insn. \n\t"
-		"mvfc	%1, psw	; No interrupt can be accepted here. \n\t"
-		"mvtc	%0, psw	\n\t"
-		"and3	%0, %1, #0xffbf	\n\t"
-		"mvtc	%0, psw	\n\t"
-	: "=&r" (tmpreg0), "=&r" (tmpreg1) : : "cbit", "memory");
-}
-#endif	/* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
-
-#define local_save_flags(x) \
-	__asm__ __volatile__("mvfc %0,psw" : "=r"(x) : /* no input */)
-
-#define local_irq_restore(x) \
-	__asm__ __volatile__("mvtc %0,psw" : /* no outputs */ \
-		: "r" (x) : "cbit", "memory")
-
-#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
-#define local_irq_save(x)				\
-	__asm__ __volatile__(				\
-  		"mvfc	%0, psw;		\n\t"	\
-	  	"clrpsw	#0x40 -> nop;		\n\t"	\
-  		: "=r" (x) : /* no input */ : "memory")
-#else	/* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
-#define local_irq_save(x) 				\
-	({						\
-		unsigned long tmpreg;			\
-		__asm__ __volatile__( 			\
-			"ld24	%1, #0 \n\t" 		\
-			"mvfc	%0, psw \n\t"		\
-			"mvtc	%1, psw \n\t"		\
-			"and3	%1, %0, #0xffbf \n\t"	\
-			"mvtc	%1, psw \n\t" 		\
-			: "=r" (x), "=&r" (tmpreg)	\
-			: : "cbit", "memory");		\
-	})
-#endif	/* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
-
-#define irqs_disabled()					\
-	({						\
-		unsigned long flags;			\
-		local_save_flags(flags);		\
-		!(flags & 0x40);			\
-	})
-
 #define nop()	__asm__ __volatile__ ("nop" : : )
 
 #define xchg(ptr, x)							\

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/22] Name the irq flag handling functions sanely, David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 06/22] Blackfin: Add missing dep to asm/irqflags.h, David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 09/22] h8300: Fix die(), David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 12/22] Fix IRQ flag handling naming, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 13/22] MIPS: Fix IRQ flags handling, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 14/22] Fix Alpha irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 15/22] Fix H8300 arch, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 16/22] Fix IA64 irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 17/22] Fix m32r irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 18/22] Fix M68K irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 19/22] Fix PA-RISC irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 20/22] Fix powerpc irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 21/22] Fix SH irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 22/22] Fix Sparc irqflags, David Howells, (Thu Aug 26, 7:00 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Mon Aug 30, 12:12 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Mon Aug 30, 1:50 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Geert Uytterhoeven, (Tue Aug 31, 12:36 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Tue Aug 31, 9:00 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Tue Aug 31, 11:33 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Tue Aug 31, 11:38 pm)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 3:43 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 3:46 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:21 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:22 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 4:30 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 4:31 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:36 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 5:03 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 6:46 pm)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Thu Sep 2, 3:20 am)
[PATCH 3/3] Fix M68K irqflags, David Howells, (Thu Sep 2, 3:22 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Thu Sep 2, 12:53 pm)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Thu Sep 2, 6:28 pm)
Re: [PATCH 19/22] Fix PA-RISC irqflags, Kyle McMartin, (Thu Sep 2, 6:40 pm)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Thu Sep 2, 11:44 pm)
Re: [PATCH 19/22] Fix PA-RISC irqflags, David Howells, (Thu Sep 2, 11:48 pm)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Thu Sep 2, 11:53 pm)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 12:28 am)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 1:05 am)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Fri Sep 3, 2:28 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Fri Sep 3, 2:33 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Fri Sep 3, 3:02 am)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 3:05 am)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Fri Sep 3, 3:38 am)
Re: [PATCH 19/22] Fix PA-RISC irqflags, Kyle McMartin, (Fri Sep 3, 6:31 am)