[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230127014812.1656340-3-yoshihiro.shimoda.uh@renesas.com>
Date: Fri, 27 Jan 2023 10:48:10 +0900
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
To: linux@...linux.org.uk, andrew@...n.ch, hkallweit1@...il.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
Subject: [PATCH net-next v3 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling
Simplify struct phy *serdes handling by keeping the valiable in
the struct rswitch_device.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
---
drivers/net/ethernet/renesas/rswitch.c | 40 ++++++++++++--------------
drivers/net/ethernet/renesas/rswitch.h | 1 +
2 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 14fc0af304ce..b0c1ea72772e 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1222,49 +1222,40 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev)
phylink_destroy(rdev->phylink);
}
-static int rswitch_serdes_set_params(struct rswitch_device *rdev)
+static int rswitch_serdes_phy_get(struct rswitch_device *rdev)
{
struct device_node *port = rswitch_get_port_node(rdev);
struct phy *serdes;
- int err;
serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
of_node_put(port);
if (IS_ERR(serdes))
return PTR_ERR(serdes);
+ rdev->serdes = serdes;
+
+ return 0;
+}
+
+static int rswitch_serdes_set_params(struct rswitch_device *rdev)
+{
+ int err;
- err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET,
+ err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET,
rdev->etha->phy_interface);
if (err < 0)
return err;
- return phy_set_speed(serdes, rdev->etha->speed);
+ return phy_set_speed(rdev->serdes, rdev->etha->speed);
}
static int rswitch_serdes_init(struct rswitch_device *rdev)
{
- struct device_node *port = rswitch_get_port_node(rdev);
- struct phy *serdes;
-
- serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
- of_node_put(port);
- if (IS_ERR(serdes))
- return PTR_ERR(serdes);
-
- return phy_init(serdes);
+ return phy_init(rdev->serdes);
}
static int rswitch_serdes_deinit(struct rswitch_device *rdev)
{
- struct device_node *port = rswitch_get_port_node(rdev);
- struct phy *serdes;
-
- serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
- of_node_put(port);
- if (IS_ERR(serdes))
- return PTR_ERR(serdes);
-
- return phy_exit(serdes);
+ return phy_exit(rdev->serdes);
}
static int rswitch_ether_port_init_one(struct rswitch_device *rdev)
@@ -1286,6 +1277,10 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev)
if (err < 0)
goto err_phylink_init;
+ err = rswitch_serdes_phy_get(rdev);
+ if (err < 0)
+ goto err_serdes_phy_get;
+
err = rswitch_serdes_set_params(rdev);
if (err < 0)
goto err_serdes_set_params;
@@ -1293,6 +1288,7 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev)
return 0;
err_serdes_set_params:
+err_serdes_phy_get:
rswitch_phylink_deinit(rdev);
err_phylink_init:
diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h
index 49efb0f31c77..c79b1bdd8072 100644
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h
@@ -953,6 +953,7 @@ struct rswitch_device {
int port;
struct rswitch_etha *etha;
+ struct phy *serdes;
};
struct rswitch_mfwd_mac_table_entry {
--
2.25.1
Powered by blists - more mailing lists