netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net v2] net: ftgmac100: refactor getting phy device handle
@ 2024-10-21  2:37 Jacky Chou
  2024-10-22  6:57 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Jacky Chou @ 2024-10-21  2:37 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel
  Cc: jacky_chou

The ftgmac100 supports NC-SI mode, dedicated PHY and fixed-link
PHY. The dedicated PHY is using the phy_handle property to get
phy device handle and the fixed-link phy is using the fixed-link
property to register a fixed-link phy device.

In of_phy_get_and_connect function, it help driver to get and register
these PHYs handle.
Therefore, here refactors this part by using of_phy_get_and_connect.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
v2:
  - enable mac asym pause support for fixed-link PHY
  - remove fixes information
---
 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 0b61f548fd18..8f4093f6d289 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [net v2] net: ftgmac100: refactor getting phy device handle
  2024-10-21  2:37 [net v2] net: ftgmac100: refactor getting phy device handle Jacky Chou
@ 2024-10-22  6:57 ` Simon Horman
  2024-10-22  7:13   ` 回覆: " Jacky Chou
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2024-10-22  6:57 UTC (permalink / raw)
  To: Jacky Chou
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Mon, Oct 21, 2024 at 10:37:05AM +0800, Jacky Chou wrote:
> The ftgmac100 supports NC-SI mode, dedicated PHY and fixed-link
> PHY. The dedicated PHY is using the phy_handle property to get
> phy device handle and the fixed-link phy is using the fixed-link
> property to register a fixed-link phy device.
> 
> In of_phy_get_and_connect function, it help driver to get and register
> these PHYs handle.
> Therefore, here refactors this part by using of_phy_get_and_connect.

Hi Jacky,

I understand the aim of this patch, and I think it is nice that we
can drop about 20 lines of code. But I did have some trouble understanding
the paragraph above. I wonder if the following is clearer:

  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

I agree that this is not a fix. And should not have a Fixes tag and so on.
But as such it should be targeted at net rather than net-next.

  Subject: [net-next vX] ...

The code themselves changes look good to me. But I think the two points
above, in combination, warrant a v3.

-- 
pw-bot: changes-requested

...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 回覆: [net v2] net: ftgmac100: refactor getting phy device handle
  2024-10-22  6:57 ` Simon Horman
@ 2024-10-22  7:13   ` Jacky Chou
  2024-10-22  7:34     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Jacky Chou @ 2024-10-22  7:13 UTC (permalink / raw)
  To: Simon Horman
  Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

Hi Simon

Thank you for your reply.

> > The ftgmac100 supports NC-SI mode, dedicated PHY and fixed-link PHY.
> > The dedicated PHY is using the phy_handle property to get phy device
> > handle and the fixed-link phy is using the fixed-link property to
> > register a fixed-link phy device.
> >
> > In of_phy_get_and_connect function, it help driver to get and register
> > these PHYs handle.
> > Therefore, here refactors this part by using of_phy_get_and_connect.
> 
> Hi Jacky,
> 
> I understand the aim of this patch, and I think it is nice that we can drop about
> 20 lines of code. But I did have some trouble understanding the paragraph
> above. I wonder if the following is clearer:
> 
>   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().
>

Agree. I will change the commit message.
Thank you for helping me fine-tune this message.

> >
> > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> > ---
> > v2:
> >   - enable mac asym pause support for fixed-link PHY
> >   - remove fixes information
> 
> I agree that this is not a fix. And should not have a Fixes tag and so on.
> But as such it should be targeted at net rather than net-next.
> 
>   Subject: [net-next vX] ...
> 
> The code themselves changes look good to me. But I think the two points above,
> in combination, warrant a v3.

I will send v3 patch to net-next tree.

Thanks,
Jacky

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 回覆: [net v2] net: ftgmac100: refactor getting phy device handle
  2024-10-22  7:13   ` 回覆: " Jacky Chou
@ 2024-10-22  7:34     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-10-22  7:34 UTC (permalink / raw)
  To: Jacky Chou
  Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Tue, Oct 22, 2024 at 07:13:56AM +0000, Jacky Chou wrote:
> Hi Simon
> 
> Thank you for your reply.
> 
> > > The ftgmac100 supports NC-SI mode, dedicated PHY and fixed-link PHY.
> > > The dedicated PHY is using the phy_handle property to get phy device
> > > handle and the fixed-link phy is using the fixed-link property to
> > > register a fixed-link phy device.
> > >
> > > In of_phy_get_and_connect function, it help driver to get and register
> > > these PHYs handle.
> > > Therefore, here refactors this part by using of_phy_get_and_connect.
> > 
> > Hi Jacky,
> > 
> > I understand the aim of this patch, and I think it is nice that we can drop about
> > 20 lines of code. But I did have some trouble understanding the paragraph
> > above. I wonder if the following is clearer:
> > 
> >   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().
> >
> 
> Agree. I will change the commit message.
> Thank you for helping me fine-tune this message.
> 
> > >
> > > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> > > ---
> > > v2:
> > >   - enable mac asym pause support for fixed-link PHY
> > >   - remove fixes information
> > 
> > I agree that this is not a fix. And should not have a Fixes tag and so on.
> > But as such it should be targeted at net rather than net-next.
> > 
> >   Subject: [net-next vX] ...
> > 
> > The code themselves changes look good to me. But I think the two points above,
> > in combination, warrant a v3.
> 
> I will send v3 patch to net-next tree.

Great, thanks Jacky.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-22  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21  2:37 [net v2] net: ftgmac100: refactor getting phy device handle Jacky Chou
2024-10-22  6:57 ` Simon Horman
2024-10-22  7:13   ` 回覆: " Jacky Chou
2024-10-22  7:34     ` Simon Horman

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).