From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: [PATCH net-next v2 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling
Date: Tue, 10 Jan 2023 14:02:04 +0900 [thread overview]
Message-ID: <20230110050206.116110-3-yoshihiro.shimoda.uh@renesas.com> (raw)
In-Reply-To: <20230110050206.116110-1-yoshihiro.shimoda.uh@renesas.com>
Simplify struct phy *serdes handling by keeping the valiable in
the struct rswitch_device.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.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 6441892636db..ca79ee168206 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1235,49 +1235,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)
@@ -1299,6 +1290,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;
@@ -1306,6 +1301,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 edbdd1b98d3d..d9a0be6666f5 100644
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h
@@ -941,6 +941,7 @@ struct rswitch_device {
int port;
struct rswitch_etha *etha;
+ struct phy *serdes;
};
struct rswitch_mfwd_mac_table_entry {
--
2.25.1
next prev parent reply other threads:[~2023-01-10 5:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 5:02 [PATCH net-next v2 0/4] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda
2023-01-10 5:02 ` [PATCH net-next v2 1/4] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda
2023-01-10 14:21 ` Arun.Ramadoss
2023-01-12 7:33 ` Yoshihiro Shimoda
2023-01-10 5:02 ` Yoshihiro Shimoda [this message]
2023-01-10 14:15 ` [PATCH net-next v2 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling Arun.Ramadoss
2023-01-12 7:32 ` Yoshihiro Shimoda
2023-01-10 5:02 ` [PATCH net-next v2 3/4] net: ethernet: renesas: rswitch: Enable ovr_host_interfaces Yoshihiro Shimoda
2023-01-10 5:02 ` [PATCH net-next v2 4/4] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda
2023-01-10 14:35 ` [PATCH net-next v2 0/4] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Russell King (Oracle)
2023-01-12 1:09 ` Yoshihiro Shimoda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230110050206.116110-3-yoshihiro.shimoda.uh@renesas.com \
--to=yoshihiro.shimoda.uh@renesas.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).