Skip to content

Commit 1734bef

Browse files
manabiandavem330
authored andcommitted
stmmac: add proper probe function to dwmac-meson
By using a few functions from stmmac_platform we can now create a proper probe function in this driver. By doing so we can drop the OF match data and simplify the overall driver. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f4f8dfd commit 1734bef

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,45 @@ static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed)
4747
writel(val, dwmac->reg);
4848
}
4949

50-
static void *meson6_dwmac_setup(struct platform_device *pdev)
50+
static int meson6_dwmac_probe(struct platform_device *pdev)
5151
{
52+
struct plat_stmmacenet_data *plat_dat;
53+
struct stmmac_resources stmmac_res;
5254
struct meson_dwmac *dwmac;
5355
struct resource *res;
56+
int ret;
57+
58+
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
59+
if (ret)
60+
return ret;
61+
62+
plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
63+
if (IS_ERR(plat_dat))
64+
return PTR_ERR(plat_dat);
5465

5566
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
5667
if (!dwmac)
57-
return ERR_PTR(-ENOMEM);
68+
return -ENOMEM;
5869

5970
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
6071
dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
6172
if (IS_ERR(dwmac->reg))
62-
return ERR_CAST(dwmac->reg);
73+
return PTR_ERR(dwmac->reg);
6374

64-
return dwmac;
65-
}
75+
plat_dat->bsp_priv = dwmac;
76+
plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;
6677

67-
static const struct stmmac_of_data meson6_dwmac_data = {
68-
.setup = meson6_dwmac_setup,
69-
.fix_mac_speed = meson6_dwmac_fix_mac_speed,
70-
};
78+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
79+
}
7180

7281
static const struct of_device_id meson6_dwmac_match[] = {
73-
{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
82+
{ .compatible = "amlogic,meson6-dwmac" },
7483
{ }
7584
};
7685
MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
7786

7887
static struct platform_driver meson6_dwmac_driver = {
79-
.probe = stmmac_pltfr_probe,
88+
.probe = meson6_dwmac_probe,
8089
.remove = stmmac_pltfr_remove,
8190
.driver = {
8291
.name = "meson6-dwmac",

0 commit comments

Comments
 (0)