Re: [REGRESSION] gpio: pxa: change initcall level second attempt

From: Marcel Ziswiler
Date: Mon Feb 01 2016 - 02:27:36 EST


Hi Robert

On Sun, 2016-01-31 at 00:20 +0100, Robert Jarzmik wrote:
> 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.

Yes, that indeed cuts it nicely. Thanks!

> Cheers.
>
> --Â
> Robert
>
> ---8<---
> From 5901e6d55061c0cd627cfbf090ef6362c712b3c8 Mon Sep 17 00:00:00
> 2001
> From: Robert Jarzmik <robert.jarzmik@xxxxxxx>
> 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 <robert.jarzmik@xxxxxxx>
> ---
> Â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);


Acked-by:ÂMarcel Ziswiler <marcel@xxxxxxxxxxxx>

Cheers

Marcel