Re: [PATCH] thermal: st: Use devm_platform_ioremap_resource() in st_mmap_regmap_init()

From: Amit Kucheria
Date: Wed Sep 25 2019 - 10:26:09 EST


On Wed, Sep 18, 2019 at 12:43 PM Markus Elfring <Markus.Elfring@xxxxxx> wrote:
>
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Wed, 18 Sep 2019 21:32:14 +0200
>
> Simplify this function implementation by using a known wrapper function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>

Reviewed-by: Amit Kucheria <amit.kucheria@xxxxxxxxxx>

> ---
> drivers/thermal/st/st_thermal_memmap.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c
> index a824b78dabf8..d8ff46abd8eb 100644
> --- a/drivers/thermal/st/st_thermal_memmap.c
> +++ b/drivers/thermal/st/st_thermal_memmap.c
> @@ -121,15 +121,8 @@ static int st_mmap_regmap_init(struct st_thermal_sensor *sensor)
> {
> struct device *dev = sensor->dev;
> struct platform_device *pdev = to_platform_device(dev);
> - struct resource *res;
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res) {
> - dev_err(dev, "no memory resources defined\n");
> - return -ENODEV;
> - }
> -
> - sensor->mmio_base = devm_ioremap_resource(dev, res);
> + sensor->mmio_base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(sensor->mmio_base)) {
> dev_err(dev, "failed to remap IO\n");
> return PTR_ERR(sensor->mmio_base);
> --
> 2.23.0
>