mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] irq: clarify logic calculating bogus irqreturn_t values
@ 2017-02-16  4:24 Jeremy Kerr
  2017-02-16 14:34 ` [tip:irq/core] genirq: Clarify " tip-bot for Jeremy Kerr
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Kerr @ 2017-02-16  4:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner

Although irqreturn_t is an enum, we treat it (and its enumeration
constants) as a bitmask.

However, bad_action_ret() uses a less-than operator to determine whether
an irqreturn_t falls within allowable bit values, which means we need to
know the signededness of an enum type to read the logic, which is
implementation-dependent.

This change explicitly uses an unsigned type for the comparison. We do
this instead of changing to a bitwise test, as the latter compiles to
increased instructions in this hot path.

It looks like we get the correct behaviour currently (bad_action_ret(-1)
returns 1), so this is purely a readability fix.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 kernel/irq/spurious.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 5707f97..061ba7e 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -175,7 +175,9 @@ static void poll_spurious_irqs(unsigned long dummy)
 
 static inline int bad_action_ret(irqreturn_t action_ret)
 {
-	if (likely(action_ret <= (IRQ_HANDLED | IRQ_WAKE_THREAD)))
+	unsigned int r = action_ret;
+
+	if (likely(r <= (IRQ_HANDLED | IRQ_WAKE_THREAD)))
 		return 0;
 	return 1;
 }
-- 
2.7.4

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

end of thread, other threads:[~2017-02-16 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16  4:24 [PATCH] irq: clarify logic calculating bogus irqreturn_t values Jeremy Kerr
2017-02-16 14:34 ` [tip:irq/core] genirq: Clarify " tip-bot for Jeremy Kerr

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

Powered by JetHome