sparc: Add sparc support for platform_get_irq()
PATCH v2 1/1 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.
--- drivers/base/platform.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/base/platform.c +6 -0
@@ -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);
Signature · 1 line
1.7.0.4
Quoted 6 lines · Andreas Larsson
This adds sparc support for
platform_get_irqthat in the normal case useplatform_get_resource()to get an irq. This standard approach fails for sparc as there are no resources of typeIORESOURCE_IRQfor 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.
Any comments? Is this a good idea, or do anyone see any problems with this change?
It would make life easier when adapting device drivers to work on a sparc platform.
Cheers,
Andreas Larsson
Quoted 25 lines
Signed-off-by Andreas Larsson <[email protected]>--- drivers/base/platform.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/base/platform.c +6
-0@@ -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);
From: Andreas Larsson <[email protected]>
Date: Tue, 23 Oct 2012 12:16:50 +0200
Quoted 11 lines · Andreas Larsson
Quoted 9 lines
This adds sparc support for
platform_get_irqthat in the normal case useplatform_get_resource()to get an irq. This standard approach fails for sparc as
there are no resources of typeIORESOURCE_IRQfor 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.
Quoted 5 lines
Any comments? Is this a good idea, or do anyone see any problems with this change?
It would make life easier when adapting device drivers to work on a sparc platform.
I'm just busy and haven't gotten to review this change yet, be patient.
Hi Andreas.
Quoted 10 lines · Andreas Larsson
Quoted 6 lines · Andreas Larsson
This adds sparc support for
platform_get_irqthat in the normal case useplatform_get_resource()to get an irq. This standard approach fails for sparc as there are no resources of typeIORESOURCE_IRQfor 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.
Any comments? Is this a good idea, or do anyone see any problems with this change?
First off - seeing a SPARC ifdef in base/drivers make me think that something is wrong. And there is not even a comment why SPARC is so special.
And secondly - what is need for SPARC to support IORESOURCE_IRQ? I took a very quick look - and I did not understand all the logic regarding IORESOURCE_IRQ.
But I could see linux/ioport.h being included in several places in sparc..
Sam
From: Sam Ravnborg <[email protected]>
Date: Wed, 24 Oct 2012 21:37:43 +0200
Quoted 3 lines
First off - seeing a SPARC ifdef in base/drivers make me think that something is wrong. And there is not even a comment why SPARC is so special.
The problem is that, on sparc, we store the IRQs in the device archdata area. Whereas other platforms do this in a different way, mostly via IORESOURCE_IRQ in the platform device.
From: David Miller:
Quoted 8 lines
From: Sam Ravnborg <[email protected]>
Quoted 3 lines
First off - seeing a SPARC ifdef in base/drivers make me think that something is wrong. And there is not even a comment why SPARC is so special.
The problem is that, on sparc, we store the IRQs in the device archdata area. Whereas other platforms do this in a different way, mostly via
IORESOURCE_IRQin the platform device
I agree that there should be a comment in the code about the reason for an #ifdef CONFIG_SPARC to be there.
From the point of view of getting cross platform drivers working on
sparc, I think it would be very nice if irqs were available as platform resources just as for so many other platforms. This however is a larger change than getting platform_get_irq to work.
I have lookined into the alternative of providing IORESOURCE_IRQ for sparc in parallel with the archdata representation, as a first step. Then drivers that relies upon platform resources could work at the same time as the code that relies on irqs being in archdata continues to work. In arch/sparc some changes needs to be done to code that assumes that all resources are "register" resources.
The problem with this approach however, is that there are a number of existing drivers (and some other code) that rely on specific number of resources for a device. All such code for devices that has irqs that run in a sparc context needs to be changed to take the new irq resources into account and care needs to be taken that code that is not in a sparc context is not changed. It is not always totally self-evident without further investigation which of the affected drivers might run in a sparc context.
The other problem of providing irq resources for sparc is the flags variable that comes with the resource. There seems to be no corresponding information for sparc devices so that the flag variable can be filled in properly.
Because of all this my proposition is to get platform_get_irq to work on sparc. Then cross platform drivers can be made to work under sparc in a smooth manner. As it is now, platform_get_irq is avalable to call in sparc, but the call will always fail.
Cheers,
Andreas
PATCH v3 1/1 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.
--- drivers/base/platform.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/base/platform.c +7 -0
@@ -82,9 +82,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);
Signature · 1 line
1.7.0.4
David Miller
AppliedFrom: Andreas Larsson <[email protected]>
Date: Thu, 18 Oct 2012 09:42:44 +0200
Quoted 8 lines
This adds sparc support for
platform_get_irqthat in the normal case useplatform_get_resource()to get an irq. This standard approach fails for sparc as there are no resources of typeIORESOURCE_IRQfor 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 <[email protected]>
Applied.