diff mbox series

[net-next,v5,3/5] net: renesas: rswitch: Add host_interfaces setting

Message ID 20230201131454.1928136-4-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Accepted
Commit 0df024d0f1d3e556e38e5418fc3577a2c7263764
Delegated to: Netdev Maintainers
Headers show
Series net: renesas: rswitch: Modify initialization for SERDES and PHY | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: s.shtylyov@omp.ru
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 39 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yoshihiro Shimoda Feb. 1, 2023, 1:14 p.m. UTC
Set phydev->host_interfaces before calling of_phy_connect() to
configure the PHY with the information of host_interfaces.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 479499f9fcb5..f8b3a81c0447 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1178,6 +1178,7 @@  static int rswitch_phy_device_init(struct rswitch_device *rdev)
 {
 	struct phy_device *phydev;
 	struct device_node *phy;
+	int err = -ENOENT;
 
 	if (!rdev->np_port)
 		return -ENODEV;
@@ -1186,11 +1187,18 @@  static int rswitch_phy_device_init(struct rswitch_device *rdev)
 	if (!phy)
 		return -ENODEV;
 
+	/* Set phydev->host_interfaces before calling of_phy_connect() to
+	 * configure the PHY with the information of host_interfaces.
+	 */
+	phydev = of_phy_find_device(phy);
+	if (!phydev)
+		goto out;
+	__set_bit(rdev->etha->phy_interface, phydev->host_interfaces);
+
 	phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
 				rdev->etha->phy_interface);
-	of_node_put(phy);
 	if (!phydev)
-		return -ENOENT;
+		goto out;
 
 	phy_set_max_speed(phydev, SPEED_2500);
 	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
@@ -1201,7 +1209,11 @@  static int rswitch_phy_device_init(struct rswitch_device *rdev)
 
 	phy_attached_info(phydev);
 
-	return 0;
+	err = 0;
+out:
+	of_node_put(phy);
+
+	return err;
 }
 
 static void rswitch_phy_device_deinit(struct rswitch_device *rdev)