mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Jeremy Kerr <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jk@ozlabs.org, tglx@linutronix.de, mingo@kernel.org,
	hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: [tip:irq/core] genirq: Clarify logic calculating bogus irqreturn_t values
Date: Thu, 16 Feb 2017 06:34:42 -0800	[thread overview]
Message-ID: <tip-5d4bac9a5f4ef24b2482529bda6661a58e5b5b65@git.kernel.org> (raw)
In-Reply-To: <1487219049-4061-1-git-send-email-jk@ozlabs.org>

Commit-ID:  5d4bac9a5f4ef24b2482529bda6661a58e5b5b65
Gitweb:     http://git.kernel.org/tip/5d4bac9a5f4ef24b2482529bda6661a58e5b5b65
Author:     Jeremy Kerr <jk@ozlabs.org>
AuthorDate: Thu, 16 Feb 2017 12:24:09 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 16 Feb 2017 15:32:19 +0100

genirq: Clarify logic calculating bogus irqreturn_t values

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 | 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 @@ out:
 
 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;
 }

      reply	other threads:[~2017-02-16 14:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16  4:24 [PATCH] irq: clarify " Jeremy Kerr
2017-02-16 14:34 ` tip-bot for Jeremy Kerr [this message]

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=tip-5d4bac9a5f4ef24b2482529bda6661a58e5b5b65@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=jk@ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome