aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index feed2318201b..967951582e03 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -974,17 +974,18 @@ static int bgx_init_acpi_phy(struct bgx *bgx)
974static int bgx_init_of_phy(struct bgx *bgx) 974static int bgx_init_of_phy(struct bgx *bgx)
975{ 975{
976 struct fwnode_handle *fwn; 976 struct fwnode_handle *fwn;
977 struct device_node *node = NULL;
977 u8 lmac = 0; 978 u8 lmac = 0;
978 const char *mac;
979 979
980 device_for_each_child_node(&bgx->pdev->dev, fwn) { 980 device_for_each_child_node(&bgx->pdev->dev, fwn) {
981 struct phy_device *pd; 981 struct phy_device *pd;
982 struct device_node *phy_np; 982 struct device_node *phy_np;
983 struct device_node *node = to_of_node(fwn); 983 const char *mac;
984 984
985 /* Should always be an OF node. But if it is not, we 985 /* Should always be an OF node. But if it is not, we
986 * cannot handle it, so exit the loop. 986 * cannot handle it, so exit the loop.
987 */ 987 */
988 node = to_of_node(fwn);
988 if (!node) 989 if (!node)
989 break; 990 break;
990 991
@@ -1005,17 +1006,30 @@ static int bgx_init_of_phy(struct bgx *bgx)
1005 /* Wait until the phy drivers are available */ 1006 /* Wait until the phy drivers are available */
1006 pd = of_phy_find_device(phy_np); 1007 pd = of_phy_find_device(phy_np);
1007 if (!pd) 1008 if (!pd)
1008 return -EPROBE_DEFER; 1009 goto defer;
1009 bgx->lmac[lmac].phydev = pd; 1010 bgx->lmac[lmac].phydev = pd;
1010 } 1011 }
1011 1012
1012 lmac++; 1013 lmac++;
1013 if (lmac == MAX_LMAC_PER_BGX) { 1014 if (lmac == MAX_LMAC_PER_BGX)
1014 of_node_put(node);
1015 break; 1015 break;
1016 }
1017 } 1016 }
1017 of_node_put(node);
1018 return 0; 1018 return 0;
1019
1020defer:
1021 /* We are bailing out, try not to leak device reference counts
1022 * for phy devices we may have already found.
1023 */
1024 while (lmac) {
1025 if (bgx->lmac[lmac].phydev) {
1026 put_device(&bgx->lmac[lmac].phydev->mdio.dev);
1027 bgx->lmac[lmac].phydev = NULL;
1028 }
1029 lmac--;
1030 }
1031 of_node_put(node);
1032 return -EPROBE_DEFER;
1019} 1033}
1020 1034
1021#else 1035#else