[PATCH 2/2] iio: adc: lpc32xx_adc: Use devm_ioremap_resource()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



By using devm_ioremap_resource() the code can be simplified, as we
no longer need to check whether platform_get_resource() succeeded
or not, as this check is already performed in devm_ioremap_resource().

Also move devm_ioremap_resource() right after platform_get_resource()
for better readability. 

Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxx>
---
 drivers/iio/adc/lpc32xx_adc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c
index 0de709b..56fb704 100644
--- a/drivers/iio/adc/lpc32xx_adc.c
+++ b/drivers/iio/adc/lpc32xx_adc.c
@@ -139,9 +139,10 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
 	int irq;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get platform I/O memory\n");
-		return -ENXIO;
+	st->adc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(st->adc_base)) {
+		dev_err(&pdev->dev, "failed mapping memory\n");
+		return PTR_ERR(st->adc_base);
 	}
 
 	iodev = devm_iio_device_alloc(&pdev->dev, sizeof(*st));
@@ -150,12 +151,6 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
 
 	st = iio_priv(iodev);
 
-	st->adc_base = devm_ioremap(&pdev->dev, res->start,
-				    resource_size(res));
-	if (!st->adc_base) {
-		dev_err(&pdev->dev, "failed mapping memory\n");
-		return -EBUSY;
-	}
 
 	st->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(st->clk)) {
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux