Messages in this thread | | | Date | Tue, 3 Nov 2020 17:20:29 +0100 | From | Andrew Lunn <> | Subject | Re: [PATCH net-next] net: emaclite: Add error handling for of_address_ and phy read functions |
| |
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
| |