* [PATCH] smc91x: retrieve IRQ and trigger flags in a modern way
@ 2014-10-31 20:32 Linus Walleij
2014-11-01 21:04 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2014-10-31 20:32 UTC (permalink / raw)
To: netdev, Nicolas Pitre, David S. Miller; +Cc: Linus Walleij
The SMC91x is written to explicitly look up the IRQ resource
from the platform device and extract the IRQ and flags, however
the platform_get_irq() does additional things, like call
of_irq_get() in the device tree case, which will translate
the IRQ using the irqdomain and defer the probe if the
IRQ host cannot be found.
As we're not looking up the resource, this will not retrieve
the IRQ flags, but that is better done using
irqd_get_trigger_type(), as the trigger is what the driver
wants to modify. We take care to preserve the semantics that
will make the trigger type provided from the resource
override any local specifier.
Tested on the Nomadik NHK15 which has its SMC91x IRQ line
connected to a STMPE2401 GPIO expander on I2C.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/net/ethernet/smsc/smc91x.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 5e94d00b96b3..7747d506646a 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2207,9 +2207,10 @@ static int smc_drv_probe(struct platform_device *pdev)
const struct of_device_id *match = NULL;
struct smc_local *lp;
struct net_device *ndev;
- struct resource *res, *ires;
+ struct resource *res;
unsigned int __iomem *addr;
unsigned long irq_flags = SMC_IRQ_FLAGS;
+ unsigned long irq_resflags;
int ret;
ndev = alloc_etherdev(sizeof(struct smc_local));
@@ -2279,16 +2280,19 @@ static int smc_drv_probe(struct platform_device *pdev)
goto out_free_netdev;
}
- ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!ires) {
+ ndev->irq = platform_get_irq(pdev, 0);
+ if (ndev->irq <= 0) {
ret = -ENODEV;
goto out_release_io;
}
-
- ndev->irq = ires->start;
-
- if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK)
- irq_flags = ires->flags & IRQF_TRIGGER_MASK;
+ /*
+ * If this platform does not specify any special irqflags, or if
+ * the resource supplies a trigger, override the irqflags with
+ * the trigger flags from the resource.
+ */
+ irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq));
+ if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK)
+ irq_flags = irq_resflags & IRQF_TRIGGER_MASK;
ret = smc_request_attrib(pdev, ndev);
if (ret)
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] smc91x: retrieve IRQ and trigger flags in a modern way
2014-10-31 20:32 [PATCH] smc91x: retrieve IRQ and trigger flags in a modern way Linus Walleij
@ 2014-11-01 21:04 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-11-01 21:04 UTC (permalink / raw)
To: linus.walleij; +Cc: netdev, nico
From: Linus Walleij <linus.walleij@linaro.org>
Date: Fri, 31 Oct 2014 21:32:06 +0100
> The SMC91x is written to explicitly look up the IRQ resource
> from the platform device and extract the IRQ and flags, however
> the platform_get_irq() does additional things, like call
> of_irq_get() in the device tree case, which will translate
> the IRQ using the irqdomain and defer the probe if the
> IRQ host cannot be found.
>
> As we're not looking up the resource, this will not retrieve
> the IRQ flags, but that is better done using
> irqd_get_trigger_type(), as the trigger is what the driver
> wants to modify. We take care to preserve the semantics that
> will make the trigger type provided from the resource
> override any local specifier.
>
> Tested on the Nomadik NHK15 which has its SMC91x IRQ line
> connected to a STMPE2401 GPIO expander on I2C.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-01 21:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31 20:32 [PATCH] smc91x: retrieve IRQ and trigger flags in a modern way Linus Walleij
2014-11-01 21:04 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).