linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mscc: ocelot: reinterpret the return value of of_get_phy_mode
@ 2019-11-11 16:21 Horatiu Vultur
  2019-11-11 21:47 ` Woojung.Huh
  0 siblings, 1 reply; 2+ messages in thread
From: Horatiu Vultur @ 2019-11-11 16:21 UTC (permalink / raw)
  Cc: alexandre.belloni, UNGLinuxDriver, davem, andrew, netdev,
	linux-kernel, Horatiu Vultur

The commit 0c65b2b90d13c ("net: of_get_phy_mode: Change API to solve
int/unit warnings") updated the function of_get_phy_mode declaration.
Now it returns an error code and in case the node doesn't contain the
property 'phy-mode' or 'phy-connection-type' it returns -EINVAL.

In Ocelot the return code of the function was checked against -ENODEV
which is not true so it would failed to probe the port and then
eventually failed to probe the driver.

The fix consists in just checking if the function of_get_phy_mode returns
an error and in that case just fall back and use the interface
PHY_INTERFACE_MODE_NA.

This patch is based on the patch series:
https://patchwork.ozlabs.org/project/netdev/list/?series=141849

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/net/ethernet/mscc/ocelot_board.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 811599f32910..677701355da2 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -378,6 +378,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		struct phy *serdes;
 		void __iomem *regs;
 		char res_name[8];
+		int phy_err;
 		u32 port;
 
 		if (of_property_read_u32(portnp, "reg", &port))
@@ -410,9 +411,9 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		priv = container_of(ocelot_port, struct ocelot_port_private,
 				    port);
 
-		err = of_get_phy_mode(portnp, &phy_mode);
-		if (err && err != -ENODEV)
-			goto out_put_ports;
+		phy_err = of_get_phy_mode(portnp, &phy_mode);
+		if (phy_err)
+			phy_mode = PHY_INTERFACE_MODE_NA;
 
 		priv->phy_mode = phy_mode;
 
-- 
2.17.1


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

* RE: [PATCH] net: mscc: ocelot: reinterpret the return value of of_get_phy_mode
  2019-11-11 16:21 [PATCH] net: mscc: ocelot: reinterpret the return value of of_get_phy_mode Horatiu Vultur
@ 2019-11-11 21:47 ` Woojung.Huh
  0 siblings, 0 replies; 2+ messages in thread
From: Woojung.Huh @ 2019-11-11 21:47 UTC (permalink / raw)
  To: Horatiu.Vultur
  Cc: alexandre.belloni, UNGLinuxDriver, davem, andrew, netdev,
	linux-kernel, Horatiu.Vultur

Hi Horatiu,

> -		err = of_get_phy_mode(portnp, &phy_mode);
> -		if (err && err != -ENODEV)
> -			goto out_put_ports;
> +		phy_err = of_get_phy_mode(portnp, &phy_mode);
> +		if (phy_err)
> +			phy_mode = PHY_INTERFACE_MODE_NA;

Because of_get_phy_mode() would assign PHY_INTERFACE_MODE_NA to phy_mode
when error, may not need this "if (phy_err)" statement at all.

Thanks.
Woojung

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

end of thread, other threads:[~2019-11-11 21:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 16:21 [PATCH] net: mscc: ocelot: reinterpret the return value of of_get_phy_mode Horatiu Vultur
2019-11-11 21:47 ` Woojung.Huh

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