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

net: davinci_emac: 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: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aced6d37
...@@ -1814,13 +1814,12 @@ static int davinci_emac_probe(struct platform_device *pdev) ...@@ -1814,13 +1814,12 @@ static int davinci_emac_probe(struct platform_device *pdev)
priv->bus_freq_mhz = (u32)(emac_bus_frequency / 1000000); priv->bus_freq_mhz = (u32)(emac_bus_frequency / 1000000);
/* Get EMAC platform data */ /* Get EMAC platform data */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->remap_addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
priv->emac_base_phys = res->start + pdata->ctrl_reg_offset;
priv->remap_addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->remap_addr)) { if (IS_ERR(priv->remap_addr)) {
rc = PTR_ERR(priv->remap_addr); rc = PTR_ERR(priv->remap_addr);
goto no_pdata; goto no_pdata;
} }
priv->emac_base_phys = res->start + pdata->ctrl_reg_offset;
res_ctrl = platform_get_resource(pdev, IORESOURCE_MEM, 1); res_ctrl = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res_ctrl) { if (res_ctrl) {
......
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