Skip to content

Commit d7a5502

Browse files
Dejin Zhengdavem330
authored andcommitted
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: Markus Elfring <[email protected]> Signed-off-by: Dejin Zheng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4dee15b commit d7a5502

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

drivers/net/ethernet/broadcom/bgmac-platform.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ static int bgmac_probe(struct platform_device *pdev)
172172
{
173173
struct device_node *np = pdev->dev.of_node;
174174
struct bgmac *bgmac;
175-
struct resource *regs;
176175
const u8 *mac_addr;
177176

178177
bgmac = bgmac_alloc(&pdev->dev);
@@ -202,31 +201,21 @@ static int bgmac_probe(struct platform_device *pdev)
202201
if (bgmac->irq < 0)
203202
return bgmac->irq;
204203

205-
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "amac_base");
206-
if (!regs) {
207-
dev_err(&pdev->dev, "Unable to obtain base resource\n");
208-
return -EINVAL;
209-
}
210-
211-
bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
204+
bgmac->plat.base =
205+
devm_platform_ioremap_resource_byname(pdev, "amac_base");
212206
if (IS_ERR(bgmac->plat.base))
213207
return PTR_ERR(bgmac->plat.base);
214208

215-
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
216-
if (regs) {
217-
bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
218-
if (IS_ERR(bgmac->plat.idm_base))
219-
return PTR_ERR(bgmac->plat.idm_base);
220-
bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK;
221-
}
209+
bgmac->plat.idm_base =
210+
devm_platform_ioremap_resource_byname(pdev, "idm_base");
211+
if (IS_ERR(bgmac->plat.idm_base))
212+
return PTR_ERR(bgmac->plat.idm_base);
213+
bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK;
222214

223-
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
224-
if (regs) {
225-
bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
226-
regs);
227-
if (IS_ERR(bgmac->plat.nicpm_base))
228-
return PTR_ERR(bgmac->plat.nicpm_base);
229-
}
215+
bgmac->plat.nicpm_base =
216+
devm_platform_ioremap_resource_byname(pdev, "nicpm_base");
217+
if (IS_ERR(bgmac->plat.nicpm_base))
218+
return PTR_ERR(bgmac->plat.nicpm_base);
230219

231220
bgmac->read = platform_bgmac_read;
232221
bgmac->write = platform_bgmac_write;

0 commit comments

Comments
 (0)