From: Grant Likely <grant.likely@secretlab.ca>
To: tglx@linutronix.de, linux-kernel@vger.kernel.org, miltonm@bga.com
Subject: [PATCH] irq: add irq_alloc_desc_between() helper
Date: Wed, 04 May 2011 14:19:22 -0600 [thread overview]
Message-ID: <20110504201839.7701.18840.stgit@ponder> (raw)
Written in response to conversation on IRC about needing to specify an upper
limit on the virq value returned for some MSI interrupt controllers. Compiled
only; untested
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
include/linux/irq.h | 9 ++++++++-
kernel/irq/irqdesc.c | 5 ++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 09a3080..bcb712b 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -544,10 +544,17 @@ static inline struct msi_desc *irq_data_get_msi(struct irq_data *d)
return d->msi_desc;
}
-int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node);
+int irq_alloc_descs_between(int irq, unsigned int from, unsigned int cnt,
+ unsigned int max, int node);
void irq_free_descs(unsigned int irq, unsigned int cnt);
int irq_reserve_irqs(unsigned int from, unsigned int cnt);
+static inline int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt,
+ int node)
+{
+ return irq_alloc_descs_between(irq, from, cnt, 0, node);
+}
+
static inline int irq_alloc_desc(int node)
{
return irq_alloc_descs(-1, 0, 1, node);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 2c039c9..c1ddabd 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -322,7 +322,7 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
* Returns the first irq number or error code
*/
int __ref
-irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
+irq_alloc_descs_between(int irq, unsigned int from, unsigned int cnt, unsigned int max, int node)
{
int start, ret;
@@ -337,6 +337,9 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
if (irq >=0 && start != irq)
goto err;
+ if (max && start + cnt >= max)
+ goto err;
+
if (start + cnt > nr_irqs) {
ret = irq_expand_nr_irqs(start + cnt);
if (ret)
next reply other threads:[~2011-05-04 20:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 20:19 Grant Likely [this message]
2011-05-04 20:26 ` [PATCH] irq: add irq_alloc_desc_between() helper Grant Likely
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=20110504201839.7701.18840.stgit@ponder \
--to=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=miltonm@bga.com \
--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