]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
genirq: Clarify logic calculating bogus irqreturn_t values
authorJeremy Kerr <jk@ozlabs.org>
Thu, 16 Feb 2017 04:24:09 +0000 (12:24 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 Feb 2017 14:32:19 +0000 (15:32 +0100)
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>
Link: http://lkml.kernel.org/r/1487219049-4061-1-git-send-email-jk@ozlabs.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/irq/spurious.c

index 5707f97a3e6ac50954f8d407d5a4aadcaa2b96fc..061ba7eed4edf77249b0a99df771e3f6d0dc26e0 100644 (file)
@@ -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;
 }