From: Andrew Lunn <andrew@lunn.ch>
To: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Cc: davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, git@xilinx.com,
Shravya Kumbham <shravya.kumbham@xilinx.com>
Subject: Re: [PATCH net-next] net: emaclite: Add error handling for of_address_ and phy read functions
Date: Tue, 3 Nov 2020 17:20:29 +0100 [thread overview]
Message-ID: <20201103162029.GK1042051@lunn.ch> (raw)
In-Reply-To: <1604410265-30246-1-git-send-email-radhey.shyam.pandey@xilinx.com>
On Tue, Nov 03, 2020 at 07:01:05PM +0530, Radhey Shyam Pandey wrote:
> From: Shravya Kumbham <shravya.kumbham@xilinx.com>
>
> Add ret variable, conditions to check the return value and it's error
> path for of_address_to_resource() and phy_read() functions.
>
> Addresses-Coverity: Event check_return value.
Hi Radhey
This is well out of scope of a Coverity fix, but looking at the patch
i noticed some bad things.
> @@ -923,7 +929,7 @@ static int xemaclite_open(struct net_device *dev)
> xemaclite_disable_interrupts(lp);
>
> if (lp->phy_node) {
> - u32 bmcr;
> + int bmcr;
>
> lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
> xemaclite_adjust_link, 0,
> @@ -945,6 +951,13 @@ static int xemaclite_open(struct net_device *dev)
>
> /* Restart auto negotiation */
> bmcr = phy_read(lp->phy_dev, MII_BMCR);
> + if (bmcr < 0) {
> + dev_err(&lp->ndev->dev, "phy_read failed\n");
> + phy_disconnect(lp->phy_dev);
> + lp->phy_dev = NULL;
> +
> + return bmcr;
> + }
> bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
> phy_write(lp->phy_dev, MII_BMCR, bmcr);
A MAC driver should not be touching the PHY. The call to
phy_set_max_speed() should prevent the PHY from advertising 1G speeds,
so there is no need to poke the advertise registers. And phy_start()
will start auto-get if it is enabled.
It would be nice if this code got cleaned up.
Andrew
next prev parent reply other threads:[~2020-11-03 16:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 13:31 Radhey Shyam Pandey
2020-11-03 16:20 ` Andrew Lunn [this message]
2020-11-07 19:35 ` Jakub Kicinski
2020-11-10 6:02 ` Radhey Shyam Pandey
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=20201103162029.GK1042051@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=git@xilinx.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=radhey.shyam.pandey@xilinx.com \
--cc=shravya.kumbham@xilinx.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
all inboxes | Powered by JetHome®