Commit 551022d6 authored by Jisheng Zhang's avatar Jisheng Zhang Committed by David S. Miller

net: stmmac: dwmac-meson8b: use devm_stmmac_probe_config_dt()

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: default avatarJisheng Zhang <jszhang@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 780b63ae
...@@ -400,33 +400,27 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) ...@@ -400,33 +400,27 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
if (ret) if (ret)
return 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)) if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat); return PTR_ERR(plat_dat);
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
if (!dwmac) { if (!dwmac)
ret = -ENOMEM; return -ENOMEM;
goto err_remove_config_dt;
}
dwmac->data = (const struct meson8b_dwmac_data *) dwmac->data = (const struct meson8b_dwmac_data *)
of_device_get_match_data(&pdev->dev); of_device_get_match_data(&pdev->dev);
if (!dwmac->data) { if (!dwmac->data)
ret = -EINVAL; return -EINVAL;
goto err_remove_config_dt;
}
dwmac->regs = devm_platform_ioremap_resource(pdev, 1); dwmac->regs = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(dwmac->regs)) { if (IS_ERR(dwmac->regs))
ret = PTR_ERR(dwmac->regs); return PTR_ERR(dwmac->regs);
goto err_remove_config_dt;
}
dwmac->dev = &pdev->dev; dwmac->dev = &pdev->dev;
ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode); ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode);
if (ret) { if (ret) {
dev_err(&pdev->dev, "missing phy-mode property\n"); 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 */ /* use 2ns as fallback since this value was previously hardcoded */
...@@ -448,53 +442,40 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) ...@@ -448,53 +442,40 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) { if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
dev_err(dwmac->dev, dev_err(dwmac->dev,
"The RGMII RX delay range is 0..3000ps in 200ps steps"); "The RGMII RX delay range is 0..3000ps in 200ps steps");
ret = -EINVAL; return -EINVAL;
goto err_remove_config_dt;
} }
} else { } else {
if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) { if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) {
dev_err(dwmac->dev, dev_err(dwmac->dev,
"The only allowed RGMII RX delays values are: 0ps, 2000ps"); "The only allowed RGMII RX delays values are: 0ps, 2000ps");
ret = -EINVAL; return -EINVAL;
goto err_remove_config_dt;
} }
} }
dwmac->timing_adj_clk = devm_clk_get_optional(dwmac->dev, dwmac->timing_adj_clk = devm_clk_get_optional(dwmac->dev,
"timing-adjustment"); "timing-adjustment");
if (IS_ERR(dwmac->timing_adj_clk)) { if (IS_ERR(dwmac->timing_adj_clk))
ret = PTR_ERR(dwmac->timing_adj_clk); return PTR_ERR(dwmac->timing_adj_clk);
goto err_remove_config_dt;
}
ret = meson8b_init_rgmii_delays(dwmac); ret = meson8b_init_rgmii_delays(dwmac);
if (ret) if (ret)
goto err_remove_config_dt; return ret;
ret = meson8b_init_rgmii_tx_clk(dwmac); ret = meson8b_init_rgmii_tx_clk(dwmac);
if (ret) if (ret)
goto err_remove_config_dt; return ret;
ret = dwmac->data->set_phy_mode(dwmac); ret = dwmac->data->set_phy_mode(dwmac);
if (ret) if (ret)
goto err_remove_config_dt; return ret;
ret = meson8b_init_prg_eth(dwmac); ret = meson8b_init_prg_eth(dwmac);
if (ret) if (ret)
goto err_remove_config_dt; return ret;
plat_dat->bsp_priv = dwmac; plat_dat->bsp_priv = dwmac;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); return 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;
} }
static const struct meson8b_dwmac_data meson8b_dwmac_data = { static const struct meson8b_dwmac_data meson8b_dwmac_data = {
...@@ -539,7 +520,7 @@ MODULE_DEVICE_TABLE(of, meson8b_dwmac_match); ...@@ -539,7 +520,7 @@ MODULE_DEVICE_TABLE(of, meson8b_dwmac_match);
static struct platform_driver meson8b_dwmac_driver = { static struct platform_driver meson8b_dwmac_driver = {
.probe = meson8b_dwmac_probe, .probe = meson8b_dwmac_probe,
.remove_new = stmmac_pltfr_remove, .remove_new = stmmac_pltfr_remove_no_dt,
.driver = { .driver = {
.name = "meson8b-dwmac", .name = "meson8b-dwmac",
.pm = &stmmac_pltfr_pm_ops, .pm = &stmmac_pltfr_pm_ops,
......
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