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]
Date:   Thu,  3 Jan 2019 02:10:30 +0100
From:   Marek Vasut <marex@...x.de>
To:     netdev@...r.kernel.org
Cc:     Marek Vasut <marex@...x.de>,
        "David S . Miller" <davem@...emloft.net>,
        Nisar Sayed <Nisar.Sayed@...rochip.com>,
        Woojung Huh <Woojung.Huh@...rochip.com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        linux-usb@...r.kernel.org
Subject: [PATCH 09/19] usbnet: smsc95xx: Connect to phydev

Add code to detect and connect to PHY. The internal PHY of the SMSC95xx
is a regular SMSC LAN8700 and the driver only supports the internal PHY,
so just use the SMSC PHY driver to configure the PHY. Note that the
driver does a lot of extra configuration of the PHY, which is left in
to avoid breakage. Some of the extra configuration is sorted out by
later patches in this series.

Signed-off-by: Marek Vasut <marex@...x.de>
Cc: David S. Miller <davem@...emloft.net>
Cc: Nisar Sayed <Nisar.Sayed@...rochip.com>
Cc: Woojung Huh <Woojung.Huh@...rochip.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>
Cc: linux-usb@...r.kernel.org
To: netdev@...r.kernel.org
---
 drivers/net/usb/smsc95xx.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 2cd5e1d34559..ce61be8ee32b 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -78,6 +78,7 @@ struct smsc95xx_priv {
 	struct delayed_work carrier_check;
 	struct usbnet *dev;
 	struct mii_bus *mii_bus;
+	struct phy_device *phydev;
 };
 
 static bool turbo_mode = true;
@@ -960,6 +961,11 @@ static int smsc95xx_start_rx_path(struct usbnet *dev)
 	return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
 }
 
+
+static void smsc95xx_adjust_link(struct net_device *netdev)
+{
+}
+
 static int smsc95xx_phy_initialize(struct usbnet *dev)
 {
 	int bmcr, ret, timeout = 0;
@@ -1308,6 +1314,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	if (ret)
 		goto err_mdiobus_alloc;
 
+	ret = mdiobus_register(bus);
+	if (ret)
+		goto err_mdiobus_register;
+
 	/* Initialize MII structure */
 	dev->mii.dev = dev->net;
 	dev->mii.mdio_read = smsc95xx_mdio_read;
@@ -1316,9 +1326,24 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	dev->mii.reg_num_mask = 0x1f;
 	dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID;
 
-	ret = mdiobus_register(bus);
-	if (ret)
+	/* Connect to PHY */
+	pdata->phydev = phy_find_first(pdata->mii_bus);
+	if (!pdata->phydev) {
+		netdev_err(dev->net, "no PHY found\n");
+		ret = -EIO;
 		goto err_mdiobus_register;
+	}
+
+	ret = phy_connect_direct(dev->net, pdata->phydev,
+				 &smsc95xx_adjust_link,
+				 PHY_INTERFACE_MODE_MII);
+	if (ret) {
+		netdev_err(dev->net, "Could not connect to PHY device\n");
+		goto err_mdiobus_register;
+	}
+
+	genphy_resume(pdata->phydev);
+	phy_start(pdata->phydev);
 
 	ret = smsc95xx_reset_post(dev);
 	if (ret)
-- 
2.19.2

Powered by blists - more mailing lists