From patchwork Wed Jul 18 07:25:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 142249 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp211708ljj; Wed, 18 Jul 2018 00:25:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcRrWkk5CFybx9KuvF1a8DXlYl4jYfixd/F2Sd8DKTbMkMO+f0/Ikr+/GjS9lAjBZRuAs1K X-Received: by 2002:a62:ce81:: with SMTP id y123-v6mr4086774pfg.95.1531898740239; Wed, 18 Jul 2018 00:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531898740; cv=none; d=google.com; s=arc-20160816; b=chp1WUcOJYdy9fGV05unsORnBC2B3uWiUGtHf3Z1yE5z2eMr4kIJ7Aghskvc5GgC0s sRiYUSj/0kzz1G08exvLN7hyZdPIE1lALkTm6etP1UdfATs/nHJtJeOUV3jNpeF15V35 LDkOqaQDIsuuO6vFyjAxxu/4kYovKkYkFT5rOHcq6T9tIycSpz/yZLxw4DP5BBLG8Z+b jUuC2xms51VaS9eFuIC6ZR+9+fZa3yrMb4a2kcsDghi4DXoSNImIF/OWFfOp9TgdIU8G hQ2q3ktDB0YdGzJjcKVXDiywz4bGXwdKDL4YeopN/Op8xdX1+U2jBFhhNrjh/AxpPGte rlag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=VD2olbd9oQC1RGmU9iprACti8KCCG3wIJjoyBgZ3IoM=; b=MhCe66wgRK6K4FVG6Xswdew5wjW7XApv4RJR0uQmW8oMp4ouY2fpcV+wlr9dt36/CY UM59h038qVa8uGxZopf7K5vNbIRp29sJ3RMruiMZwU8ToXrLhp00Gq7+yr0orZPUkaPB 9pHgLMH/FiSlICz1OyBwhA7jwkzItfN10j06E56n9SiJCaOyuoMQ9O0K2ynXBVmBukN2 d0HS8Jk/YcBO2d+EyJhnVcjRZIE5JW6yOFwnO7n3KBWRro4yHZWmfqAOxmzcfxs3Bqha u3vWklwL4Cr5ladGTcp8SPmgUnH/3IVv8DdyNHqLhoUW1BRO9xSu2S59vHO/UvpIB9ra /C4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M/Jo+vXV"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6-v6si2585736pgb.446.2018.07.18.00.25.39; Wed, 18 Jul 2018 00:25:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M/Jo+vXV"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729594AbeGRICD (ORCPT + 10 others); Wed, 18 Jul 2018 04:02:03 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45596 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729462AbeGRICC (ORCPT ); Wed, 18 Jul 2018 04:02:02 -0400 Received: by mail-wr1-f66.google.com with SMTP id c4-v6so3520936wrs.12 for ; Wed, 18 Jul 2018 00:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=VD2olbd9oQC1RGmU9iprACti8KCCG3wIJjoyBgZ3IoM=; b=M/Jo+vXV92GYMmp5IIJxWZp+PRsISVnNpXChlCaibp28Aj1WOgJc8ctyjRUcPy3qfy cSzhNz2CADP5c2t0MD6Iu1UWRNQIosmYqZnCdQWS4NBzRbV8cnsQjilvW/Vry1CwdHMY EIGhDWO2GSxqxyyj/UYxbngSBIs2Jz4Ccuxo0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=VD2olbd9oQC1RGmU9iprACti8KCCG3wIJjoyBgZ3IoM=; b=g4a5D79h5BiBfGZC9Hsoz2ghJrsa8FctjN9hj6HFuzQzDAJU4JRcrCBTlqPb2n0sTW KDwkvZwBPNuKCiGYajCVGJocWL+LyjqPvOlZ5QIIsss1Fxm2/Q112vXA6XQLfZ2csjPT KUfOuWS7uNT+LMPi0YiBVV4Iyrs0npM6QmTXyHmKJX4VMLLnjHqzJz+Q5BUz0l0pIXPC 996qipkv7EdpsnqJ6pmcjGFGCWL6G9IQsdmY5AFhhHI09u9WU1Au3jmRPOKlVxHiVDMn m3a2l/C+gzGTL9OpsdTH4MjbSioMWKd35XAjK/SlCNr59xxidSt4Xer+kZI9X3LITO4U cuYA== X-Gm-Message-State: AOUpUlFxlj1yq9K21lu25QaQd7wPJmGl/VlRHzxLZ3gxK+zjFmm3pTEK xabeV+yg2tgOJzmwGXBG8UObzw== X-Received: by 2002:adf:88e3:: with SMTP id g32-v6mr3270446wrg.62.1531898734754; Wed, 18 Jul 2018 00:25:34 -0700 (PDT) Received: from localhost ([49.248.170.255]) by smtp.gmail.com with ESMTPSA id q11-v6sm7220033wrp.58.2018.07.18.00.25.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 00:25:34 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v1 2/3] thermal: tsens: switch from of_iomap() to devm_ioremap_resource() Date: Wed, 18 Jul 2018 12:55:02 +0530 Message-Id: <4dd9f01c2b5d6988c5329062c25ae61747b42a32.1531898088.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org devm_ioremap_resources() automatically requests resources (so that the I/O region shows up in /proc/iomem) and devm_ wrappers do better error handling and unmapping of the I/O region when needed. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 25e7f24..6207d8d 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -127,13 +127,11 @@ static const struct regmap_config tsens_config = { int __init init_common(struct tsens_device *tmdev) { void __iomem *base; + struct resource *res; struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); if (!op) return -EINVAL; - base = of_iomap(tmdev->dev->of_node, 0); - if (!base) - return -EINVAL; /* The driver only uses the TM register address space for now */ if (op->num_resources > 1) { @@ -143,11 +141,14 @@ int __init init_common(struct tsens_device *tmdev) tmdev->tm_offset = 0x1000; } + res = platform_get_resource(op, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&op->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config); - if (IS_ERR(tmdev->map)) { - iounmap(base); + if (IS_ERR(tmdev->map)) return PTR_ERR(tmdev->map); - } return 0; }