summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-03-16 19:55:42 -0400
committerDavid S. Miller <davem@davemloft.net>2016-03-16 19:55:42 -0400
commitb4ab9d76b9e4a2ef36821b93b4cee48e3e68fe93 (patch)
treefa226a278d8b74975bb064c94409f72f85b3898f
parente8e56ffd9d2973398b60ece1f1bebb8d67b4d032 (diff)
parentb7d3e3d3d21a09f8e45043d548224000a8efe06a (diff)
Merge branch 'thunderx-mdio-fixes'
David Daney says: ==================== net/phy: Fixes for Cavium Thunder MDIO code. Previous patch set: commit 5fc7cf179449 ("net: thunderx: Cleanup PHY probing code.") commit 1eefee901fca ("phy: mdio-octeon: Refactor into two files/modules") commit 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.") Had several problems. We try to fix them here. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cavium/Kconfig2
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c26
-rw-r--r--drivers/net/phy/mdio-cavium.c4
3 files changed, 25 insertions, 7 deletions
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index 8fb84e69c30e..953aa408c384 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -35,7 +35,7 @@ config THUNDER_NIC_BGX
tristate "Thunder MAC interface driver (BGX)"
depends on 64BIT
select PHYLIB
- select MDIO_OCTEON
+ select MDIO_THUNDER
---help---
This driver supports programming and controlling of MAC
interface from NIC physical function driver.
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)
static int bgx_init_of_phy(struct bgx *bgx)
{
struct fwnode_handle *fwn;
+ struct device_node *node = NULL;
u8 lmac = 0;
- const char *mac;
device_for_each_child_node(&bgx->pdev->dev, fwn) {
struct phy_device *pd;
struct device_node *phy_np;
- struct device_node *node = to_of_node(fwn);
+ const char *mac;
/* Should always be an OF node. But if it is not, we
* cannot handle it, so exit the loop.
*/
+ node = to_of_node(fwn);
if (!node)
break;
@@ -1005,17 +1006,30 @@ static int bgx_init_of_phy(struct bgx *bgx)
/* Wait until the phy drivers are available */
pd = of_phy_find_device(phy_np);
if (!pd)
- return -EPROBE_DEFER;
+ goto defer;
bgx->lmac[lmac].phydev = pd;
}
lmac++;
- if (lmac == MAX_LMAC_PER_BGX) {
- of_node_put(node);
+ if (lmac == MAX_LMAC_PER_BGX)
break;
- }
}
+ of_node_put(node);
return 0;
+
+defer:
+ /* We are bailing out, try not to leak device reference counts
+ * for phy devices we may have already found.
+ */
+ while (lmac) {
+ if (bgx->lmac[lmac].phydev) {
+ put_device(&bgx->lmac[lmac].phydev->mdio.dev);
+ bgx->lmac[lmac].phydev = NULL;
+ }
+ lmac--;
+ }
+ of_node_put(node);
+ return -EPROBE_DEFER;
}
#else
diff --git a/drivers/net/phy/mdio-cavium.c b/drivers/net/phy/mdio-cavium.c
index e796ee121eac..6df2fa755bb4 100644
--- a/drivers/net/phy/mdio-cavium.c
+++ b/drivers/net/phy/mdio-cavium.c
@@ -147,3 +147,7 @@ int cavium_mdiobus_write(struct mii_bus *bus, int phy_id, int regnum, u16 val)
return 0;
}
EXPORT_SYMBOL(cavium_mdiobus_write);
+
+MODULE_DESCRIPTION("Common code for OCTEON and Thunder MDIO bus drivers");
+MODULE_AUTHOR("David Daney");
+MODULE_LICENSE("GPL");