From: <Claudiu.Beznea@microchip.com>
To: <mparab@cadence.com>, <Nicolas.Ferre@microchip.com>,
<jakub.kicinski@netronome.com>, <andrew@lunn.ch>,
<antoine.tenart@bootlin.com>, <rmk+kernel@armlinux.org.uk>
Cc: <f.fainelli@gmail.com>, <davem@davemloft.net>,
<netdev@vger.kernel.org>, <hkallweit1@gmail.com>,
<linux-kernel@vger.kernel.org>, <dkangude@cadence.com>,
<a.fatoum@pengutronix.de>, <brad.mouring@ni.com>,
<pthombar@cadence.com>
Subject: Re: [PATCH net] net: macb: fix for fixed-link mode
Date: Fri, 10 Jan 2020 11:53:24 +0000 [thread overview]
Message-ID: <91a5684d-9170-fdf6-3cd1-ae0636f3727b@microchip.com> (raw)
In-Reply-To: <1578635183-30482-1-git-send-email-mparab@cadence.com>
On 10.01.2020 07:46, Milind Parab wrote:
> This patch fix the issue with fixed link. With fixed-link
> device opening fails due to macb_phylink_connect not
> handling fixed-link mode, in which case no MAC-PHY connection
> is needed and phylink_connect return success (0), however
> in current driver attempt is made to search and connect to
> PHY even for fixed-link.
>
> Fixes: 7897b071ac3b ("net: macb: convert to phylink")
> Signed-off-by: Milind Parab <mparab@cadence.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index c5ee363ca5dc..41c485485619 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -611,21 +611,24 @@ static const struct phylink_mac_ops macb_phylink_ops = {
> .mac_link_up = macb_mac_link_up,
> };
>
> +static bool macb_phy_handle_exists(struct device_node *dn)
> +{
> + dn = of_parse_phandle(dn, "phy-handle", 0);
> + of_node_put(dn);
> + return dn != NULL;
> +}
> +
> static int macb_phylink_connect(struct macb *bp)
> {
> struct net_device *dev = bp->dev;
> struct phy_device *phydev;
> + struct device_node *dn = bp->pdev->dev.of_node;
> int ret;
>
> - if (bp->pdev->dev.of_node &&
> - of_parse_phandle(bp->pdev->dev.of_node, "phy-handle", 0)) {
> - ret = phylink_of_phy_connect(bp->phylink, bp->pdev->dev.of_node,
> - 0);
> - if (ret) {
> - netdev_err(dev, "Could not attach PHY (%d)\n", ret);
> - return ret;
> - }
> - } else {
> + if (dn)
> + ret = phylink_of_phy_connect(bp->phylink, dn, 0);
> +
> + if (!dn || (ret && !macb_phy_handle_exists(dn))) {
> phydev = phy_find_first(bp->mii_bus);
> if (!phydev) {
> netdev_err(dev, "no PHY found\n");
> @@ -638,6 +641,9 @@ static int macb_phylink_connect(struct macb *bp)
> netdev_err(dev, "Could not attach to PHY (%d)\n", ret);
> return ret;
> }
> + } else if (ret) {
> + netdev_err(dev, "Could not attach PHY (%d)\n", ret);
> + return ret;
> }
You can remove this "else if (ret)" branch and also:
if (ret) {
netdev_err(dev, "Could not attach PHY (%d)\n", ret);
return ret;
}
under "if (!dn || (ret && !macb_phy_handle_exists(dn)))" and have something
like:
static int macb_phylink_connect(struct macb *bp)
{
struct net_device *dev = bp->dev;
struct phy_device *phydev;
struct device_node *dn = bp->pdev->dev.of_node;
int ret;
if (dn)
ret = phylink_of_phy_connect(bp->phylink, dn, 0);
if (!dn || (ret && !macb_phy_handle_exists(dn))) {
phydev = phy_find_first(bp->mii_bus);
if (!phydev) {
netdev_err(dev, "no PHY found\n");
return -ENXIO;
}
/* attach the mac to the phy */
ret = phylink_connect_phy(bp->phylink, phydev);
}
if (ret) {
netdev_err(dev, "Could not attach PHY (%d)\n", ret);
return ret;
}
phylink_start(bp->phylink);
return 0;
}
>
> phylink_start(bp->phylink);
> --
> 2.17.1
>
>
prev parent reply other threads:[~2020-01-10 11:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 5:46 Milind Parab
2020-01-10 11:53 ` Claudiu.Beznea [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=91a5684d-9170-fdf6-3cd1-ae0636f3727b@microchip.com \
--to=claudiu.beznea@microchip.com \
--cc=Nicolas.Ferre@microchip.com \
--cc=a.fatoum@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=antoine.tenart@bootlin.com \
--cc=brad.mouring@ni.com \
--cc=davem@davemloft.net \
--cc=dkangude@cadence.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mparab@cadence.com \
--cc=netdev@vger.kernel.org \
--cc=pthombar@cadence.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
all inboxes | Powered by JetHome®