All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Robert Jarzmik <robert.jarzmik@free.fr>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] net: ethernet: davicom: fix devicetree irq resource
Date: Sun, 7 Feb 2016 13:49:23 +0300	[thread overview]
Message-ID: <56B72133.5090801@cogentembedded.com> (raw)
In-Reply-To: <1454796693-4446-1-git-send-email-robert.jarzmik@free.fr>

Hello.

On 2/7/2016 1:11 AM, Robert Jarzmik wrote:

> 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

    Fixes: tag here?

> 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@free.fr>
> Acked-by: Marcel Ziswiler <marcel@ziswiler.com>
> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> ---
> Since v1: comment style and requested irq test < 0
>            David, you should know that Sergei is concerned with the
> 	  subsystem prefix in the patch subject (too long for him).
> ---
>   drivers/net/ethernet/davicom/dm9000.c | 29 +++++++++++++++--------------
>   1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
> index cf94b72dbacd..2bae5c8c1f85 100644
> --- a/drivers/net/ethernet/davicom/dm9000.c
> +++ b/drivers/net/ethernet/davicom/dm9000.c
[...]
> @@ -1300,18 +1299,15 @@ 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;

    Why not just initialize to IRQF_SHARED?
    But actually you don't need this variable anymore.

> @@ -1500,15 +1496,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 || !db->data_res) {
> +		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 resource unavailable: %d\n",
> +			ndev->irq);
> +		return ndev->irq;

    As already noted, direct *return* can't be used here.

[...]

MBR, Sergei

  parent reply	other threads:[~2016-02-07 10:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-06 22:11 [PATCH v2] net: ethernet: davicom: fix devicetree irq resource Robert Jarzmik
2016-02-07 10:23 ` Francois Romieu
2016-02-07 10:46   ` Robert Jarzmik
2016-02-07 12:34     ` Francois Romieu
2016-02-07 10:49 ` Sergei Shtylyov [this message]
2016-02-07 11:47   ` Robert Jarzmik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56B72133.5090801@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robert.jarzmik@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.