Patchwork sparc: Add sparc support for platform_get_resource()

login
register
mail settings
Submitter Andreas Larsson
Date Oct. 18, 2012, 7:39 a.m.
Message ID <1350545996-7823-1-git-send-email-andreas@gaisler.com>
Download mbox | patch
Permalink /patch/192213/
State Superseded
Delegated to: David Miller
Headers show

Comments

Andreas Larsson - Oct. 18, 2012, 7:39 a.m.
This adds sparc support for platform_get_irq that in the normal case use
platform_get_resource() to get an irq. This standard approach fails for sparc as
there are no resources of type IORESOURCE_IRQ for irqs for sparc.

Cross platform drivers can then use this standard platform function and work on
sparc instead of having to have a special case for sparc.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
 drivers/base/platform.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Andreas Larsson - Oct. 18, 2012, 7:44 a.m.
On 2012-10-18 09:39, Andreas Larsson wrote:
> This adds sparc support for platform_get_irq that in the normal case use
> platform_get_resource() to get an irq. This standard approach fails for sparc as
> there are no resources of type IORESOURCE_IRQ for irqs for sparc.

Sorry, subject line incorrect. New version sent.

Cheers,
Andreas

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index ddeca14..a17199a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -82,9 +82,15 @@  EXPORT_SYMBOL_GPL(platform_get_resource);
  */
 int platform_get_irq(struct platform_device *dev, unsigned int num)
 {
+#ifdef CONFIG_SPARC
+	if (!dev || num >= dev->archdata.num_irqs)
+		return -ENXIO;
+	return dev->archdata.irqs[num];
+#else
 	struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num);
 
 	return r ? r->start : -ENXIO;
+#endif
 }
 EXPORT_SYMBOL_GPL(platform_get_irq);