]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: stmmac: dwmac-sun8i: Balance internal PHY resource references
authorSamuel Holland <samuel@sholland.org>
Sun, 3 Jan 2021 11:17:42 +0000 (05:17 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Jan 2021 13:04:18 +0000 (14:04 +0100)
commitf0c95ef6c43d1fb27c54582fe402a57d936de9f6
tree7030beec238b9cfcc9bb22f67a229f962a5bae1e
parenta96b98eabd28ab9da2e436541a0bfd6d99d15e3a
net: stmmac: dwmac-sun8i: Balance internal PHY resource references

[ Upstream commit 529254216773acd5039c07aa18cf06fd1f9fccdd ]

While stmmac_pltfr_remove calls sun8i_dwmac_exit, the sun8i_dwmac_init
and sun8i_dwmac_exit functions are also called by the stmmac_platform
suspend/resume callbacks. They may be called many times during the
device's lifetime and should not release resources used by the driver.

Furthermore, there was no error handling in case registering the MDIO
mux failed during probe, and the EPHY clock was never released at all.

Fix all of these issues by moving the deinitialization code to a driver
removal callback. Also ensure the EPHY is powered down before removal.

Fixes: 634db83b8265 ("net: stmmac: dwmac-sun8i: Handle integrated/external MDIOs")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c