public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Axel Lin <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, grant.likely@linaro.org,
	hpa@zytor.com, mingo@kernel.org, tony@atomide.com, arnd@arndb.de,
	tglx@linutronix.de, axel.lin@ingics.com
Subject: [tip:irq/urgent] genirq: generic chip: Use DIV_ROUND_UP to calculate numchips
Date: Fri, 5 Jul 2013 02:48:57 -0700	[thread overview]
Message-ID: <tip-002fca5df168922103a2bb52748f9984e6de80b2@git.kernel.org> (raw)
In-Reply-To: <1373015592.18252.2.camel@phoenix>

Commit-ID:  002fca5df168922103a2bb52748f9984e6de80b2
Gitweb:     http://git.kernel.org/tip/002fca5df168922103a2bb52748f9984e6de80b2
Author:     Axel Lin <axel.lin@ingics.com>
AuthorDate: Fri, 5 Jul 2013 17:13:12 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 5 Jul 2013 11:39:25 +0200

genirq: generic chip: Use DIV_ROUND_UP to calculate numchips

The number of interrupts in a domain may be not divisible by the
number of interrupts each chip handles. Integer division may truncate
the result, thus use DIV_ROUND_UP to count numchips.

Seems all users of irq_alloc_domain_generic_chips() in current code do
not have this issue. I just found the issue while reading the code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: http://lkml.kernel.org/r/1373015592.18252.2.camel@phoenix
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/generic-chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 1c39ecc..2f274f3 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -278,7 +278,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
 	if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR)
 		return -EINVAL;
 
-	numchips = d->revmap_data.linear.size / irqs_per_chip;
+	numchips = DIV_ROUND_UP(d->revmap_data.linear.size, irqs_per_chip);
 	if (!numchips)
 		return -EINVAL;
 

      reply	other threads:[~2013-07-05  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-05  9:13 [PATCH RFC] genirq: Genric chip: Use DIV_ROUND_UP to count numchips Axel Lin
2013-07-05  9:48 ` tip-bot for Axel Lin [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-002fca5df168922103a2bb52748f9984e6de80b2@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=arnd@arndb.de \
    --cc=axel.lin@ingics.com \
    --cc=grant.likely@linaro.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.com \
    /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