diff mbox series

[net-next,v3] net: ftgmac100: refactor getting phy device handle

Message ID 20241022084214.1261174-1-jacky_chou@aspeedtech.com (mailing list archive)
State Accepted
Commit 4dbc8d6d05b7d977cf7997d3fcd6cfd74ba9b4de
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] net: ftgmac100: refactor getting phy device handle | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 40 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-23--12-00 (tests: 777)

Commit Message

Jacky Chou Oct. 22, 2024, 8:42 a.m. UTC
Consolidate the handling of dedicated PHY and fixed-link phy by taking
advantage of logic in of_phy_get_and_connect() which handles both of
these cases, rather than open coding the same logic in ftgmac100_probe().

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
v2:
  - enable mac asym pause support for fixed-link PHY
  - remove fixes information
v3:
  - Adjust the commit message
---
 drivers/net/ethernet/faraday/ftgmac100.c | 28 +++++-------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

Comments

Simon Horman Oct. 24, 2024, 8:57 a.m. UTC | #1
+ Russell

On Tue, Oct 22, 2024 at 04:42:14PM +0800, Jacky Chou wrote:
> Consolidate the handling of dedicated PHY and fixed-link phy by taking
> advantage of logic in of_phy_get_and_connect() which handles both of
> these cases, rather than open coding the same logic in ftgmac100_probe().
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
> v2:
>   - enable mac asym pause support for fixed-link PHY
>   - remove fixes information
> v3:
>   - Adjust the commit message

Thanks for the updates.

Probably this should also be reviewed by Andrew or Russell (CCed).
But it looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 28 +++++-------------------
>  1 file changed, 5 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 10c1a2f11000..17ec35e75a65 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1918,35 +1918,17 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev, "Connecting PHY failed\n");
>  			goto err_phy_connect;
>  		}
> -	} else if (np && of_phy_is_fixed_link(np)) {
> -		struct phy_device *phy;
> -
> -		err = of_phy_register_fixed_link(np);
> -		if (err) {
> -			dev_err(&pdev->dev, "Failed to register fixed PHY\n");
> -			goto err_phy_connect;
> -		}
> -
> -		phy = of_phy_get_and_connect(priv->netdev, np,
> -					     &ftgmac100_adjust_link);
> -		if (!phy) {
> -			dev_err(&pdev->dev, "Failed to connect to fixed PHY\n");
> -			of_phy_deregister_fixed_link(np);
> -			err = -EINVAL;
> -			goto err_phy_connect;
> -		}
> -
> -		/* Display what we found */
> -		phy_attached_info(phy);
> -	} else if (np && of_get_property(np, "phy-handle", NULL)) {
> +	} else if (np && (of_phy_is_fixed_link(np) ||
> +			  of_get_property(np, "phy-handle", NULL))) {
>  		struct phy_device *phy;
>  
>  		/* Support "mdio"/"phy" child nodes for ast2400/2500 with
>  		 * an embedded MDIO controller. Automatically scan the DTS for
>  		 * available PHYs and register them.
>  		 */
> -		if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
> -		    of_device_is_compatible(np, "aspeed,ast2500-mac")) {
> +		if (of_get_property(np, "phy-handle", NULL) &&
> +		    (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
> +		     of_device_is_compatible(np, "aspeed,ast2500-mac"))) {
>  			err = ftgmac100_setup_mdio(netdev);
>  			if (err)
>  				goto err_setup_mdio;
> -- 
> 2.25.1
> 
>
Andrew Lunn Oct. 24, 2024, 7:42 p.m. UTC | #2
On Tue, Oct 22, 2024 at 04:42:14PM +0800, Jacky Chou wrote:
> Consolidate the handling of dedicated PHY and fixed-link phy by taking
> advantage of logic in of_phy_get_and_connect() which handles both of
> these cases, rather than open coding the same logic in ftgmac100_probe().
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
> v2:
>   - enable mac asym pause support for fixed-link PHY
>   - remove fixes information
> v3:
>   - Adjust the commit message

It takes a bit of effort to see it is correct, but it looks O.K. to
me.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org Oct. 29, 2024, 10:50 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Oct 2024 16:42:14 +0800 you wrote:
> Consolidate the handling of dedicated PHY and fixed-link phy by taking
> advantage of logic in of_phy_get_and_connect() which handles both of
> these cases, rather than open coding the same logic in ftgmac100_probe().
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
> v2:
>   - enable mac asym pause support for fixed-link PHY
>   - remove fixes information
> v3:
>   - Adjust the commit message
> 
> [...]

Here is the summary with links:
  - [net-next,v3] net: ftgmac100: refactor getting phy device handle
    https://git.kernel.org/netdev/net-next/c/4dbc8d6d05b7

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 10c1a2f11000..17ec35e75a65 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1918,35 +1918,17 @@  static int ftgmac100_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "Connecting PHY failed\n");
 			goto err_phy_connect;
 		}
-	} else if (np && of_phy_is_fixed_link(np)) {
-		struct phy_device *phy;
-
-		err = of_phy_register_fixed_link(np);
-		if (err) {
-			dev_err(&pdev->dev, "Failed to register fixed PHY\n");
-			goto err_phy_connect;
-		}
-
-		phy = of_phy_get_and_connect(priv->netdev, np,
-					     &ftgmac100_adjust_link);
-		if (!phy) {
-			dev_err(&pdev->dev, "Failed to connect to fixed PHY\n");
-			of_phy_deregister_fixed_link(np);
-			err = -EINVAL;
-			goto err_phy_connect;
-		}
-
-		/* Display what we found */
-		phy_attached_info(phy);
-	} else if (np && of_get_property(np, "phy-handle", NULL)) {
+	} else if (np && (of_phy_is_fixed_link(np) ||
+			  of_get_property(np, "phy-handle", NULL))) {
 		struct phy_device *phy;
 
 		/* Support "mdio"/"phy" child nodes for ast2400/2500 with
 		 * an embedded MDIO controller. Automatically scan the DTS for
 		 * available PHYs and register them.
 		 */
-		if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
-		    of_device_is_compatible(np, "aspeed,ast2500-mac")) {
+		if (of_get_property(np, "phy-handle", NULL) &&
+		    (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
+		     of_device_is_compatible(np, "aspeed,ast2500-mac"))) {
 			err = ftgmac100_setup_mdio(netdev);
 			if (err)
 				goto err_setup_mdio;