summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2017-05-16 15:26:12 +0000
committerJonathan Cameron <jic23@kernel.org>2017-06-03 10:52:31 +0100
commit1454e15bc28ba94aa5d6b31a83a42d5c03af2a6d (patch)
treed43e49ed59da745c4b01a61597c5a4584d1a287d /drivers/iio
parent948588e25b8af5e66962ed3f53e1cae1656fa5af (diff)
iio: adc: mxs-lradc: Fix return value check in mxs_lradc_adc_probe()
In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Also add NULL test for iores. Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/mxs-lradc-adc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index b0c7d8ee5cb8..6888167ca1e6 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -718,9 +718,12 @@ static int mxs_lradc_adc_probe(struct platform_device *pdev)
adc->dev = dev;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!iores)
+ return -EINVAL;
+
adc->base = devm_ioremap(dev, iores->start, resource_size(iores));
- if (IS_ERR(adc->base))
- return PTR_ERR(adc->base);
+ if (!adc->base)
+ return -ENOMEM;
init_completion(&adc->completion);
spin_lock_init(&adc->lock);