]> git.baikalelectronics.ru Git - kernel.git/commit
net: fec: Fix phy_device lookup for phy_reset_after_clk_enable()
authorMarek Vasut <marex@denx.de>
Sat, 10 Oct 2020 09:10:00 +0000 (11:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 12 Oct 2020 21:16:30 +0000 (14:16 -0700)
commitaa762f68660b1698ac157a94e7f5be81e74011b1
tree88a77c2e4ebd2066a990caef146429dbd0faf012
parent91b012d3930ea65f3149dfa970436c7e72d48e21
net: fec: Fix phy_device lookup for phy_reset_after_clk_enable()

The phy_reset_after_clk_enable() is always called with ndev->phydev,
however that pointer may be NULL even though the PHY device instance
already exists and is sufficient to perform the PHY reset.

This condition happens in fec_open(), where the clock must be enabled
first, then the PHY must be reset, and then the PHY IDs can be read
out of the PHY.

If the PHY still is not bound to the MAC, but there is OF PHY node
and a matching PHY device instance already, use the OF PHY node to
obtain the PHY device instance, and then use that PHY device instance
when triggering the PHY reset.

Fixes: e1c48383dc1c ("net: fec: add phy_reset_after_clk_enable() support")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Richard Leitner <richard.leitner@skidata.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fec_main.c