From: Andrey Smirnov Subject: [PATCH v2 09/13] thermal: qoriq: Convert driver to use devm_ioremap() Date: Fri, 22 Feb 2019 12:05:04 -0800 Message-ID: <20190222200508.26325-10-andrew.smirnov@gmail.com> References: <20190222200508.26325-1-andrew.smirnov@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190222200508.26325-1-andrew.smirnov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-pm@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Lucas Stach , Zhang Rui , Eduardo Valentin , Daniel Lezcano , linux-imx@nxp.com, linux-kernel@vger.kernel.org List-Id: linux-pm@vger.kernel.org Convert driver to use devm_ioremap() to simplify memory deallocation and error handling code. No functional change intended. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index a3ddb55740e4..4f9a2543f9c3 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -192,6 +192,7 @@ static int qoriq_tmu_probe(struct platform_device *pdev) struct qoriq_tmu_data *data; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; + struct resource *io; data = devm_kzalloc(dev, sizeof(struct qoriq_tmu_data), GFP_KERNEL); @@ -200,7 +201,13 @@ static int qoriq_tmu_probe(struct platform_device *pdev) data->little_endian = of_property_read_bool(np, "little-endian"); - data->regs = of_iomap(np, 0); + io = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!io) { + dev_err(dev, "Failed to get memory region\n"); + return -ENODEV; + } + + data->regs = devm_ioremap(dev, io->start, resource_size(io)); if (!data->regs) { dev_err(dev, "Failed to get memory region\n"); return -ENODEV; @@ -210,23 +217,17 @@ static int qoriq_tmu_probe(struct platform_device *pdev) ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */ if (ret < 0) - goto err_tmu; + return ret; ret = qoriq_tmu_register_tmu_zone(dev, data); if (ret < 0) { dev_err(dev, "Failed to register sensors\n"); - ret = -ENODEV; - goto err_iomap; + return -ENODEV; } platform_set_drvdata(pdev, data); return 0; - -err_tmu: - iounmap(data->regs); - - return ret; } static int qoriq_tmu_remove(struct platform_device *pdev) @@ -236,7 +237,6 @@ static int qoriq_tmu_remove(struct platform_device *pdev) /* Disable monitoring */ tmu_write(data, TMR_DISABLE, &data->regs->tmr); - iounmap(data->regs); platform_set_drvdata(pdev, NULL); return 0; -- 2.20.1