Commit 96329a18 authored by Wei Yongjun's avatar Wei Yongjun Committed by David S. Miller

net: hns: fix return value check in hns_dsaf_get_cfg()

In case of error, function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 684a95c0
...@@ -114,9 +114,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -114,9 +114,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
dsaf_dev->sc_base = devm_ioremap_resource(&pdev->dev, dsaf_dev->sc_base = devm_ioremap_resource(&pdev->dev,
res); res);
if (!dsaf_dev->sc_base) { if (IS_ERR(dsaf_dev->sc_base)) {
dev_err(dsaf_dev->dev, "subctrl can not map!\n"); dev_err(dsaf_dev->dev, "subctrl can not map!\n");
return -ENOMEM; return PTR_ERR(dsaf_dev->sc_base);
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, res = platform_get_resource(pdev, IORESOURCE_MEM,
...@@ -128,9 +128,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -128,9 +128,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
dsaf_dev->sds_base = devm_ioremap_resource(&pdev->dev, dsaf_dev->sds_base = devm_ioremap_resource(&pdev->dev,
res); res);
if (!dsaf_dev->sds_base) { if (IS_ERR(dsaf_dev->sds_base)) {
dev_err(dsaf_dev->dev, "serdes-ctrl can not map!\n"); dev_err(dsaf_dev->dev, "serdes-ctrl can not map!\n");
return -ENOMEM; return PTR_ERR(dsaf_dev->sds_base);
} }
} else { } else {
dsaf_dev->sub_ctrl = syscon; dsaf_dev->sub_ctrl = syscon;
...@@ -146,9 +146,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -146,9 +146,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
} }
} }
dsaf_dev->ppe_base = devm_ioremap_resource(&pdev->dev, res); dsaf_dev->ppe_base = devm_ioremap_resource(&pdev->dev, res);
if (!dsaf_dev->ppe_base) { if (IS_ERR(dsaf_dev->ppe_base)) {
dev_err(dsaf_dev->dev, "ppe-base resource can not map!\n"); dev_err(dsaf_dev->dev, "ppe-base resource can not map!\n");
return -ENOMEM; return PTR_ERR(dsaf_dev->ppe_base);
} }
dsaf_dev->ppe_paddr = res->start; dsaf_dev->ppe_paddr = res->start;
...@@ -165,9 +165,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -165,9 +165,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
} }
} }
dsaf_dev->io_base = devm_ioremap_resource(&pdev->dev, res); dsaf_dev->io_base = devm_ioremap_resource(&pdev->dev, res);
if (!dsaf_dev->io_base) { if (IS_ERR(dsaf_dev->io_base)) {
dev_err(dsaf_dev->dev, "dsaf-base resource can not map!\n"); dev_err(dsaf_dev->dev, "dsaf-base resource can not map!\n");
return -ENOMEM; return PTR_ERR(dsaf_dev->io_base);
} }
} }
......
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