net: stmmac: dwmac-qcom-ethqos: Improve error handling
Subsystems (6)
v2 cover net: stmmac: dwmac-qcom-ethqos: Improve error handling
This series includes some very minor quality of life patches in the error handling.
I recently ran into a few issues where these patches would have made my life easier (messing with the devicetree, dependent driver of this failing, and incorrect kernel configs resulting in this driver not probing).
v1: https://lore.kernel.org/netdev/[email protected]/
Changes since v1:
* Collect tags (Andrew Lunn)
* Switch to of_get_phy_mode() (Andrew Lunn)
* Follow netdev patch submission process (net-next subject, wait until merge window is open) (Simon)
Andrew Halaney (3):
net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over
device_get_phy_mode()
net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe()
net: stmmac: dwmac-qcom-ethqos: Log more errors in probe
.../stmicro/stmmac/dwmac-qcom-ethqos.c | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.41.0
PATCH v2 1/3 net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()
Since this driver only uses devicetree, let's move over to of_get_phy_mode(). That API has an explicit error return and produces a phy_interface_t directly instead of an int when representing the phy mode.
---
Changes since v1:
* Convert to using of_get_phy_mode() instead of continuing to use device_get_phy_mode() (Andrew Lunn)
.../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5 -5
@@ -4,10 +4,10 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/of_net.h> #include <linux/platform_device.h> #include <linux/phy.h> #include <linux/phy/phy.h> -#include <linux/property.h> #include "stmmac.h" #include "stmmac_platform.h"
@@ -104,7 +104,7 @@ struct qcom_ethqos {struct clk *link_clk;struct phy *serdes_phy;unsigned int speed; -int phy_mode; +phy_interface_t phy_mode;const struct ethqos_emac_por *por;unsigned int num_por;
@@ -720,7 +720,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)if (!ethqos)return -ENOMEM ; - ethqos->phy_mode =device_get_phy_mode (dev); + ret =of_get_phy_mode (np, ðqos->phy_mode); +if (ret) +return dev_err_probe (dev, ret,"Failed to get phy mode\n" );switch (ethqos->phy_mode) {case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :
@@ -731,8 +733,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)case PHY_INTERFACE_MODE_SGMII : ethqos->configure_func = ethqos_configure_sgmii;break ; -case -ENODEV : -return -ENODEV ;default :return -EINVAL ; }
Signature · 1 line
2.41.0
Re: [PATCH net-next v2 1/3] net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()
Quoted 6 lines · Andrew Halaney
Since this driver only uses devicetree, let's move over to
of_get_phy_mode(). That API has an explicit error return and produces aphy_interface_tdirectly instead of an int when representing the phy mode.Signed-off-by Andrew Halaney <[email protected]>
Andrew
PATCH v2 2/3 net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe()
In reply to Andrew HalaneyUsing dev_err_probe() logs to devices_deferred which is helpful when debugging.
---
Changes since v1:
* Collect tags (Andrew Lunn)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2 -2
@@ -710,8 +710,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat =devm_stmmac_probe_config_dt (pdev, stmmac_res.mac);if (IS_ERR (plat_dat)) { -dev_err (dev,"dt configuration failed\n" ); -return PTR_ERR (plat_dat); +return dev_err_probe (dev,PTR_ERR (plat_dat), +"dt configuration failed\n" ); } plat_dat->clks_config = ethqos_clks_config;
Signature · 1 line
2.41.0
PATCH v2 3/3 net: stmmac: dwmac-qcom-ethqos: Log more errors in probe
In reply to Andrew HalaneyThese are useful to see when debugging a probe failure.
---
Changes since v1:
* No changes
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10 -4
@@ -706,7 +706,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ret =stmmac_get_platform_resources (pdev, &stmmac_res);if (ret) -return ret; +return dev_err_probe (dev, ret, +"Failed to get platform resources\n" ); plat_dat =devm_stmmac_probe_config_dt (pdev, stmmac_res.mac);if (IS_ERR (plat_dat)) {
@@ -734,13 +735,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->configure_func = ethqos_configure_sgmii;break ;default : +dev_err (dev,"Unsupported phy mode %s\n" , +phy_modes (ethqos->phy_mode));return -EINVAL ; } ethqos->pdev = pdev; ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" );if (IS_ERR (ethqos->rgmii_base)) -return PTR_ERR (ethqos->rgmii_base); +return dev_err_probe (dev,PTR_ERR (ethqos->rgmii_base), +"Failed to map rgmii resource\n" ); ethqos->mac_base = stmmac_res.addr;
@@ -752,7 +756,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->link_clk =devm_clk_get (dev, data->link_clk_name ?:"rgmii" );if (IS_ERR (ethqos->link_clk)) -return PTR_ERR (ethqos->link_clk); +return dev_err_probe (dev,PTR_ERR (ethqos->link_clk), +"Failed to get link_clk\n" ); ret =ethqos_clks_config (ethqos, true);if (ret)
@@ -764,7 +769,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->serdes_phy =devm_phy_optional_get (dev,"serdes" );if (IS_ERR (ethqos->serdes_phy)) -return PTR_ERR (ethqos->serdes_phy); +return dev_err_probe (dev,PTR_ERR (ethqos->serdes_phy), +"Failed to get serdes phy\n" ); ethqos->speed =SPEED_1000 ;ethqos_update_link_clk (ethqos,SPEED_1000 );
Signature · 1 line
2.41.0
Re: [PATCH net-next v2 3/3] net: stmmac: dwmac-qcom-ethqos: Log more errors in probe
Quoted 3 lines · Andrew Halaney
These are useful to see when debugging a probe failure.
Signed-off-by Andrew Halaney <[email protected]>
Andrew
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 9 lines · On Mon, 10 Jul 2023 15:06:36 -0500 you wrote:
This series includes some very minor quality of life patches in the error handling.
I recently ran into a few issues where these patches would have made my life easier (messing with the devicetree, dependent driver of this failing, and incorrect kernel configs resulting in this driver not probing).
[...]
Here is the summary with links:
- [net-next,v2,1/3] net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()
https://git.kernel.org/netdev/net-next/c/a8aa20a64ef2 - [net-next,v2,2/3] net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe() https://git.kernel.org/netdev/net-next/c/b2f3d915b4fe - [net-next,v2,3/3] net: stmmac: dwmac-qcom-ethqos: Log more errors in probe https://git.kernel.org/netdev/net-next/c/27381e72a2db
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html