[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220310114434.3465481-3-o.rempel@pengutronix.de>
Date: Thu, 10 Mar 2022 12:44:33 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
netdev@...r.kernel.org, paskripkin@...il.com
Subject: [PATCH net-next v1 3/4] net: usb: asix: make use of mdiobus_get_phy and phy_connect_direct
In most cases we use own mdio bus, there is no need to create and store
string for the PHY address.
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
drivers/net/usb/asix.h | 1 -
drivers/net/usb/asix_devices.c | 19 ++++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index 691f37f45238..072760d76a72 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -184,7 +184,6 @@ struct asix_common_private {
struct mii_bus *mdio;
struct phy_device *phydev;
u16 phy_addr;
- char phy_name[20];
bool embd_phy;
u8 chipcode;
};
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 34622c1adacf..fb617eb551bb 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -661,15 +661,16 @@ static int ax88772_init_phy(struct usbnet *dev)
struct asix_common_private *priv = dev->driver_priv;
int ret;
- snprintf(priv->phy_name, sizeof(priv->phy_name), PHY_ID_FMT,
- priv->mdio->id, priv->phy_addr);
-
- priv->phydev = phy_connect(dev->net, priv->phy_name, &asix_adjust_link,
- PHY_INTERFACE_MODE_INTERNAL);
- if (IS_ERR(priv->phydev)) {
- netdev_err(dev->net, "Could not connect to PHY device %s\n",
- priv->phy_name);
- ret = PTR_ERR(priv->phydev);
+ priv->phydev = mdiobus_get_phy(priv->mdio, priv->phy_addr);
+ if (!priv->phydev) {
+ netdev_err(dev->net, "Could not find PHY\n");
+ return -ENODEV;
+ }
+
+ ret = phy_connect_direct(dev->net, priv->phydev, &asix_adjust_link,
+ PHY_INTERFACE_MODE_INTERNAL);
+ if (ret) {
+ netdev_err(dev->net, "Could not connect PHY\n");
return ret;
}
--
2.30.2
Powered by blists - more mailing lists