Make use of devm_platform_get_and_ioremap_resource() provided by
driver core platform instead of duplicated analogue, dev_err() is
removed because it has been done in devm_ioremap_resource().

Signed-off-by: Wang ShaoBo <bobo.shaobow...@huawei.com>
---
 drivers/iio/adc/stm32-dfsdm-core.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/stm32-dfsdm-core.c 
b/drivers/iio/adc/stm32-dfsdm-core.c
index 0b8bea88b011..42a7377704a4 100644
--- a/drivers/iio/adc/stm32-dfsdm-core.c
+++ b/drivers/iio/adc/stm32-dfsdm-core.c
@@ -226,16 +226,13 @@ static int stm32_dfsdm_parse_of(struct platform_device 
*pdev,
        if (!node)
                return -EINVAL;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "Failed to get memory resource\n");
-               return -ENODEV;
-       }
-       priv->dfsdm.phys_base = res->start;
-       priv->dfsdm.base = devm_ioremap_resource(&pdev->dev, res);
+       priv->dfsdm.base = devm_platform_get_and_ioremap_resource(pdev, 0,
+                                                       &res);
        if (IS_ERR(priv->dfsdm.base))
                return PTR_ERR(priv->dfsdm.base);
 
+       priv->dfsdm.phys_base = res->start;
+
        /*
         * "dfsdm" clock is mandatory for DFSDM peripheral clocking.
         * "dfsdm" or "audio" clocks can be used as source clock for
-- 
2.17.1

Reply via email to