From patchwork Tue May 2 08:30:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9707697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB0D36021C for ; Tue, 2 May 2017 09:05:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3BA928402 for ; Tue, 2 May 2017 09:05:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9883C28405; Tue, 2 May 2017 09:05:44 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33BA028402 for ; Tue, 2 May 2017 09:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kIzfofZTMjyUgHVecbJBOls/fFB9n1U6IiwHf0WpRyc=; b=pCHMJxsRkVSQZkTlb84ei9jjlK T9X5X4DC0LzKVOUOKkFnQvE80q7/r0Sodw2MATQwcb+ukhh8sxmFQRuMUHpsyl39PYp+X3YFG/rSt wzdI+S0n69YCzDzjpqFT6YHShQzL3J5gxHVi3x/2IMLgzLjvNpRAiDfKvSLjbGvz7nS7jHwLbymGo 69bwOe+Zzy1UIoBB4aIGfmUZH6ncSfjP5nC38dSmORzJDDvLoT0lPGqKF3W1aL1HzztuRah+YOdR7 /NyrOWxucxFG0od/RLcdbVy2+0JiUaskRV+5wBqVjr3vBGQB1J7shUsZdQ8wjrbRgDIDRJ6H8XHHp C5aIrSxg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d5Tkd-0006Ql-2J; Tue, 02 May 2017 09:05:43 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d5TkT-0006E2-S4 for linux-arm-kernel@bombadil.infradead.org; Tue, 02 May 2017 09:05:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Aj1P91bNy7GpmeBFbhGT6Iu5DO6C2EaUvqQMOXu1peA=; b=0AlVpfo5apfrn9xTWgDH20DY9 gMpAENYrMznNtbCdpwii5pYI0fz+jI3+0QMPNNbCkFsj2Hwyw/1+p8E5eVMqHmU+1rxqiAUdAbT6d TQ1OZDA+l3Td5OB+AW1jInDQd+EWzvjxVLNlGuuz5hWx9bjeZBleMkATLTDlD4qZTSjC8Dq+4fx4z LLCeOpxwQBtQn5ldZRCvR13RlkW6DgCMbeYuyzwqqx54CfOIjcoUUm728bn9d7yWhs1gVn+jE6tjv NwSNIxCedJWSykNqRjKEoTQgFAINzi1yi30gXN6ir1XJ4qhwUagS/JBiTerHsJxAx5pBWbggv8EPd 6suTw3i8A==; Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d5TDc-0004ln-Sf for linux-arm-kernel@lists.infradead.org; Tue, 02 May 2017 08:31:37 +0000 Received: by mail-pf0-x235.google.com with SMTP id v14so85863325pfd.2 for ; Tue, 02 May 2017 01:31:15 -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; bh=Aj1P91bNy7GpmeBFbhGT6Iu5DO6C2EaUvqQMOXu1peA=; b=adMfPJZWgBlvGm1YTeUdaXuOV5XFD1V7IBpgziOxdAoH6PRhycmcGlLotVvGLgJaYq nxGMwnc6bvIU5kLKeYzwTLe88p8JdteuM97Q1Sb6lKMtoy1b9ENbiTaLGObF3cDLUwMO 4NXxz75cFDNRNcQ1//gnOn/qaGTUAmAFoiKFQ= 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; bh=Aj1P91bNy7GpmeBFbhGT6Iu5DO6C2EaUvqQMOXu1peA=; b=R+BapZAgdN0QjIB61GYe4SDg2tAYLfd+TMDmq5JDSkcONClAAe+/XjoLwNOUCxwtw9 GaedKuCCZhAhV2e8C4guUnvetk++d/4gCrEPbsDeHNh+Cabtry0ctcvnTkYC3WlTEzNm G0ItpEoU9/Kq3FfiEFw38Zhu1T4muQYxZZ3AEIziSydhY3+uJLlK/QePJ7BB5OaHixNe VMJ3FdbTqTaLrn+q1pLUkZok9vUdwQV+R4nftpmRNBstdYrp2DSg1JbEx/S/PdzTXwjI y62ZccDbn3zxwJsiuF5mSorRJEs2Ewr6850QfpmcXBkHVZoPBwXpwVCrDE3KT0TXwFOU Y0LA== X-Gm-Message-State: AN3rC/460zSDP9WD22M80RMvzhMTrd8xXxn0vkvgJhl077m/1SXtZfMH 2ddKYJoACOgkedXI X-Received: by 10.84.211.65 with SMTP id b59mr39676806pli.17.1493713874554; Tue, 02 May 2017 01:31:14 -0700 (PDT) Received: from localhost.localdomain (45-125-195-13.ip4.readyserver.sg. [45.125.195.13]) by smtp.gmail.com with ESMTPSA id g89sm29047829pfk.25.2017.05.02.01.31.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 May 2017 01:31:13 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Mathieu Poirier , Greg Kroah-Hartman , Suzuki K Poulose , Stephen Boyd , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Mike Leach , Sudeep Holla Subject: [PATCH v7 3/7] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Tue, 2 May 2017 16:30:01 +0800 Message-Id: <1493713805-26920-4-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493713805-26920-1-git-send-email-leo.yan@linaro.org> References: <1493713805-26920-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170502_043136_995329_3CB9E51C X-CRM114-Status: GOOD ( 14.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suzuki K Poulose The of_get_coresight_platform_data iterates over the possible CPU nodes to find a given cpu phandle. However it does not drop the reference to the node pointer returned by the of_get_coresight_platform_data. This patch also introduces another minor fix is to use of_cpu_device_node_get() to replace of_get_cpu_node(). Cc: Mathieu Poirier Reviewed-by: Suzuki K Poulose Signed-off-by: Suzuki K Poulose [Leo: minor tweaks for of_get_coresight_platform_data] Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/of_coresight.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 859ad49..de7e8ce 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -108,7 +108,8 @@ struct coresight_platform_data *of_get_coresight_platform_data( struct coresight_platform_data *pdata; struct of_endpoint endpoint, rendpoint; struct device *rdev; - struct device_node *dn; + bool found; + struct device_node *dn, *np; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -175,17 +176,19 @@ struct coresight_platform_data *of_get_coresight_platform_data( } while (ep); } - /* Affinity defaults to CPU0 */ - pdata->cpu = 0; dn = of_parse_phandle(node, "cpu", 0); - for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) { - if (dn == of_get_cpu_node(cpu, NULL)) { - pdata->cpu = cpu; + for_each_possible_cpu(cpu) { + np = of_cpu_device_node_get(cpu); + found = (dn == np); + of_node_put(np); + if (found) break; - } } of_node_put(dn); + /* Affinity to CPU0 if no cpu nodes are found */ + pdata->cpu = found ? cpu : 0; + return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);