Commit b0003ead authored by Joachim Eastwood's avatar Joachim Eastwood Committed by David S. Miller

stmmac: make stmmac_probe_config_dt return the platform data struct

Since stmmac_probe_config_dt() allocates the platform data structure
it is cleaner if it just returned this structure directly. This
function will later be used in the probe function in dwmac-* drivers.
Signed-off-by: default avatarJoachim Eastwood <manabian@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f396cb01
...@@ -104,9 +104,8 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries) ...@@ -104,9 +104,8 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
* this function is to read the driver parameters from device-tree and * this function is to read the driver parameters from device-tree and
* set some private fields that will be used by the main at runtime. * set some private fields that will be used by the main at runtime.
*/ */
static int stmmac_probe_config_dt(struct platform_device *pdev, static struct plat_stmmacenet_data *
struct plat_stmmacenet_data **plat_dat, stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
const char **mac)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat; struct plat_stmmacenet_data *plat;
...@@ -115,9 +114,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -115,9 +114,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat) if (!plat)
return -ENOMEM; return ERR_PTR(-ENOMEM);
*plat_dat = plat;
data = of_device_get_match_data(&pdev->dev); data = of_device_get_match_data(&pdev->dev);
if (data) { if (data) {
...@@ -156,7 +153,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -156,7 +153,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
/* If phy-handle is not specified, check if we have a fixed-phy */ /* If phy-handle is not specified, check if we have a fixed-phy */
if (!plat->phy_node && of_phy_is_fixed_link(np)) { if (!plat->phy_node && of_phy_is_fixed_link(np)) {
if ((of_phy_register_fixed_link(np) < 0)) if ((of_phy_register_fixed_link(np) < 0))
return -ENODEV; return ERR_PTR(-ENODEV);
plat->phy_node = of_node_get(np); plat->phy_node = of_node_get(np);
} }
...@@ -233,7 +230,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -233,7 +230,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
GFP_KERNEL); GFP_KERNEL);
if (!dma_cfg) { if (!dma_cfg) {
of_node_put(np); of_node_put(np);
return -ENOMEM; return ERR_PTR(-ENOMEM);
} }
plat->dma_cfg = dma_cfg; plat->dma_cfg = dma_cfg;
of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl); of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
...@@ -251,14 +248,13 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -251,14 +248,13 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set."); pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set.");
} }
return 0; return plat;
} }
#else #else
static int stmmac_probe_config_dt(struct platform_device *pdev, static struct plat_stmmacenet_data *
struct plat_stmmacenet_data **plat, stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
const char **mac)
{ {
return -ENOSYS; return ERR_PTR(-ENOSYS);
} }
#endif /* CONFIG_OF */ #endif /* CONFIG_OF */
...@@ -325,10 +321,10 @@ int stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -325,10 +321,10 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
return ret; return ret;
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac); plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
if (ret) { if (IS_ERR(plat_dat)) {
dev_err(&pdev->dev, "dt configuration failed\n"); dev_err(&pdev->dev, "dt configuration failed\n");
return ret; return PTR_ERR(plat_dat);
} }
} else { } else {
plat_dat = dev_get_platdata(&pdev->dev); plat_dat = dev_get_platdata(&pdev->dev);
......
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