Commit d7a5502b authored by Dejin Zheng's avatar Dejin Zheng Committed by David S. Miller

net: broadcom: convert to devm_platform_ioremap_resource_byname()

Use the function devm_platform_ioremap_resource_byname() to simplify
source code which calls the functions platform_get_resource_byname()
and devm_ioremap_resource(). Remove also a few error messages which
became unnecessary with this software refactoring.
Suggested-by: default avatarMarkus Elfring <Markus.Elfring@web.de>
Signed-off-by: default avatarDejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4dee15b4
...@@ -172,7 +172,6 @@ static int bgmac_probe(struct platform_device *pdev) ...@@ -172,7 +172,6 @@ static int bgmac_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct bgmac *bgmac; struct bgmac *bgmac;
struct resource *regs;
const u8 *mac_addr; const u8 *mac_addr;
bgmac = bgmac_alloc(&pdev->dev); bgmac = bgmac_alloc(&pdev->dev);
...@@ -202,31 +201,21 @@ static int bgmac_probe(struct platform_device *pdev) ...@@ -202,31 +201,21 @@ static int bgmac_probe(struct platform_device *pdev)
if (bgmac->irq < 0) if (bgmac->irq < 0)
return bgmac->irq; return bgmac->irq;
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "amac_base"); bgmac->plat.base =
if (!regs) { devm_platform_ioremap_resource_byname(pdev, "amac_base");
dev_err(&pdev->dev, "Unable to obtain base resource\n");
return -EINVAL;
}
bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
if (IS_ERR(bgmac->plat.base)) if (IS_ERR(bgmac->plat.base))
return PTR_ERR(bgmac->plat.base); return PTR_ERR(bgmac->plat.base);
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base"); bgmac->plat.idm_base =
if (regs) { devm_platform_ioremap_resource_byname(pdev, "idm_base");
bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
if (IS_ERR(bgmac->plat.idm_base)) if (IS_ERR(bgmac->plat.idm_base))
return PTR_ERR(bgmac->plat.idm_base); return PTR_ERR(bgmac->plat.idm_base);
bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK; bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK;
}
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base"); bgmac->plat.nicpm_base =
if (regs) { devm_platform_ioremap_resource_byname(pdev, "nicpm_base");
bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
regs);
if (IS_ERR(bgmac->plat.nicpm_base)) if (IS_ERR(bgmac->plat.nicpm_base))
return PTR_ERR(bgmac->plat.nicpm_base); return PTR_ERR(bgmac->plat.nicpm_base);
}
bgmac->read = platform_bgmac_read; bgmac->read = platform_bgmac_read;
bgmac->write = platform_bgmac_write; bgmac->write = platform_bgmac_write;
......
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