Commit e0f0a5db authored by David S. Miller's avatar David S. Miller

Merge branch 'stmmac-errors'

Andrew Halaney says:

====================
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/20230629191725.1434142-1-ahalaney@redhat.com/
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)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 47b7acfb 27381e72
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_net.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <linux/property.h>
#include "stmmac.h" #include "stmmac.h"
#include "stmmac_platform.h" #include "stmmac_platform.h"
...@@ -104,7 +104,7 @@ struct qcom_ethqos { ...@@ -104,7 +104,7 @@ struct qcom_ethqos {
struct clk *link_clk; struct clk *link_clk;
struct phy *serdes_phy; struct phy *serdes_phy;
unsigned int speed; unsigned int speed;
int phy_mode; phy_interface_t phy_mode;
const struct ethqos_emac_por *por; const struct ethqos_emac_por *por;
unsigned int num_por; unsigned int num_por;
...@@ -706,12 +706,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -706,12 +706,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ret = stmmac_get_platform_resources(pdev, &stmmac_res); ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret) 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); plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat)) { if (IS_ERR(plat_dat)) {
dev_err(dev, "dt configuration failed\n"); return dev_err_probe(dev, PTR_ERR(plat_dat),
return PTR_ERR(plat_dat); "dt configuration failed\n");
} }
plat_dat->clks_config = ethqos_clks_config; plat_dat->clks_config = ethqos_clks_config;
...@@ -720,7 +721,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -720,7 +721,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
if (!ethqos) if (!ethqos)
return -ENOMEM; return -ENOMEM;
ethqos->phy_mode = device_get_phy_mode(dev); ret = of_get_phy_mode(np, &ethqos->phy_mode);
if (ret)
return dev_err_probe(dev, ret, "Failed to get phy mode\n");
switch (ethqos->phy_mode) { switch (ethqos->phy_mode) {
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_ID:
...@@ -731,16 +734,17 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -731,16 +734,17 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
case PHY_INTERFACE_MODE_SGMII: case PHY_INTERFACE_MODE_SGMII:
ethqos->configure_func = ethqos_configure_sgmii; ethqos->configure_func = ethqos_configure_sgmii;
break; break;
case -ENODEV:
return -ENODEV;
default: default:
dev_err(dev, "Unsupported phy mode %s\n",
phy_modes(ethqos->phy_mode));
return -EINVAL; return -EINVAL;
} }
ethqos->pdev = pdev; ethqos->pdev = pdev;
ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii"); ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii");
if (IS_ERR(ethqos->rgmii_base)) 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; ethqos->mac_base = stmmac_res.addr;
...@@ -752,7 +756,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -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"); ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
if (IS_ERR(ethqos->link_clk)) 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); ret = ethqos_clks_config(ethqos, true);
if (ret) if (ret)
...@@ -764,7 +769,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -764,7 +769,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes"); ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
if (IS_ERR(ethqos->serdes_phy)) 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->speed = SPEED_1000;
ethqos_update_link_clk(ethqos, SPEED_1000); ethqos_update_link_clk(ethqos, SPEED_1000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment