Commit 5cf8f7db8274f68b180ad277dbb0308e72b66efd

Authored by Andreas Larsson
Committed by David S. Miller
1 parent afe760e43d

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>

Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff

drivers/base/platform.c
... ... @@ -83,9 +83,16 @@
83 83 */
84 84 int platform_get_irq(struct platform_device *dev, unsigned int num)
85 85 {
  86 +#ifdef CONFIG_SPARC
  87 + /* sparc does not have irqs represented as IORESOURCE_IRQ resources */
  88 + if (!dev || num >= dev->archdata.num_irqs)
  89 + return -ENXIO;
  90 + return dev->archdata.irqs[num];
  91 +#else
86 92 struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num);
87 93  
88 94 return r ? r->start : -ENXIO;
  95 +#endif
89 96 }
90 97 EXPORT_SYMBOL_GPL(platform_get_irq);
91 98