Skip to content

Commit 061425d

Browse files
Bartosz Golaszewskikuba-moo
authored andcommitted
net: stmmac: dwmac-qco-ethqos: use devm_stmmac_probe_config_dt()
Significantly simplify the driver's probe() function by using the devres variant of stmmac_probe_config_dt(). This allows to drop the goto jumps entirely. The remove_new() callback now needs to be switched to stmmac_pltfr_remove_no_dt(). Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://lore.kernel.org/r/20230623100417.93592-10-brgl@bgdev.pl Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d740654 commit 061425d

1 file changed

Lines changed: 15 additions & 34 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
708708
if (ret)
709709
return ret;
710710

711-
plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
711+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
712712
if (IS_ERR(plat_dat)) {
713713
dev_err(dev, "dt configuration failed\n");
714714
return PTR_ERR(plat_dat);
@@ -717,10 +717,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
717717
plat_dat->clks_config = ethqos_clks_config;
718718

719719
ethqos = devm_kzalloc(dev, sizeof(*ethqos), GFP_KERNEL);
720-
if (!ethqos) {
721-
ret = -ENOMEM;
722-
goto out_config_dt;
723-
}
720+
if (!ethqos)
721+
return -ENOMEM;
724722

725723
ethqos->phy_mode = device_get_phy_mode(dev);
726724
switch (ethqos->phy_mode) {
@@ -734,19 +732,15 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
734732
ethqos->configure_func = ethqos_configure_sgmii;
735733
break;
736734
case -ENODEV:
737-
ret = -ENODEV;
738-
goto out_config_dt;
735+
return -ENODEV;
739736
default:
740-
ret = -EINVAL;
741-
goto out_config_dt;
737+
return -EINVAL;
742738
}
743739

744740
ethqos->pdev = pdev;
745741
ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii");
746-
if (IS_ERR(ethqos->rgmii_base)) {
747-
ret = PTR_ERR(ethqos->rgmii_base);
748-
goto out_config_dt;
749-
}
742+
if (IS_ERR(ethqos->rgmii_base))
743+
return PTR_ERR(ethqos->rgmii_base);
750744

751745
ethqos->mac_base = stmmac_res.addr;
752746

@@ -757,24 +751,20 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
757751
ethqos->has_emac_ge_3 = data->has_emac_ge_3;
758752

759753
ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
760-
if (IS_ERR(ethqos->link_clk)) {
761-
ret = PTR_ERR(ethqos->link_clk);
762-
goto out_config_dt;
763-
}
754+
if (IS_ERR(ethqos->link_clk))
755+
return PTR_ERR(ethqos->link_clk);
764756

765757
ret = ethqos_clks_config(ethqos, true);
766758
if (ret)
767-
goto out_config_dt;
759+
return ret;
768760

769761
ret = devm_add_action_or_reset(dev, ethqos_clks_disable, ethqos);
770762
if (ret)
771-
goto out_config_dt;
763+
return ret;
772764

773765
ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
774-
if (IS_ERR(ethqos->serdes_phy)) {
775-
ret = PTR_ERR(ethqos->serdes_phy);
776-
goto out_config_dt;
777-
}
766+
if (IS_ERR(ethqos->serdes_phy))
767+
return PTR_ERR(ethqos->serdes_phy);
778768

779769
ethqos->speed = SPEED_1000;
780770
ethqos_update_link_clk(ethqos, SPEED_1000);
@@ -797,16 +787,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
797787
plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
798788
}
799789

800-
ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
801-
if (ret)
802-
goto out_config_dt;
803-
804-
return ret;
805-
806-
out_config_dt:
807-
stmmac_remove_config_dt(pdev, plat_dat);
808-
809-
return ret;
790+
return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
810791
}
811792

812793
static const struct of_device_id qcom_ethqos_match[] = {
@@ -820,7 +801,7 @@ MODULE_DEVICE_TABLE(of, qcom_ethqos_match);
820801

821802
static struct platform_driver qcom_ethqos_driver = {
822803
.probe = qcom_ethqos_probe,
823-
.remove_new = stmmac_pltfr_remove,
804+
.remove_new = stmmac_pltfr_remove_no_dt,
824805
.driver = {
825806
.name = "qcom-ethqos",
826807
.pm = &stmmac_pltfr_pm_ops,

0 commit comments

Comments
 (0)