netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Madalin Bucur <madalin.bucur@nxp.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next 4/8] net: pcs: lynx: add lynx_pcs_create_fwnode()
Date: Fri, 2 Jun 2023 11:51:23 -0400	[thread overview]
Message-ID: <64b55156-81e2-44cf-224d-d362e10955e3@seco.com> (raw)
In-Reply-To: <E1q56y1-00Bsum-Hx@rmk-PC.armlinux.org.uk>

On 6/2/23 11:45, Russell King (Oracle) wrote:
> Add a helper to create a lynx PCS from a fwnode handle.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/pcs/pcs-lynx.c | 29 +++++++++++++++++++++++++++++
>  include/linux/pcs-lynx.h   |  1 +
>  2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c
> index a90f74172f49..b0907c67d469 100644
> --- a/drivers/net/pcs/pcs-lynx.c
> +++ b/drivers/net/pcs/pcs-lynx.c
> @@ -353,6 +353,35 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr)
>  }
>  EXPORT_SYMBOL(lynx_pcs_create_mdiodev);
>  
> +struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node)
> +{
> +	struct mdio_device *mdio;
> +	struct phylink_pcs *pcs;

I think you should put the available check here as well.

> +	mdio = fwnode_mdio_find_device(node);
> +	if (!mdio)
> +		return ERR_PTR(-EPROBE_DEFER);
> +
> +	pcs = lynx_pcs_create(mdio);
> +
> +	/* Convert failure to create the PCS to an error pointer, so this
> +	 * function has a consistent return value strategy.
> +	 */
> +	if (!pcs)
> +		pcs = ERR_PTR(-ENOMEM);
> +
> +	/* lynx_create() has taken a refcount on the mdiodev if it was
> +	 * successful. If lynx_create() fails, this will free the mdio
> +	 * device here. In any case, we don't need to hold our reference
> +	 * anymore, and putting it here will allow mdio_device_put() in
> +	 * lynx_destroy() to automatically free the mdio device.
> +	 */
> +	mdio_device_put(mdio);
> +
> +	return pcs;
> +}
> +EXPORT_SYMBOL_GPL(lynx_pcs_create_fwnode);
> +
>  void lynx_pcs_destroy(struct phylink_pcs *pcs)
>  {
>  	struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs);
> diff --git a/include/linux/pcs-lynx.h b/include/linux/pcs-lynx.h
> index 25f68a096bfe..123e813df771 100644
> --- a/include/linux/pcs-lynx.h
> +++ b/include/linux/pcs-lynx.h
> @@ -11,6 +11,7 @@
>  
>  struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio);
>  struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr);
> +struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node);
>  
>  void lynx_pcs_destroy(struct phylink_pcs *pcs);
>  

Anyway, the rest of this series looks good to me.

--Sean

  reply	other threads:[~2023-06-02 15:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 15:44 [PATCH net-next 0/8] complete Lynx mdio device handling Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 1/8] net: dpaa2-mac: allow lynx PCS to manage mdiodev lifetime Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 2/8] net: fman_memac: allow lynx PCS to handle " Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 3/8] net: pcs: lynx: remove lynx_get_mdio_device() Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 4/8] net: pcs: lynx: add lynx_pcs_create_fwnode() Russell King (Oracle)
2023-06-02 15:51   ` Sean Anderson [this message]
2023-06-06 11:25     ` Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 5/8] net: dpaa2-mac: use lynx_pcs_create_fwnode() Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 6/8] net: fman_memac: " Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 7/8] net: pcs: lynx: make lynx_pcs_create() static Russell King (Oracle)
2023-06-02 15:45 ` [PATCH net-next 8/8] net: pcs: lynx: change lynx_pcs_create() to return error-pointers Russell King (Oracle)
2023-06-06 11:09 ` [PATCH net-next 0/8] complete Lynx mdio device handling Russell King (Oracle)

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=64b55156-81e2-44cf-224d-d362e10955e3@seco.com \
    --to=sean.anderson@seco.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).