Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mido: mdio-mux-bcm-iproc: Use devm_platform_get_and_ioremap_resource()

Use devm_platform_get_and_ioremap_resource() to simplify
code and avoid a null-ptr-deref by checking 'res' in it.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yang Yingliang and committed by
David S. Miller
8a55a734 1f7096f0

+3 -4
+3 -4
drivers/net/mdio/mdio-mux-bcm-iproc.c
··· 187 187 return -ENOMEM; 188 188 md->dev = &pdev->dev; 189 189 190 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 190 + md->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 191 + if (IS_ERR(md->base)) 192 + return PTR_ERR(md->base); 191 193 if (res->start & 0xfff) { 192 194 /* For backward compatibility in case the 193 195 * base address is specified with an offset. ··· 198 196 res->start &= ~0xfff; 199 197 res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1; 200 198 } 201 - md->base = devm_ioremap_resource(&pdev->dev, res); 202 - if (IS_ERR(md->base)) 203 - return PTR_ERR(md->base); 204 199 205 200 md->mii_bus = devm_mdiobus_alloc(&pdev->dev); 206 201 if (!md->mii_bus) {