From patchwork Thu Jul 26 10:33:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 10545591 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B707F112B for ; Thu, 26 Jul 2018 10:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A55DA2A4B5 for ; Thu, 26 Jul 2018 10:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 996222ADF6; Thu, 26 Jul 2018 10:33:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 865BE2A4B5 for ; Thu, 26 Jul 2018 10:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729370AbeGZLt4 (ORCPT ); Thu, 26 Jul 2018 07:49:56 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33139 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729107AbeGZLt4 (ORCPT ); Thu, 26 Jul 2018 07:49:56 -0400 Received: by mail-wr1-f67.google.com with SMTP id g6-v6so1202685wrp.0 for ; Thu, 26 Jul 2018 03:33:42 -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=7pdKkXszJl0Y74TWXh6gdA8KIIImBRTHTJ1Z9RN0dvg=; b=Fhi4Ct/bj4yBxlkbsu/bgpQOl38iLOTF6THsInYunPXq3OR8wghp/qpuILwTIc/7ls usASnw3IVoVeBZvGIfqRJLAc6KRMJULsxnKne8r9HGPv6PvX5gib4c8KhjQ8uDGMFqIF XMmk78yAf6eBbPx1OfM+Vgww16XG9Bm5jluFo= 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=7pdKkXszJl0Y74TWXh6gdA8KIIImBRTHTJ1Z9RN0dvg=; b=mW4o5cJtV6U5Y3Z8y5B5OR0GKxZIGffcXnTE1ZzNokbLyuMjvsAMz2mcNt5ZipAPK1 z2DJZhR2h0B1MOSoFQVKw7/5BAeSscaUgLBCkRsZ98zc35BFq/B1S6ms1Rpd0Iu0dkPW gnjIH75CRhhUuXZ8nEKBHHaEMRXh/7vvn3pD45rRQ38l09lla64fE1DxNQuuvUcWj2EW 6iEIhWEeDSBKwMMdLUyC6V9XnK1KbXQOp0N0Q08QMoi5HSARJMbQw8fPyfA0RdV+482P msu8hZifLphi21uY7vLaK1YOIPB29/DfcNww2rjn02+ZyGjXEVta1VE59mWhyI65LvS4 pCug== X-Gm-Message-State: AOUpUlGd1CzqsbIN3p/pb5i/OkddHFR280HPJJF2o7TYdxVUcbQ6+hmE pB/lQqdsq0XzCTzKlro7NEx8Ow== X-Google-Smtp-Source: AAOMgpf0xMjlSxZene1uZ8E1PEOaAydk+2kAI+x7mnHgUpvHTxRBxEKH5gT+ApiiGP0FCPRVniipDA== X-Received: by 2002:a5d:6841:: with SMTP id o1-v6mr1124857wrw.159.1532601222160; Thu, 26 Jul 2018 03:33:42 -0700 (PDT) Received: from localhost ([49.248.197.57]) by smtp.gmail.com with ESMTPSA id b6-v6sm1520458wru.66.2018.07.26.03.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 03:33:41 -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 v2 2/3] thermal: tsens: switch from of_iomap() to devm_ioremap_resource() Date: Thu, 26 Jul 2018 16:03:09 +0530 Message-Id: X-Mailer: git-send-email 2.17.GIT In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 25e7f247b027..6207d8d92351 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; }