Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smc91x: retrieve IRQ and trigger flags in a modern way

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Linus Walleij and committed by
David S. Miller
d52fdbb7 1db3ddff

+12 -8
+12 -8
drivers/net/ethernet/smsc/smc91x.c
··· 2243 2243 const struct of_device_id *match = NULL; 2244 2244 struct smc_local *lp; 2245 2245 struct net_device *ndev; 2246 - struct resource *res, *ires; 2246 + struct resource *res; 2247 2247 unsigned int __iomem *addr; 2248 2248 unsigned long irq_flags = SMC_IRQ_FLAGS; 2249 + unsigned long irq_resflags; 2249 2250 int ret; 2250 2251 2251 2252 ndev = alloc_etherdev(sizeof(struct smc_local)); ··· 2338 2337 goto out_free_netdev; 2339 2338 } 2340 2339 2341 - ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2342 - if (!ires) { 2340 + ndev->irq = platform_get_irq(pdev, 0); 2341 + if (ndev->irq <= 0) { 2343 2342 ret = -ENODEV; 2344 2343 goto out_release_io; 2345 2344 } 2346 - 2347 - ndev->irq = ires->start; 2348 - 2349 - if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK) 2350 - irq_flags = ires->flags & IRQF_TRIGGER_MASK; 2345 + /* 2346 + * If this platform does not specify any special irqflags, or if 2347 + * the resource supplies a trigger, override the irqflags with 2348 + * the trigger flags from the resource. 2349 + */ 2350 + irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq)); 2351 + if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK) 2352 + irq_flags = irq_resflags & IRQF_TRIGGER_MASK; 2351 2353 2352 2354 ret = smc_request_attrib(pdev, ndev); 2353 2355 if (ret)