diff mbox series

[-next] iio: adc: stm32-dfsdm: Use devm_platform_get_and_ioremap_resource()

Message ID 20200918083142.32816-1-bobo.shaobowang@huawei.com
State New
Headers show
Series [-next] iio: adc: stm32-dfsdm: Use devm_platform_get_and_ioremap_resource() | expand

Commit Message

Wang ShaoBo Sept. 18, 2020, 8:31 a.m. UTC
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.shaobowang@huawei.com>
---
 drivers/iio/adc/stm32-dfsdm-core.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Jonathan Cameron Sept. 23, 2020, 8:54 p.m. UTC | #1
On Fri, 18 Sep 2020 16:31:42 +0800
Wang ShaoBo <bobo.shaobowang@huawei.com> wrote:

> 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.shaobowang@huawei.com>

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to see if they can find any problems.

Thanks,

Jonathan

> ---
>  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
diff mbox series

Patch

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