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

stmmac: clean up platform/of_match data retrieval

Refactor code to clearly separate probing non-dt versus dt. In the
non-dt case platform data must be supplied to probe successfully.
For dt the platform data structure is created and match data is
copied into it. Note that support for supplying platform data in
dt from AUXDATA is dropped as no users in mainline does this.

This change will allow dt dwmac-* drivers to call the config_dt()
function from probe to create the needed platform data struct and
retrieve common dt properties.
Signed-off-by: default avatarJoachim Eastwood <manabian@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0dacf3f6
...@@ -105,13 +105,20 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries) ...@@ -105,13 +105,20 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
* 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 int stmmac_probe_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat, struct plat_stmmacenet_data **plat_dat,
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;
const struct stmmac_of_data *data; const struct stmmac_of_data *data;
struct stmmac_dma_cfg *dma_cfg; struct stmmac_dma_cfg *dma_cfg;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
return -ENOMEM;
*plat_dat = plat;
data = of_device_get_match_data(&pdev->dev); data = of_device_get_match_data(&pdev->dev);
if (data) { if (data) {
plat->has_gmac = data->has_gmac; plat->has_gmac = data->has_gmac;
...@@ -180,6 +187,12 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -180,6 +187,12 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
*/ */
plat->maxmtu = JUMBO_LEN; plat->maxmtu = JUMBO_LEN;
/* Set default value for multicast hash bins */
plat->multicast_filter_bins = HASH_TABLE_SIZE;
/* Set default value for unicast filter entries */
plat->unicast_filter_entries = 1;
/* /*
* Currently only the properties needed on SPEAr600 * Currently only the properties needed on SPEAr600
* are provided. All other properties should be added * are provided. All other properties should be added
...@@ -242,7 +255,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -242,7 +255,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
} }
#else #else
static int stmmac_probe_config_dt(struct platform_device *pdev, static int stmmac_probe_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat, struct plat_stmmacenet_data **plat,
const char **mac) const char **mac)
{ {
return -ENOSYS; return -ENOSYS;
...@@ -301,15 +314,17 @@ int stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -301,15 +314,17 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
if (IS_ERR(stmmac_res.addr)) if (IS_ERR(stmmac_res.addr))
return PTR_ERR(stmmac_res.addr); return PTR_ERR(stmmac_res.addr);
if (pdev->dev.of_node) {
ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
if (ret) {
dev_err(&pdev->dev, "dt configuration failed\n");
return ret;
}
} else {
plat_dat = dev_get_platdata(&pdev->dev); plat_dat = dev_get_platdata(&pdev->dev);
if (!plat_dat)
plat_dat = devm_kzalloc(&pdev->dev,
sizeof(struct plat_stmmacenet_data),
GFP_KERNEL);
if (!plat_dat) { if (!plat_dat) {
pr_err("%s: ERROR: no memory", __func__); dev_err(&pdev->dev, "no platform data provided\n");
return -ENOMEM; return -EINVAL;
} }
/* Set default value for multicast hash bins */ /* Set default value for multicast hash bins */
...@@ -317,13 +332,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -317,13 +332,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
/* Set default value for unicast filter entries */ /* Set default value for unicast filter entries */
plat_dat->unicast_filter_entries = 1; plat_dat->unicast_filter_entries = 1;
if (pdev->dev.of_node) {
ret = stmmac_probe_config_dt(pdev, plat_dat, &stmmac_res.mac);
if (ret) {
pr_err("%s: main dt probe failed", __func__);
return ret;
}
} }
/* Custom setup (if needed) */ /* Custom setup (if needed) */
......
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