Commit ef91f798 authored by Yang Yingliang's avatar Yang Yingliang Committed by David S. Miller

net: gemini: Use devm_platform_get_and_ioremap_resource()

Use devm_platform_get_and_ioremap_resource() to simplify
code.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4fb473fe
...@@ -2356,8 +2356,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) ...@@ -2356,8 +2356,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct gemini_ethernet *geth; struct gemini_ethernet *geth;
struct net_device *netdev; struct net_device *netdev;
struct resource *gmacres;
struct resource *dmares;
struct device *parent; struct device *parent;
unsigned int id; unsigned int id;
int irq; int irq;
...@@ -2390,24 +2388,18 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) ...@@ -2390,24 +2388,18 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
port->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); port->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
/* DMA memory */ /* DMA memory */
dmares = platform_get_resource(pdev, IORESOURCE_MEM, 0); port->dma_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (!dmares) { if (IS_ERR(port->dma_base)) {
dev_err(dev, "no DMA resource\n"); dev_err(dev, "get DMA address failed\n");
return -ENODEV;
}
port->dma_base = devm_ioremap_resource(dev, dmares);
if (IS_ERR(port->dma_base))
return PTR_ERR(port->dma_base); return PTR_ERR(port->dma_base);
}
/* GMAC config memory */ /* GMAC config memory */
gmacres = platform_get_resource(pdev, IORESOURCE_MEM, 1); port->gmac_base = devm_platform_get_and_ioremap_resource(pdev, 1, NULL);
if (!gmacres) { if (IS_ERR(port->gmac_base)) {
dev_err(dev, "no GMAC resource\n"); dev_err(dev, "get GMAC address failed\n");
return -ENODEV;
}
port->gmac_base = devm_ioremap_resource(dev, gmacres);
if (IS_ERR(port->gmac_base))
return PTR_ERR(port->gmac_base); return PTR_ERR(port->gmac_base);
}
/* Interrupt */ /* Interrupt */
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -2502,10 +2494,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) ...@@ -2502,10 +2494,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
if (ret) if (ret)
goto unprepare; goto unprepare;
netdev_info(netdev,
"irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
port->irq, &dmares->start,
&gmacres->start);
return 0; return 0;
unprepare: unprepare:
...@@ -2544,17 +2532,13 @@ static int gemini_ethernet_probe(struct platform_device *pdev) ...@@ -2544,17 +2532,13 @@ static int gemini_ethernet_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct gemini_ethernet *geth; struct gemini_ethernet *geth;
unsigned int retry = 5; unsigned int retry = 5;
struct resource *res;
u32 val; u32 val;
/* Global registers */ /* Global registers */
geth = devm_kzalloc(dev, sizeof(*geth), GFP_KERNEL); geth = devm_kzalloc(dev, sizeof(*geth), GFP_KERNEL);
if (!geth) if (!geth)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); geth->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (!res)
return -ENODEV;
geth->base = devm_ioremap_resource(dev, res);
if (IS_ERR(geth->base)) if (IS_ERR(geth->base))
return PTR_ERR(geth->base); return PTR_ERR(geth->base);
geth->dev = dev; geth->dev = 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