Russell pointed out there's a new devm_stmmac_probe_config_dt()
helper now when reviewing my starfive gmac error handling patch[1].
After greping the code, this nice helper was introduced by Bartosz in
[2], I think it's time to convert all dwmac users to this helper and
finally complete the TODO in [2] "but once all users of the old
stmmac_pltfr_remove() are converted to the devres helper, it will be
renamed back to stmmac_pltfr_remove() and the no_dt function removed."
Link: https://lore.kernel.org/netdev/[email protected]/ [1]
Link: https://lore.kernel.org/all/[email protected]/ [2]
Jisheng Zhang (22):
net: stmmac: dwmac-anarion: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-dwc-qos-eth: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-generic: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-generic: use devm_stmmac_pltfr_probe()
net: stmmac: dwmac-imx: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-ingenic: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-intel-plat: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-ipq806x: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-lpc18xx: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-mediatek: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-meson: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-meson8b: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-rk: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-socfpga: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-starfive: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-sti: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-stm32: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-sun8i: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-sunxi: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-tegra: use devm_stmmac_probe_config_dt()
net: stmmac: dwmac-visconti: use devm_stmmac_probe_config_dt()
net: stmmac: rename stmmac_pltfr_remove_no_dt to stmmac_pltfr_remove
.../ethernet/stmicro/stmmac/dwmac-anarion.c | 10 +---
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 15 ++----
.../ethernet/stmicro/stmmac/dwmac-generic.c | 15 +-----
.../net/ethernet/stmicro/stmmac/dwmac-imx.c | 13 ++---
.../ethernet/stmicro/stmmac/dwmac-ingenic.c | 33 ++++--------
.../stmicro/stmmac/dwmac-intel-plat.c | 25 +++------
.../ethernet/stmicro/stmmac/dwmac-ipq806x.c | 27 +++-------
.../ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 19 ++-----
.../ethernet/stmicro/stmmac/dwmac-mediatek.c | 6 +--
.../net/ethernet/stmicro/stmmac/dwmac-meson.c | 25 +++------
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 53 ++++++-------------
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 14 ++---
.../ethernet/stmicro/stmmac/dwmac-socfpga.c | 16 +++---
.../ethernet/stmicro/stmmac/dwmac-starfive.c | 10 +---
.../net/ethernet/stmicro/stmmac/dwmac-sti.c | 14 ++---
.../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 17 +++---
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 +--
.../net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 23 +++-----
.../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 10 ++--
.../ethernet/stmicro/stmmac/dwmac-visconti.c | 12 ++---
.../ethernet/stmicro/stmmac/stmmac_platform.c | 23 ++------
.../ethernet/stmicro/stmmac/stmmac_platform.h | 1 -
22 files changed, 110 insertions(+), 277 deletions(-)
--
2.40.1
Simplify the driver's probe() function by using the devres
variant of stmmac_probe_config_dt().
The calling of stmmac_pltfr_remove() now needs to be switched to
stmmac_pltfr_remove_no_dt().
Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 7580077383c0..1c37df6d22b3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -656,7 +656,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;
- plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
@@ -665,7 +665,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
ret = mediatek_dwmac_clks_config(priv_plat, true);
if (ret)
- goto err_remove_config_dt;
+ return ret;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
@@ -675,8 +675,6 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
err_drv_probe:
mediatek_dwmac_clks_config(priv_plat, false);
-err_remove_config_dt:
- stmmac_remove_config_dt(pdev, plat_dat);
return ret;
}
@@ -685,7 +683,7 @@ static void mediatek_dwmac_remove(struct platform_device *pdev)
{
struct mediatek_dwmac_plat_data *priv_plat = get_stmmac_bsp_priv(&pdev->dev);
- stmmac_pltfr_remove(pdev);
+ stmmac_pltfr_remove_no_dt(pdev);
mediatek_dwmac_clks_config(priv_plat, false);
}
--
2.40.1
Simplify the driver's probe() function by using the devres
variant of stmmac_probe_config_dt().
The remove_new() callback now needs to be switched to
stmmac_pltfr_remove_no_dt().
Signed-off-by: Jisheng Zhang <[email protected]>
---
.../ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 21 +++++--------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
index 18e84ba693a6..5d4936642de5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
@@ -37,7 +37,7 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;
- plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
@@ -46,8 +46,7 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
if (IS_ERR(reg)) {
dev_err(&pdev->dev, "syscon lookup failed\n");
- ret = PTR_ERR(reg);
- goto err_remove_config_dt;
+ return PTR_ERR(reg);
}
if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
@@ -56,23 +55,13 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
} else {
dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
- ret = -EINVAL;
- goto err_remove_config_dt;
+ return -EINVAL;
}
regmap_update_bits(reg, LPC18XX_CREG_CREG6,
LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
- ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
- if (ret)
- goto err_remove_config_dt;
-
- return 0;
-
-err_remove_config_dt:
- stmmac_remove_config_dt(pdev, plat_dat);
-
- return ret;
+ return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
}
static const struct of_device_id lpc18xx_dwmac_match[] = {
@@ -83,7 +72,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
static struct platform_driver lpc18xx_dwmac_driver = {
.probe = lpc18xx_dwmac_probe,
- .remove_new = stmmac_pltfr_remove,
+ .remove_new = stmmac_pltfr_remove_no_dt,
.driver = {
.name = "lpc18xx-dwmac",
.pm = &stmmac_pltfr_pm_ops,
--
2.40.1
Simplify the driver's probe() function by using the devres
variant of stmmac_probe_config_dt().
The calling of stmmac_pltfr_remove() now needs to be switched to
stmmac_pltfr_remove_no_dt().
Signed-off-by: Jisheng Zhang <[email protected]>
---
.../ethernet/stmicro/stmmac/dwmac-socfpga.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 7db176e8691f..6d5e45fb54c9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -400,21 +400,19 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;
- plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
- if (!dwmac) {
- ret = -ENOMEM;
- goto err_remove_config_dt;
- }
+ if (!dwmac)
+ return -ENOMEM;
dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
if (IS_ERR(dwmac->stmmac_ocp_rst)) {
ret = PTR_ERR(dwmac->stmmac_ocp_rst);
dev_err(dev, "error getting reset control of ocp %d\n", ret);
- goto err_remove_config_dt;
+ return ret;
}
reset_control_deassert(dwmac->stmmac_ocp_rst);
@@ -422,7 +420,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
ret = socfpga_dwmac_parse_data(dwmac, dev);
if (ret) {
dev_err(dev, "Unable to parse OF data\n");
- goto err_remove_config_dt;
+ return ret;
}
dwmac->ops = ops;
@@ -431,7 +429,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
- goto err_remove_config_dt;
+ return ret;
ndev = platform_get_drvdata(pdev);
stpriv = netdev_priv(ndev);
@@ -492,8 +490,6 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
err_dvr_remove:
stmmac_dvr_remove(&pdev->dev);
-err_remove_config_dt:
- stmmac_remove_config_dt(pdev, plat_dat);
return ret;
}
@@ -504,7 +500,7 @@ static void socfpga_dwmac_remove(struct platform_device *pdev)
struct stmmac_priv *priv = netdev_priv(ndev);
struct phylink_pcs *pcs = priv->hw->lynx_pcs;
- stmmac_pltfr_remove(pdev);
+ stmmac_pltfr_remove_no_dt(pdev);
lynx_pcs_destroy(pcs);
}
--
2.40.1
Simplify the driver's probe() function by using the devres
variant of stmmac_probe_config_dt().
The remove_new() callback now needs to be switched to
stmmac_pltfr_remove_no_dt().
Signed-off-by: Jisheng Zhang <[email protected]>
---
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 55 ++++++-------------
1 file changed, 18 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index 0b159dc0d5f6..37f249980929 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -400,33 +400,27 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;
- plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
- if (!dwmac) {
- ret = -ENOMEM;
- goto err_remove_config_dt;
- }
+ if (!dwmac)
+ return -ENOMEM;
dwmac->data = (const struct meson8b_dwmac_data *)
of_device_get_match_data(&pdev->dev);
- if (!dwmac->data) {
- ret = -EINVAL;
- goto err_remove_config_dt;
- }
+ if (!dwmac->data)
+ return -EINVAL;
dwmac->regs = devm_platform_ioremap_resource(pdev, 1);
- if (IS_ERR(dwmac->regs)) {
- ret = PTR_ERR(dwmac->regs);
- goto err_remove_config_dt;
- }
+ if (IS_ERR(dwmac->regs))
+ return PTR_ERR(dwmac->regs);
dwmac->dev = &pdev->dev;
ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode);
if (ret) {
dev_err(&pdev->dev, "missing phy-mode property\n");
- goto err_remove_config_dt;
+ return ret;
}
/* use 2ns as fallback since this value was previously hardcoded */
@@ -448,53 +442,40 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
dev_err(dwmac->dev,
"The RGMII RX delay range is 0..3000ps in 200ps steps");
- ret = -EINVAL;
- goto err_remove_config_dt;
+ return -EINVAL;
}
} else {
if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) {
dev_err(dwmac->dev,
"The only allowed RGMII RX delays values are: 0ps, 2000ps");
- ret = -EINVAL;
- goto err_remove_config_dt;
+ return -EINVAL;
}
}
dwmac->timing_adj_clk = devm_clk_get_optional(dwmac->dev,
"timing-adjustment");
- if (IS_ERR(dwmac->timing_adj_clk)) {
- ret = PTR_ERR(dwmac->timing_adj_clk);
- goto err_remove_config_dt;
- }
+ if (IS_ERR(dwmac->timing_adj_clk))
+ return PTR_ERR(dwmac->timing_adj_clk);
ret = meson8b_init_rgmii_delays(dwmac);
if (ret)
- goto err_remove_config_dt;
+ return ret;
ret = meson8b_init_rgmii_tx_clk(dwmac);
if (ret)
- goto err_remove_config_dt;
+ return ret;
ret = dwmac->data->set_phy_mode(dwmac);
if (ret)
- goto err_remove_config_dt;
+ return ret;
ret = meson8b_init_prg_eth(dwmac);
if (ret)
- goto err_remove_config_dt;
+ return ret;
plat_dat->bsp_priv = dwmac;
- ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
- if (ret)
- goto err_remove_config_dt;
-
- return 0;
-
-err_remove_config_dt:
- stmmac_remove_config_dt(pdev, plat_dat);
-
- return ret;
+ return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
}
static const struct meson8b_dwmac_data meson8b_dwmac_data = {
@@ -539,7 +520,7 @@ MODULE_DEVICE_TABLE(of, meson8b_dwmac_match);
static struct platform_driver meson8b_dwmac_driver = {
.probe = meson8b_dwmac_probe,
- .remove_new = stmmac_pltfr_remove,
+ .remove_new = stmmac_pltfr_remove_no_dt,
.driver = {
.name = "meson8b-dwmac",
.pm = &stmmac_pltfr_pm_ops,
--
2.40.1