From: robherring2@gmail•com (Rob Herring)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 5/5] ARM: convert asm/irqflags.h to use asm-generic/irqflags.h
Date: Sat, 4 Aug 2012 20:24:00 -0500 [thread overview]
Message-ID: <1344129840-16447-6-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1344129840-16447-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-08-05 1:24 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-05 1:23 [PATCH v2 0/5] Use more asm-generic headers Rob Herring
2012-08-05 1:23 ` [PATCH v2 1/5] ARM: use generic version of identical asm headers Rob Herring
2012-08-05 1:23 ` [PATCH v2 2/5] ARM: add strstr declaration for decompressors Rob Herring
2012-08-05 1:23 ` [PATCH v2 3/5] ARM: use generic unaligned.h Rob Herring
2012-10-08 16:43 ` Shawn Guo
2012-10-08 20:34 ` Rob Herring
2012-10-08 23:28 ` Shawn Guo
2012-10-09 2:27 ` Rob Herring
2012-10-09 2:45 ` Shawn Guo
2012-10-09 4:01 ` Nicolas Pitre
2012-10-10 13:29 ` Rob Herring
2012-10-10 13:57 ` Nicolas Pitre
2012-10-11 12:43 ` [PATCH] ARM: decompressor: clear SCTLR.A bit for v7 cores Rob Herring
2012-10-11 13:09 ` Russell King - ARM Linux
2012-10-11 13:31 ` Rob Herring
2012-10-11 13:41 ` Russell King - ARM Linux
2012-10-11 15:44 ` Nicolas Pitre
2012-10-23 20:32 ` Gregory CLEMENT
2012-10-25 12:07 ` Russell King - ARM Linux
2012-10-11 13:59 ` Russell King - ARM Linux
2012-10-11 15:58 ` Nicolas Pitre
2012-10-25 9:34 ` Johannes Stezenbach
2012-10-25 12:41 ` Rob Herring
2012-10-25 13:30 ` Arnd Bergmann
2012-10-25 14:16 ` Johannes Stezenbach
2012-10-25 14:25 ` Rob Herring
2012-10-25 15:02 ` Nicolas Pitre
2012-10-25 15:08 ` Johannes Stezenbach
2012-11-05 10:48 ` Dave Martin
2012-11-05 11:13 ` Russell King - ARM Linux
2012-11-05 13:02 ` Dave Martin
2012-11-05 13:43 ` Johannes Stezenbach
2012-11-05 15:39 ` Russell King - ARM Linux
2012-11-05 16:13 ` Nicolas Pitre
2012-11-05 17:26 ` Dave Martin
2012-11-05 17:44 ` Rob Herring
2012-11-05 20:02 ` Nicolas Pitre
2012-11-05 17:46 ` Nicolas Pitre
2012-11-05 13:48 ` Rob Herring
2012-11-05 22:02 ` Michael Hope
2013-02-20 14:56 ` Johannes Stezenbach
2013-02-20 15:07 ` Johannes Stezenbach
2012-08-05 1:23 ` [PATCH v2 4/5] ARM: use generic termios.h Rob Herring
2012-08-05 1:24 ` Rob Herring [this message]
2012-08-05 9:34 ` [PATCH v2 0/5] Use more asm-generic headers Thomas Petazzoni
2012-08-06 14:35 ` Arnd Bergmann
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=1344129840-16447-6-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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