diff mbox

net/smsc911x: fix irq resource allocation failure

Message ID 1430730589-17378-1-git-send-email-kamlakant.patel@broadcom.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Kamlakant Patel May 4, 2015, 9:09 a.m. UTC
From: Kamlakant Patel <kamlakant.patel@broadcom.com>

When smsc911x uses GPIO as the interrupt controller, and if both are
loaded as modules, we get following error:

"smsc911x: Could not allocate irq resource"

This issue is because of smsc911x using platform_get_resource to get
device tree based irq resource.

commit "9ec36ca (of/irq: do irq resolution in platform_get_irq)" and
commit "7085a7 (drivers: platform: parse IRQ flags from resources)" add
support in platform_get_irq to resolve irq and irq_flags respectively
for both modern device tree and legacy static platform data platforms.

Modify smsc911x driver to use platform_get_irq to pick up irq resource
correctly and use irq_get_trigger_type to get the IRQ trigger flags.

Signed-off-by: Kamlakant Patel <kamlakant.patel@broadcom.com>
---
 drivers/net/ethernet/smsc/smsc911x.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

Comments

Linus Walleij May 4, 2015, 1:16 p.m. UTC | #1
On Mon, May 4, 2015 at 11:09 AM,  <kamlakant.patel@broadcom.com> wrote:

> From: Kamlakant Patel <kamlakant.patel@broadcom.com>
>
> When smsc911x uses GPIO as the interrupt controller, and if both are
> loaded as modules, we get following error:
>
> "smsc911x: Could not allocate irq resource"
>
> This issue is because of smsc911x using platform_get_resource to get
> device tree based irq resource.
>
> commit "9ec36ca (of/irq: do irq resolution in platform_get_irq)" and
> commit "7085a7 (drivers: platform: parse IRQ flags from resources)" add
> support in platform_get_irq to resolve irq and irq_flags respectively
> for both modern device tree and legacy static platform data platforms.
>
> Modify smsc911x driver to use platform_get_irq to pick up irq resource
> correctly and use irq_get_trigger_type to get the IRQ trigger flags.
>
> Signed-off-by: Kamlakant Patel <kamlakant.patel@broadcom.com>

Basically identical to commit d52fdbb735c36a209f36a628d40ca9185b349ba7
"smc91x: retrieve IRQ and trigger flags in a modern way" for
the SMC91x driver, which was reverted but should now be unreverted
as the patch to driver core was merged :P


> -       irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> -       if (!irq_res) {
> +       irq = platform_get_irq(pdev, 0);
> +       if (irq <= 0) {
>                 pr_warn("Could not allocate irq resource\n");

Correct.

> -       dev->irq = irq_res->start;
> -       irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
> +       dev->irq = irq;
> +       irq_flags = irq_get_trigger_type(irq);

This slightly alters semantics, since any other flags apart from trigger
flags will also be retrieved. maybe you should still add

irq_flags &= IRQF_TRIGGER_MASK;

after this line?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 4, 2015, 7:11 p.m. UTC | #2
From: <kamlakant.patel@broadcom.com>
Date: Mon, 4 May 2015 14:39:49 +0530

> From: Kamlakant Patel <kamlakant.patel@broadcom.com>
> 
> When smsc911x uses GPIO as the interrupt controller, and if both are
> loaded as modules, we get following error:
> 
> "smsc911x: Could not allocate irq resource"
> 
> This issue is because of smsc911x using platform_get_resource to get
> device tree based irq resource.
> 
> commit "9ec36ca (of/irq: do irq resolution in platform_get_irq)" and
> commit "7085a7 (drivers: platform: parse IRQ flags from resources)" add
> support in platform_get_irq to resolve irq and irq_flags respectively
> for both modern device tree and legacy static platform data platforms.
> 
> Modify smsc911x driver to use platform_get_irq to pick up irq resource
> correctly and use irq_get_trigger_type to get the IRQ trigger flags.
> 
> Signed-off-by: Kamlakant Patel <kamlakant.patel@broadcom.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 41047c9..959aeea 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2418,9 +2418,9 @@  static int smsc911x_drv_probe(struct platform_device *pdev)
 	struct net_device *dev;
 	struct smsc911x_data *pdata;
 	struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev);
-	struct resource *res, *irq_res;
+	struct resource *res;
 	unsigned int intcfg = 0;
-	int res_size, irq_flags;
+	int res_size, irq, irq_flags;
 	int retval;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -2434,8 +2434,8 @@  static int smsc911x_drv_probe(struct platform_device *pdev)
 	}
 	res_size = resource_size(res);
 
-	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!irq_res) {
+	irq = platform_get_irq(pdev, 0);
+	if (irq <= 0) {
 		pr_warn("Could not allocate irq resource\n");
 		retval = -ENODEV;
 		goto out_0;
@@ -2455,8 +2455,8 @@  static int smsc911x_drv_probe(struct platform_device *pdev)
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	pdata = netdev_priv(dev);
-	dev->irq = irq_res->start;
-	irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
+	dev->irq = irq;
+	irq_flags = irq_get_trigger_type(irq);
 	pdata->ioaddr = ioremap_nocache(res->start, res_size);
 
 	pdata->dev = dev;