lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1387132925-18651-9-git-send-email-hauke@hauke-m.de>
Date:	Sun, 15 Dec 2013 19:42:05 +0100
From:	Hauke Mehrtens <hauke@...ke-m.de>
To:	davem@...emloft.net
Cc:	zambrano@...adcom.com, netdev@...r.kernel.org,
	Hauke Mehrtens <hauke@...ke-m.de>
Subject: [PATCH 8/8] b44: add dummy PHY device if we do not find any

The ADM6996L switches used on some routers do not return a valid value
when reading the PHY id register and Linux thinks there is not PHY at
all, but that is wrong. This created a dummy PHY and uses that instead.

Signed-off-by: Hauke Mehrtens <hauke@...ke-m.de>
---
 drivers/net/ethernet/broadcom/b44.c |   23 +++++++++++++++++++----
 drivers/net/ethernet/broadcom/b44.h |    3 +++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index b65a463..07e58c2 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2233,6 +2233,8 @@ static int b44_register_phy_one(struct b44 *bp)
 	struct ssb_device *sdev = bp->sdev;
 	struct phy_device *phydev;
 	int err;
+	struct phy_c45_device_ids c45_ids = {0};
+	struct ssb_sprom *sprom = &sdev->bus->sprom;
 
 	mii_bus = mdiobus_alloc();
 	if (!mii_bus) {
@@ -2266,10 +2268,23 @@ static int b44_register_phy_one(struct b44 *bp)
 	}
 
 	phydev = bp->mii_bus->phy_map[bp->phy_addr];
-	if (!phydev) {
-		dev_err(sdev->dev, "could not find PHY at %i\n", bp->phy_addr);
-		err = -ENODEV;
-		goto err_out_mdiobus_unregister;
+	if (!phydev &&
+	    (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
+		dev_info(sdev->dev, "could not find PHY at %i, create dummy one\n",
+			 bp->phy_addr);
+
+		phydev = phy_device_create(bp->mii_bus, bp->phy_addr, 0x0,
+					   false, &c45_ids);
+		if (IS_ERR(phydev)) {
+			err = PTR_ERR(phydev);
+			dev_err(sdev->dev, "Can not create dummy PHY\n");
+			goto err_out_mdiobus_unregister;
+		}
+		err = phy_device_register(phydev);
+		if (err) {
+			dev_err(sdev->dev, "failed to register MII bus\n");
+			goto err_out_mdiobus_unregister;
+		}
 	}
 
 	err = phy_connect_direct(bp->dev, phydev, &b44_adjust_link,
diff --git a/drivers/net/ethernet/broadcom/b44.h b/drivers/net/ethernet/broadcom/b44.h
index c5ec9b4..e6780fe 100644
--- a/drivers/net/ethernet/broadcom/b44.h
+++ b/drivers/net/ethernet/broadcom/b44.h
@@ -345,6 +345,9 @@ B44_STAT_REG_DECLARE
 	struct u64_stats_sync	syncp;
 };
 
+#define	B44_BOARDFLAG_ROBO		0x0010  /* Board has robo switch */
+#define	B44_BOARDFLAG_ADM		0x0080  /* Board has ADMtek switch */
+
 struct ssb_device;
 
 struct b44 {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ