Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2417311ybv; Mon, 24 Feb 2020 04:59:50 -0800 (PST) X-Google-Smtp-Source: APXvYqx9E1dPfJlJV9BaUGUpkPgrQtq+fXNebY9KcaXbdX67oo96E6J+HNot0YFPTa0+gkox7dvn X-Received: by 2002:a9d:6443:: with SMTP id m3mr38841285otl.20.1582549190683; Mon, 24 Feb 2020 04:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582549190; cv=none; d=google.com; s=arc-20160816; b=URZG85JwsIM/2AXn24Nzu5pUfk1C0yuR1MxfefCjr1TfwFutMTaEjKrzlCvQ779C3m tkozr4RNBz3kyO12b/G+BguQ5YAEvvlcKmpZwJMK4F3CTNp8g5MJ0ufeN1GxgC+WzANF hj6+7oNRyFqDAsUZkevBoXwqOTL2KMjhw9jLwI74csz1ePe+4kmM1YZKAfcDLstbm4SY U8leMIRHuragBUIe+8vdXsyVx5xNotw7k9but2u5lJX/8tmuXlo4umAlck6tbXIbNE7g xqQTUBz5mxLcoPEaCZhmS4MTHkl1cUFR9C7o8URSs1HC44NH43Na285g7Pb+dHXpQkH8 SscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YyTMBW/LB/vN3eCREReLdM0mvM31rEOT+ERAgjHVtRY=; b=i0gQhgCr41BkUI0++g6RHg8QfUz1WV38O6JKDNcjKCTALC87MYeytnk/Rc5CpGUvlR IR+27avYYeALQTHQCCOYl4ngRZu1dhaK6goeuDzSqR5BJGCLouSYMgM+iN6OjkTgiRKz c5p01FdUHzSf/pFt9D7LJFrBko+glREGEgE3kK3E4vGr8D5HTwoK/N5X8cbePbKzuIwj wCIwOCrc4pGv8V6luIWJwq+RrPexJWB/IVIi4PIIHKoh0vgaIbS3Fu6QLwebyXBA9Dlb wX6rK//d30XIt4d6FQbVJBgb3OYr5T3nbY1v1L6xwaM9wTOEBlbhahXVQEwI6wp2tG4g 9VqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZWSboEM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 z8si5963999otp.79.2020.02.24.04.59.38; Mon, 24 Feb 2020 04:59:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=JZWSboEM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727711AbgBXM7U (ORCPT + 99 others); Mon, 24 Feb 2020 07:59:20 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40945 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727714AbgBXM7T (ORCPT ); Mon, 24 Feb 2020 07:59:19 -0500 Received: by mail-pf1-f193.google.com with SMTP id b185so5335381pfb.7 for ; Mon, 24 Feb 2020 04:59:18 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=YyTMBW/LB/vN3eCREReLdM0mvM31rEOT+ERAgjHVtRY=; b=JZWSboEMZ1DD76EgGmGkJwuOffVfjE7SlTjAdOeMsMIBQwLbx0kdb8cyKjlpnEogsV 5yk0rrXYLM3jCeJJySFyWt/RdE5ttiRJCU9O+IOsVGz9hxiLRXjhnDtxbdIRqdi1csel bbOZYlUiRh00qVjFpuCQsy5cCPFHJuWCHKmIRlTYW6nNFCgroLKjxzFRxjtsDbf/XKsT 5O5WsGI8NklYrhNpufzN5w5kEK6/3viAihInhJSClEH/e3jntLVUiYBkQz+vOMRPZF+t 7/5+z7kQzyyekDYT7tnnDG8VzCyROFRzzx56Rc7Nl7ElaXkEHp0pO+Ny52485wtpU6Rg C0gw== 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:mime-version:content-transfer-encoding; bh=YyTMBW/LB/vN3eCREReLdM0mvM31rEOT+ERAgjHVtRY=; b=kcu4yo0pswlEeTOSlpWzvosNfhKGLSmnxhmPblAScQJyddQHSV1h+O9A3JQy3p8Jyr PDY+3aAuF9q9pQfrf/mZ0wKSgJicTIyDgxVbntbthFzA8BTO9ByZf3xmHhTVpUM4Eufa 6sX4btpJpxIIhHxn4RvDHL5M0FbolquQaaref6otGJC2ML8KWbZdmcL/5hfWvktVwg5t rP60SB3/HPb0JtLSHu1PZ65VV3XMxw9I7BLCneNp0EZMCxAT/z9O5gaKH5v4wYxvGnFg Wnfotw/W3GXZbop7w7RSV9rkvzaStEQmhXJ5E0LBePQ6B9VwCt7Ffngd+vKiY6lgbmB9 iYLQ== X-Gm-Message-State: APjAAAUuQIm/1LnddMGK1T+GKMK4Szgge5i7RSuIS5dI6osFQjZyRPnW IkmKG2EPDrjNJxMa6elHL9kHvC989l0= X-Received: by 2002:a62:1594:: with SMTP id 142mr51093679pfv.18.1582549157864; Mon, 24 Feb 2020 04:59:17 -0800 (PST) Received: from localhost ([103.195.202.114]) by smtp.gmail.com with ESMTPSA id a9sm13203869pjk.1.2020.02.24.04.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 04:59:17 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, swboyd@chromium.org, sivaa@codeaurora.org, Andy Gross Cc: Amit Kucheria , linux-pm@vger.kernel.org Subject: [PATCH v6 4/8] drivers: thermal: tsens: Release device in success path Date: Mon, 24 Feb 2020 18:28:51 +0530 Message-Id: <9210fe430e75f6e971358c1db823d69ccab43580.1582548319.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't currently call put_device in case of successfully initialising the device. So we hold the reference and keep the device pinned forever. Allow control to fall through so we can use same code for success and error paths to put_device. As a part of this fixup, change devm_ioremap_resource to act on the same device pointer as that used to allocate regmap memory. That ensures that we are free to release op->dev after examining its resources. Signed-off-by: Amit Kucheria Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/9fa8a4e09b6fcff4b9d4facc9f9e9f8e3c4a41d5.1582048155.git.amit.kucheria@linaro.org --- drivers/thermal/qcom/tsens-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 1cbc5a6e5b4f..013750fff8b2 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -602,7 +602,7 @@ int __init init_common(struct tsens_priv *priv) /* DT with separate SROT and TM address space */ priv->tm_offset = 0; res = platform_get_resource(op, IORESOURCE_MEM, 1); - srot_base = devm_ioremap_resource(&op->dev, res); + srot_base = devm_ioremap_resource(dev, res); if (IS_ERR(srot_base)) { ret = PTR_ERR(srot_base); goto err_put_device; @@ -620,7 +620,7 @@ int __init init_common(struct tsens_priv *priv) } res = platform_get_resource(op, IORESOURCE_MEM, 0); - tm_base = devm_ioremap_resource(&op->dev, res); + tm_base = devm_ioremap_resource(dev, res); if (IS_ERR(tm_base)) { ret = PTR_ERR(tm_base); goto err_put_device; @@ -687,8 +687,6 @@ int __init init_common(struct tsens_priv *priv) tsens_enable_irq(priv); tsens_debug_init(op); - return 0; - err_put_device: put_device(&op->dev); return ret; -- 2.20.1