summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorAndreas Larsson <andreas@gaisler.com>2012-10-30 00:26:56 +0100
committerDavid S. Miller <davem@davemloft.net>2012-11-10 01:30:49 +0100
commit5cf8f7db8274f68b180ad277dbb0308e72b66efd (patch)
treead0e683218fec13d4d877b4dc56b8436ac023d5f /drivers/base
parentsparc: Allow OF_GPIO on sparc. (diff)
downloadlinux-5cf8f7db8274f68b180ad277dbb0308e72b66efd.tar.xz
linux-5cf8f7db8274f68b180ad277dbb0308e72b66efd.zip
sparc: Add sparc support for platform_get_irq()
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/platform.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8727e9c5eea4..72c776f2a1f5 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -83,9 +83,16 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
*/
int platform_get_irq(struct platform_device *dev, unsigned int num)
{
+#ifdef CONFIG_SPARC
+ /* sparc does not have irqs represented as IORESOURCE_IRQ resources */
+ 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);