From: Andrew Lunn <andrew@lunn.ch>
To: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Po-Yu Chuang <ratbert@faraday-tech.com>,
Joel Stanley <joel@jms.id.au>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
openbmc@lists.ozlabs.org
Subject: Re: [PATCH v1 2/2] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500
Date: Sat, 17 Oct 2020 22:39:38 +0200 [thread overview]
Message-ID: <20201017203938.GR456889@lunn.ch> (raw)
In-Reply-To: <20201015124917.8168-3-i.mikhaylov@yadro.com>
> - err = mdiobus_register(priv->mii_bus);
> + mdio_np = of_get_child_by_name(np, "mdio");
> + if (mdio_np)
> + err = of_mdiobus_register(priv->mii_bus, mdio_np);
> + else
> + err = mdiobus_register(priv->mii_bus);
of_mdiobus_register() will do the right thing if passed a NULL pointer
for mdio_np.
> +
> if (err) {
> dev_err(priv->dev, "Cannot register MDIO bus!\n");
> goto err_register_mdiobus;
> }
>
> + if (mdio_np)
> + of_node_put(mdio_np);
of_node_put() is also happy with a NULL pointer.
> +
> return 0;
>
> err_register_mdiobus:
> @@ -1830,10 +1839,23 @@ static int ftgmac100_probe(struct platform_device *pdev)
> } else if (np && of_get_property(np, "phy-handle", NULL)) {
> struct phy_device *phy;
>
> + /* Support "mdio"/"phy" child nodes for ast2400/2500 with
> + * an embedded MDIO controller. Automatically scan the DTS for
> + * available PHYs and register them.
> + */
> + if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
> + of_device_is_compatible(np, "aspeed,ast2500-mac")) {
> + err = ftgmac100_setup_mdio(netdev);
> + if (err)
> + goto err_setup_mdio;
> + }
> +
> phy = of_phy_get_and_connect(priv->netdev, np,
> &ftgmac100_adjust_link);
> if (!phy) {
> dev_err(&pdev->dev, "Failed to connect to phy\n");
> + if (priv->mii_bus)
> + mdiobus_unregister(priv->mii_bus);
> goto err_setup_mdio;
It would be nice if the tear down was symmetric to the setup. Add an
ftgmac100_remove_mdio(), and call it on the same condition as
ftgmac100_setup_mdio().
Andrew
prev parent reply other threads:[~2020-10-17 20:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 12:49 [PATCH v1 0/2] add ast2400/2500 phy-handle support Ivan Mikhaylov
2020-10-15 12:49 ` [PATCH v1 1/2] net: ftgmac100: move phy connect out from ftgmac100_setup_mdio Ivan Mikhaylov
2020-10-17 20:32 ` Andrew Lunn
2020-10-19 23:30 ` Benjamin Herrenschmidt
2020-10-15 12:49 ` [PATCH v1 2/2] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500 Ivan Mikhaylov
2020-10-17 20:39 ` 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=20201017203938.GR456889@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=i.mikhaylov@yadro.com \
--cc=joel@jms.id.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=ratbert@faraday-tech.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;
as well as URLs for NNTP newsgroup(s).