From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] ARM: convert asm/irqflags.h to use asm-generic/irqflags.h
Date: Sun, 15 Jul 2012 22:53:56 -0500 [thread overview]
Message-ID: <1342410836-6010-4-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1342410836-6010-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
By implmenting arch_local_irq_restore with constant flags, we can use
asm-generic/irqflags.h and remove some of the ARM version of irqflags.h.
Verified the code is equivalent by checking the disassembled code.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
arch/arm/include/asm/irqflags.h | 131 ++++++++++++++-------------------------
1 file changed, 45 insertions(+), 86 deletions(-)
diff --git a/arch/arm/include/asm/irqflags.h b/arch/arm/include/asm/irqflags.h
index 1e6cca5..67bfb53 100644
--- a/arch/arm/include/asm/irqflags.h
+++ b/arch/arm/include/asm/irqflags.h
@@ -8,88 +8,68 @@
/*
* CPU interrupt mask handling.
*/
-#if __LINUX_ARM_ARCH__ >= 6
+#define ARCH_IRQ_DISABLED PSR_I_BIT
+#define ARCH_IRQ_ENABLED 0
-static inline unsigned long arch_local_irq_save(void)
+static inline unsigned long arch_local_save_flags(void)
{
unsigned long flags;
asm volatile(
- " mrs %0, cpsr @ arch_local_irq_save\n"
- " cpsid i"
+ " mrs %0, cpsr @ arch_local_save_flags\n"
: "=r" (flags) : : "memory", "cc");
return flags;
}
-static inline void arch_local_irq_enable(void)
+static inline void constant_arch_local_irq_restore(unsigned long flags)
{
- asm volatile(
- " cpsie i @ arch_local_irq_enable"
- :
- :
- : "memory", "cc");
+#if __LINUX_ARM_ARCH__ >= 6
+ if (flags == ARCH_IRQ_ENABLED)
+ asm volatile(
+ " cpsie i @ constant_arch_local_irq_restore"
+ : : : "memory", "cc");
+ else if (flags == ARCH_IRQ_DISABLED)
+ asm volatile(
+ " cpsid i @ constant_arch_local_irq_restore"
+ : : : "memory", "cc");
+#else
+ unsigned long temp;
+ if (flags == ARCH_IRQ_ENABLED)
+ asm volatile(
+ " mrs %0, cpsr @ constant_arch_local_irq_restore\n"
+ " bic %0, %0, #128\n"
+ " msr cpsr_c, %0"
+ : "=r" (temp)
+ :
+ : "memory", "cc");
+ else if (flags == ARCH_IRQ_DISABLED)
+ asm volatile(
+ " mrs %0, cpsr @ constant_arch_local_irq_restore\n"
+ " orr %0, %0, #128\n"
+ " msr cpsr_c, %0"
+ : "=r" (temp)
+ :
+ : "memory", "cc");
+#endif
}
-static inline void arch_local_irq_disable(void)
+static inline void _arch_local_irq_restore(unsigned long flags)
{
- asm volatile(
- " cpsid i @ arch_local_irq_disable"
- :
+ asm volatile(
+ " msr cpsr_c, %0 @ _arch_local_irq_restore"
:
+ : "r" (flags)
: "memory", "cc");
}
+#define arch_local_irq_restore(flags) \
+ (__builtin_constant_p(flags) ? constant_arch_local_irq_restore(flags) : \
+ _arch_local_irq_restore(flags))
+
+#if __LINUX_ARM_ARCH__ >= 6
#define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc")
#define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc")
#else
-
-/*
- * Save the current interrupt enable state & disable IRQs
- */
-static inline unsigned long arch_local_irq_save(void)
-{
- unsigned long flags, temp;
-
- asm volatile(
- " mrs %0, cpsr @ arch_local_irq_save\n"
- " orr %1, %0, #128\n"
- " msr cpsr_c, %1"
- : "=r" (flags), "=r" (temp)
- :
- : "memory", "cc");
- return flags;
-}
-
-/*
- * Enable IRQs
- */
-static inline void arch_local_irq_enable(void)
-{
- unsigned long temp;
- asm volatile(
- " mrs %0, cpsr @ arch_local_irq_enable\n"
- " bic %0, %0, #128\n"
- " msr cpsr_c, %0"
- : "=r" (temp)
- :
- : "memory", "cc");
-}
-
-/*
- * Disable IRQs
- */
-static inline void arch_local_irq_disable(void)
-{
- unsigned long temp;
- asm volatile(
- " mrs %0, cpsr @ arch_local_irq_disable\n"
- " orr %0, %0, #128\n"
- " msr cpsr_c, %0"
- : "=r" (temp)
- :
- : "memory", "cc");
-}
-
/*
* Enable FIQs
*/
@@ -122,34 +102,13 @@ static inline void arch_local_irq_disable(void)
#endif
-/*
- * Save the current interrupt enable state.
- */
-static inline unsigned long arch_local_save_flags(void)
-{
- unsigned long flags;
- asm volatile(
- " mrs %0, cpsr @ local_save_flags"
- : "=r" (flags) : : "memory", "cc");
- return flags;
-}
-
-/*
- * restore saved IRQ & FIQ state
- */
-static inline void arch_local_irq_restore(unsigned long flags)
-{
- asm volatile(
- " msr cpsr_c, %0 @ local_irq_restore"
- :
- : "r" (flags)
- : "memory", "cc");
-}
-
static inline int arch_irqs_disabled_flags(unsigned long flags)
{
return flags & PSR_I_BIT;
}
+#define arch_irqs_disabled_flags arch_irqs_disabled_flags
+
+#include <asm-generic/irqflags.h>
#endif
#endif
--
1.7.9.5
next prev parent reply other threads:[~2012-07-16 3:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 3:53 [PATCH 0/3] Use more asm-generic headers Rob Herring
2012-07-16 3:53 ` [PATCH 1/3] ARM: use generic version of identical asm headers Rob Herring
2012-07-16 10:51 ` Arnd Bergmann
2012-07-16 15:37 ` Nicolas Pitre
2012-07-16 3:53 ` [PATCH 2/3] ARM: use asm-generic version of kmap_types.h Rob Herring
2012-07-16 9:18 ` Arnd Bergmann
2012-07-16 16:15 ` Rob Herring
2012-07-16 3:53 ` Rob Herring [this message]
2012-07-16 6:35 ` [PATCH 3/3] ARM: convert asm/irqflags.h to use asm-generic/irqflags.h Hui Wang
2012-07-16 16:10 ` Rob Herring
2012-07-17 1:42 ` Hui Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342410836-6010-4-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).