diff mbox series

[07/14] net: sunxi_emac: Switch to new U-Boot PHY API

Message ID 20230530225131.949721-7-marek.vasut+renesas@mailbox.org
State Accepted
Commit 83434e249f060ab4e1f57d6ec63c03d72eea50cf
Delegated to: Ramon Fried
Headers show
Series [01/14] net: eth-phy: staticize eth_phy_reset() | expand

Commit Message

Marek Vasut May 30, 2023, 10:51 p.m. UTC
Use new U-Boot phy_connect() API which also supports fixed PHYs.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@amd.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
---
 drivers/net/sunxi_emac.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Ramon Fried June 10, 2023, 11 a.m. UTC | #1
On Wed, May 31, 2023 at 1:51 AM Marek Vasut
<marek.vasut+renesas@mailbox.org> wrote:
>
> Use new U-Boot phy_connect() API which also supports fixed PHYs.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Michal Simek <michal.simek@amd.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Ramon Fried <rfried.dev@gmail.com>
> ---
>  drivers/net/sunxi_emac.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
> index ad9e1abd161..4c90d4b4981 100644
> --- a/drivers/net/sunxi_emac.c
> +++ b/drivers/net/sunxi_emac.c
> @@ -248,10 +248,10 @@ static int emac_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
>
>  static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev)
>  {
> -       int ret, mask = 0xffffffff;
> +       int ret, mask = -1;
>
>  #ifdef CONFIG_PHY_ADDR
> -       mask = 1 << CONFIG_PHY_ADDR;
> +       mask = CONFIG_PHY_ADDR;
>  #endif
>
>         priv->bus = mdio_alloc();
> @@ -269,11 +269,10 @@ static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev)
>         if (ret)
>                 return ret;
>
> -       priv->phydev = phy_find_by_mask(priv->bus, mask);
> +       priv->phydev = phy_connect(priv->bus, mask, dev, PHY_INTERFACE_MODE_MII);
>         if (!priv->phydev)
>                 return -ENODEV;
>
> -       phy_connect_dev(priv->phydev, dev, PHY_INTERFACE_MODE_MII);
>         phy_config(priv->phydev);
>
>         return 0;
> --
> 2.39.2
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index ad9e1abd161..4c90d4b4981 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -248,10 +248,10 @@  static int emac_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
 
 static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev)
 {
-	int ret, mask = 0xffffffff;
+	int ret, mask = -1;
 
 #ifdef CONFIG_PHY_ADDR
-	mask = 1 << CONFIG_PHY_ADDR;
+	mask = CONFIG_PHY_ADDR;
 #endif
 
 	priv->bus = mdio_alloc();
@@ -269,11 +269,10 @@  static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev)
 	if (ret)
 		return ret;
 
-	priv->phydev = phy_find_by_mask(priv->bus, mask);
+	priv->phydev = phy_connect(priv->bus, mask, dev, PHY_INTERFACE_MODE_MII);
 	if (!priv->phydev)
 		return -ENODEV;
 
-	phy_connect_dev(priv->phydev, dev, PHY_INTERFACE_MODE_MII);
 	phy_config(priv->phydev);
 
 	return 0;