Skip to content

Commit

Permalink
net: gemini: Use devm_platform_get_and_ioremap_resource()
Browse files Browse the repository at this point in the history
Use devm_platform_get_and_ioremap_resource() to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yang Yingliang authored and David S. Miller committed Jun 7, 2021
1 parent 4fb473f commit ef91f79
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions drivers/net/ethernet/cortina/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2356,8 +2356,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct gemini_ethernet *geth;
struct net_device *netdev;
struct resource *gmacres;
struct resource *dmares;
struct device *parent;
unsigned int id;
int irq;
Expand Down Expand Up @@ -2390,24 +2388,18 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
port->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);

/* DMA memory */
dmares = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!dmares) {
dev_err(dev, "no DMA resource\n");
return -ENODEV;
}
port->dma_base = devm_ioremap_resource(dev, dmares);
if (IS_ERR(port->dma_base))
port->dma_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(port->dma_base)) {
dev_err(dev, "get DMA address failed\n");
return PTR_ERR(port->dma_base);
}

/* GMAC config memory */
gmacres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!gmacres) {
dev_err(dev, "no GMAC resource\n");
return -ENODEV;
}
port->gmac_base = devm_ioremap_resource(dev, gmacres);
if (IS_ERR(port->gmac_base))
port->gmac_base = devm_platform_get_and_ioremap_resource(pdev, 1, NULL);
if (IS_ERR(port->gmac_base)) {
dev_err(dev, "get GMAC address failed\n");
return PTR_ERR(port->gmac_base);
}

/* Interrupt */
irq = platform_get_irq(pdev, 0);
Expand Down Expand Up @@ -2502,10 +2494,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
if (ret)
goto unprepare;

netdev_info(netdev,
"irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
port->irq, &dmares->start,
&gmacres->start);
return 0;

unprepare:
Expand Down Expand Up @@ -2544,17 +2532,13 @@ static int gemini_ethernet_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct gemini_ethernet *geth;
unsigned int retry = 5;
struct resource *res;
u32 val;

/* Global registers */
geth = devm_kzalloc(dev, sizeof(*geth), GFP_KERNEL);
if (!geth)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENODEV;
geth->base = devm_ioremap_resource(dev, res);
geth->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(geth->base))
return PTR_ERR(geth->base);
geth->dev = dev;
Expand Down

0 comments on commit ef91f79

Please sign in to comment.