The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] irq: add irq_alloc_desc_between() helper
@ 2011-05-04 20:19 Grant Likely
  2011-05-04 20:26 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Grant Likely @ 2011-05-04 20:19 UTC (permalink / raw)
  To: tglx, linux-kernel, miltonm

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)


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

* Re: [PATCH] irq: add irq_alloc_desc_between() helper
  2011-05-04 20:19 [PATCH] irq: add irq_alloc_desc_between() helper Grant Likely
@ 2011-05-04 20:26 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2011-05-04 20:26 UTC (permalink / raw)
  To: tglx, linux-kernel, miltonm

On Wed, May 4, 2011 at 2:19 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
> 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)

Actually, this should be 'if (max && start + cnt > max)'

g.

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

end of thread, other threads:[~2011-05-04 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 20:19 [PATCH] irq: add irq_alloc_desc_between() helper Grant Likely
2011-05-04 20:26 ` Grant Likely

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