static int socfpga_dwmac_probe(struct platform_device *pdev) { struct plat_stmmacenet_data *plat_dat; struct stmmac_resources stmmac_res; struct device *dev = &pdev->dev; int ret; struct socfpga_dwmac *dwmac; struct net_device *ndev; struct stmmac_priv *stpriv; ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) return ret; plat_dat = 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; } ret = socfpga_dwmac_parse_data(dwmac, dev); if (ret) { dev_err(dev, "Unable to parse OF data\n"); goto err_remove_config_dt; } plat_dat->bsp_priv = dwmac; plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) goto err_remove_config_dt; ndev = platform_get_drvdata(pdev); stpriv = netdev_priv(ndev); /* The socfpga driver needs to control the stmmac reset to set the phy * mode. Create a copy of the core reset handle so it can be used by * the driver later. */ dwmac->stmmac_rst = stpriv->stmmac_rst; ret = socfpga_dwmac_set_phy_mode(dwmac); if (ret) goto err_dvr_remove; return 0; err_dvr_remove: stmmac_dvr_remove(&pdev->dev); err_remove_config_dt: stmmac_remove_config_dt(pdev, plat_dat); return ret; }
static void *socfpga_dwmac_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int ret; struct socfpga_dwmac *dwmac; dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); if (!dwmac) return ERR_PTR(-ENOMEM); ret = socfpga_dwmac_parse_data(dwmac, dev); if (ret) { dev_err(dev, "Unable to parse OF data\n"); return ERR_PTR(ret); } ret = socfpga_dwmac_setup(dwmac); if (ret) { dev_err(dev, "couldn't setup SoC glue (%d)\n", ret); return ERR_PTR(ret); } return dwmac; }