From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Jarzmik Subject: Re: [REGRESSION] gpio: pxa: change initcall level second attempt Date: Sun, 31 Jan 2016 00:20:13 +0100 Message-ID: <8737te7iz6.fsf@belgarion.home> References: <1453598314.3178.12.camel@ziswiler.com> <87oac9ag32.fsf@belgarion.home> <87y4bc845m.fsf@belgarion.home> <1453853124.25762.5.camel@ziswiler.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1453853124.25762.5.camel@ziswiler.com> (Marcel Ziswiler's message of "Wed, 27 Jan 2016 01:05:24 +0100") Sender: linux-kernel-owner@vger.kernel.org To: Marcel Ziswiler Cc: Linus Walleij , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-gpio@vger.kernel.org Marcel, would you try the patch here after ? I have tested it on my cm-x300 with a devicetree build, let's see if th= at is a solution to your issue. Cheers. --=20 Robert ---8<--- =46rom 5901e6d55061c0cd627cfbf090ef6362c712b3c8 Mon Sep 17 00:00:00 200= 1 =46rom: Robert Jarzmik Date: Sun, 31 Jan 2016 00:06:21 +0100 Subject: [PATCH] net: ethernet: davicom: fix devicetree irq resource The dm9000 driver doesn't work in at least one device-tree configuration, spitting an error message on irq resource : [=C2=A0=C2=A0=C2=A0=C2=A01.062495] dm9000 8000000.ethernet: insufficien= t resources [=C2=A0=C2=A0=C2=A0=C2=A01.068439] dm9000 8000000.ethernet: not found (= -2). [=C2=A0=C2=A0=C2=A0=C2=A01.073451] dm9000: probe of 8000000.ethernet fa= iled with error -2 The reason behind is that the interrupt might be provided by a gpio controller, not probed when dm9000 is probed, and needing the probe deferral mechanism to apply. Currently, the interrupt is directly taken from resources. This patch changes this to use the more generic platform_get_irq(), which handles the deferral. Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse IRQ flags from resources"), the interrupt trigger flags are honored in platform_get_irq(), so remove the needless code in dm9000. Signed-off-by: Robert Jarzmik --- drivers/net/ethernet/davicom/dm9000.c | 28 ++++++++++++++-------------= - 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethern= et/davicom/dm9000.c index cf94b72..22e1a9d 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -128,7 +128,6 @@ struct board_info { struct resource *data_res; struct resource *addr_req; /* resources requested */ struct resource *data_req; - struct resource *irq_res; =20 int irq_wake; =20 @@ -1300,18 +1299,14 @@ static int dm9000_open(struct net_device *dev) { struct board_info *db =3D netdev_priv(dev); - unsigned long irqflags =3D db->irq_res->flags & IRQF_TRIGGER_MASK; + unsigned long irqflags =3D 0; =20 if (netif_msg_ifup(db)) dev_dbg(db->dev, "enabling %s\n", dev->name); =20 - /* If there is no IRQ type specified, default to something that - * may work, and tell the user that this is a problem */ - - if (irqflags =3D=3D IRQF_TRIGGER_NONE) - irqflags =3D irq_get_trigger_type(dev->irq); - - if (irqflags =3D=3D IRQF_TRIGGER_NONE) + /* If there is no IRQ type specified, tell the user that this is a + * problem */ + if (irq_get_trigger_type(dev->irq) =3D=3D IRQF_TRIGGER_NONE) dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n"); =20 irqflags |=3D IRQF_SHARED; @@ -1500,15 +1495,21 @@ dm9000_probe(struct platform_device *pdev) =20 db->addr_res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); db->data_res =3D platform_get_resource(pdev, IORESOURCE_MEM, 1); - db->irq_res =3D platform_get_resource(pdev, IORESOURCE_IRQ, 0); =20 - if (db->addr_res =3D=3D NULL || db->data_res =3D=3D NULL || - db->irq_res =3D=3D NULL) { - dev_err(db->dev, "insufficient resources\n"); + if (db->addr_res =3D=3D NULL || db->data_res =3D=3D NULL) { + dev_err(db->dev, "insufficient resources addr=3D%p data=3D%p\n", + db->addr_res, db->data_res); ret =3D -ENOENT; goto out; } =20 + ndev->irq =3D platform_get_irq(pdev, 0); + if (ndev->irq <=3D 0) { + dev_err(db->dev, "interrupt ressource unavailable: %d\n", + ndev->irq); + return ndev->irq; + } + db->irq_wake =3D platform_get_irq(pdev, 1); if (db->irq_wake >=3D 0) { dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake); @@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev) =20 /* fill in parameters for net-dev structure */ ndev->base_addr =3D (unsigned long)db->io_addr; - ndev->irq =3D db->irq_res->start; =20 /* ensure at least we have a default set of IO routines */ dm9000_set_io(db, iosize); --=20 2.1.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932194AbcA3XUT (ORCPT ); Sat, 30 Jan 2016 18:20:19 -0500 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:27676 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757106AbcA3XUR convert rfc822-to-8bit (ORCPT ); Sat, 30 Jan 2016 18:20:17 -0500 X-ME-Helo: belgarion X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Sun, 31 Jan 2016 00:20:15 +0100 X-ME-IP: 109.214.175.60 From: Robert Jarzmik To: Marcel Ziswiler Cc: Linus Walleij , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [REGRESSION] gpio: pxa: change initcall level second attempt References: <1453598314.3178.12.camel@ziswiler.com> <87oac9ag32.fsf@belgarion.home> <87y4bc845m.fsf@belgarion.home> <1453853124.25762.5.camel@ziswiler.com> X-URL: http://belgarath.falguerolles.org/ Date: Sun, 31 Jan 2016 00:20:13 +0100 In-Reply-To: <1453853124.25762.5.camel@ziswiler.com> (Marcel Ziswiler's message of "Wed, 27 Jan 2016 01:05:24 +0100") Message-ID: <8737te7iz6.fsf@belgarion.home> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Marcel, would you try the patch here after ? I have tested it on my cm-x300 with a devicetree build, let's see if that is a solution to your issue. Cheers. -- Robert ---8<--- >>From 5901e6d55061c0cd627cfbf090ef6362c712b3c8 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sun, 31 Jan 2016 00:06:21 +0100 Subject: [PATCH] net: ethernet: davicom: fix devicetree irq resource The dm9000 driver doesn't work in at least one device-tree configuration, spitting an error message on irq resource : [    1.062495] dm9000 8000000.ethernet: insufficient resources [    1.068439] dm9000 8000000.ethernet: not found (-2). [    1.073451] dm9000: probe of 8000000.ethernet failed with error -2 The reason behind is that the interrupt might be provided by a gpio controller, not probed when dm9000 is probed, and needing the probe deferral mechanism to apply. Currently, the interrupt is directly taken from resources. This patch changes this to use the more generic platform_get_irq(), which handles the deferral. Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse IRQ flags from resources"), the interrupt trigger flags are honored in platform_get_irq(), so remove the needless code in dm9000. Signed-off-by: Robert Jarzmik --- drivers/net/ethernet/davicom/dm9000.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index cf94b72..22e1a9d 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -128,7 +128,6 @@ struct board_info { struct resource *data_res; struct resource *addr_req; /* resources requested */ struct resource *data_req; - struct resource *irq_res; int irq_wake; @@ -1300,18 +1299,14 @@ static int dm9000_open(struct net_device *dev) { struct board_info *db = netdev_priv(dev); - unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; + unsigned long irqflags = 0; if (netif_msg_ifup(db)) dev_dbg(db->dev, "enabling %s\n", dev->name); - /* If there is no IRQ type specified, default to something that - * may work, and tell the user that this is a problem */ - - if (irqflags == IRQF_TRIGGER_NONE) - irqflags = irq_get_trigger_type(dev->irq); - - if (irqflags == IRQF_TRIGGER_NONE) + /* If there is no IRQ type specified, tell the user that this is a + * problem */ + if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE) dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n"); irqflags |= IRQF_SHARED; @@ -1500,15 +1495,21 @@ dm9000_probe(struct platform_device *pdev) db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (db->addr_res == NULL || db->data_res == NULL || - db->irq_res == NULL) { - dev_err(db->dev, "insufficient resources\n"); + if (db->addr_res == NULL || db->data_res == NULL) { + dev_err(db->dev, "insufficient resources addr=%p data=%p\n", + db->addr_res, db->data_res); ret = -ENOENT; goto out; } + ndev->irq = platform_get_irq(pdev, 0); + if (ndev->irq <= 0) { + dev_err(db->dev, "interrupt ressource unavailable: %d\n", + ndev->irq); + return ndev->irq; + } + db->irq_wake = platform_get_irq(pdev, 1); if (db->irq_wake >= 0) { dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake); @@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev) /* fill in parameters for net-dev structure */ ndev->base_addr = (unsigned long)db->io_addr; - ndev->irq = db->irq_res->start; /* ensure at least we have a default set of IO routines */ dm9000_set_io(db, iosize); -- 2.1.4