Skip to content

Commit

Permalink
stmmac: introduce stmmac_get_platform_resources()
Browse files Browse the repository at this point in the history
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: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Joachim Eastwood authored and David S. Miller committed Jul 21, 2015
1 parent 4ed2d8f commit f396cb0
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
Original file line number Diff line number Diff line change
@@ -262,33 +262,23 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
}
#endif /* CONFIG_OF */

/**
* 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)
static int stmmac_get_platform_resources(struct platform_device *pdev,
struct stmmac_resources *stmmac_res)
{
struct stmmac_resources stmmac_res;
int ret = 0;
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
* probe if needed before we went too far with resource allocation.
*/
stmmac_res.irq = platform_get_irq_byname(pdev, "macirq");
if (stmmac_res.irq < 0) {
if (stmmac_res.irq != -EPROBE_DEFER) {
dev_err(dev,
stmmac_res->irq = platform_get_irq_byname(pdev, "macirq");
if (stmmac_res->irq < 0) {
if (stmmac_res->irq != -EPROBE_DEFER) {
dev_err(&pdev->dev,
"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
@@ -298,21 +288,41 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
* In case the wake up interrupt is not passed from the platform
* so the driver will continue to use the mac irq (ndev->irq)
*/
stmmac_res.wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
if (stmmac_res.wol_irq < 0) {
if (stmmac_res.wol_irq == -EPROBE_DEFER)
stmmac_res->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
if (stmmac_res->wol_irq < 0) {
if (stmmac_res->wol_irq == -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");
if (stmmac_res.lpi_irq == -EPROBE_DEFER)
stmmac_res->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
if (stmmac_res->lpi_irq == -EPROBE_DEFER)
return -EPROBE_DEFER;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
stmmac_res.addr = devm_ioremap_resource(dev, res);
if (IS_ERR(stmmac_res.addr))
return PTR_ERR(stmmac_res.addr);
stmmac_res->addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_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) {
ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);

0 comments on commit f396cb0

Please sign in to comment.