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

stmmac: introduce stmmac_get_platform_resources()

Refactor all code that deals with platform resources into it's
own get function. 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 4ed2d8fc
...@@ -262,33 +262,23 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -262,33 +262,23 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
} }
#endif /* CONFIG_OF */ #endif /* CONFIG_OF */
/** static int stmmac_get_platform_resources(struct platform_device *pdev,
* stmmac_pltfr_probe - platform driver probe. struct stmmac_resources *stmmac_res)
* @pdev: platform device pointer
* Description: platform_device probe function. It is to allocate
* the necessary platform resources, invoke custom helper (if required) and
* invoke the main probe function.
*/
int stmmac_pltfr_probe(struct platform_device *pdev)
{ {
struct stmmac_resources stmmac_res;
int ret = 0;
struct resource *res; struct resource *res;
struct device *dev = &pdev->dev;
struct plat_stmmacenet_data *plat_dat = NULL;
memset(&stmmac_res, 0, sizeof(stmmac_res)); memset(stmmac_res, 0, sizeof(*stmmac_res));
/* Get IRQ information early to have an ability to ask for deferred /* Get IRQ information early to have an ability to ask for deferred
* probe if needed before we went too far with resource allocation. * probe if needed before we went too far with resource allocation.
*/ */
stmmac_res.irq = platform_get_irq_byname(pdev, "macirq"); stmmac_res->irq = platform_get_irq_byname(pdev, "macirq");
if (stmmac_res.irq < 0) { if (stmmac_res->irq < 0) {
if (stmmac_res.irq != -EPROBE_DEFER) { if (stmmac_res->irq != -EPROBE_DEFER) {
dev_err(dev, dev_err(&pdev->dev,
"MAC IRQ configuration information not found\n"); "MAC IRQ configuration information not found\n");
} }
return stmmac_res.irq; return stmmac_res->irq;
} }
/* On some platforms e.g. SPEAr the wake up irq differs from the mac irq /* On some platforms e.g. SPEAr the wake up irq differs from the mac irq
...@@ -298,21 +288,41 @@ int stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -298,21 +288,41 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
* In case the wake up interrupt is not passed from the platform * In case the wake up interrupt is not passed from the platform
* so the driver will continue to use the mac irq (ndev->irq) * so the driver will continue to use the mac irq (ndev->irq)
*/ */
stmmac_res.wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq"); stmmac_res->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
if (stmmac_res.wol_irq < 0) { if (stmmac_res->wol_irq < 0) {
if (stmmac_res.wol_irq == -EPROBE_DEFER) if (stmmac_res->wol_irq == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
stmmac_res.wol_irq = stmmac_res.irq; stmmac_res->wol_irq = stmmac_res->irq;
} }
stmmac_res.lpi_irq = platform_get_irq_byname(pdev, "eth_lpi"); stmmac_res->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
if (stmmac_res.lpi_irq == -EPROBE_DEFER) if (stmmac_res->lpi_irq == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
stmmac_res.addr = devm_ioremap_resource(dev, res); stmmac_res->addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(stmmac_res.addr)) if (IS_ERR(stmmac_res->addr))
return PTR_ERR(stmmac_res.addr); return PTR_ERR(stmmac_res->addr);
return 0;
}
/**
* stmmac_pltfr_probe - platform driver probe.
* @pdev: platform device pointer
* Description: platform_device probe function. It is to allocate
* the necessary platform resources, invoke custom helper (if required) and
* invoke the main probe function.
*/
int stmmac_pltfr_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
struct stmmac_resources stmmac_res;
int ret;
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
return ret;
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac); ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
......
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