Netdev List
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Liu Xiang <liu.xiang@zlingsmart.com>
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Subject: Re: [PATCH v4] net: stmmac: avoid repeated devm_gpiod_get_optional in mdio reset on resume
Date: Fri, 15 May 2026 14:59:54 +0200	[thread overview]
Message-ID: <4a2c3023-ddc9-4729-a609-a648f1a052de@lunn.ch> (raw)
In-Reply-To: <20260515065652.46998-1-liu.xiang@zlingsmart.com>

On Fri, May 15, 2026 at 02:56:52PM +0800, Liu Xiang wrote:
> During system resume, stmmac_resume() calls stmmac_mdio_reset().
> This results in repeated calls to devm_gpiod_get_optional() for the same
> GPIO. The second invocation returns an error since the GPIO descriptor has
> already been obtained.
> 
> Fixes: 7c86f20d15b7c113 ("net: stmmac: use GPIO descriptors in stmmac_mdio_reset")
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Liu Xiang <liu.xiang@zlingsmart.com>
> ---

Under the --- you should include the history of the patch. This is
version 4. How does it differ to v1, v2, v3.

> +	priv->reset_gpio = devm_gpiod_get_optional(priv->device,
> +						   "snps,reset",
> +						   GPIOD_ASIS);
> +	if (IS_ERR(priv->reset_gpio)) {
> +		priv->reset_gpio = NULL;
> +		dev_warn(dev, "No reset GPIO found\n");
> +	}

Please read the documentation for devm_gpiod_get_optional().

There are three different cases:

1) A GPIO is returned
2) No GPIO is found in DT, which since it is optional, is O.K.
3) A real error happened, which should fail the probe.

Also, see what happens when you pass NULL to any gpiod_ method.

    Andrew

---
pw-bot: cr

      reply	other threads:[~2026-05-15 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  6:56 [PATCH v4] net: stmmac: avoid repeated devm_gpiod_get_optional in mdio reset on resume Liu Xiang
2026-05-15 12:59 ` Andrew Lunn [this message]

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=4a2c3023-ddc9-4729-a609-a648f1a052de@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=liu.xiang@zlingsmart.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox