From patchwork Fri May 19 04:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9735801 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.web.codeaurora.org (Postfix) with ESMTP id 49E7B601C2 for ; Fri, 19 May 2017 04:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 323CE2866A for ; Fri, 19 May 2017 04:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27148288A9; Fri, 19 May 2017 04:28:28 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 A64FB2866A for ; Fri, 19 May 2017 04:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753024AbdESE1Y (ORCPT ); Fri, 19 May 2017 00:27:24 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33928 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754479AbdESE1P (ORCPT ); Fri, 19 May 2017 00:27:15 -0400 Received: by mail-pf0-f182.google.com with SMTP id 9so33738430pfj.1 for ; Thu, 18 May 2017 21:27:10 -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=KPg79NY3sGvLdvwjFFRlkg3unWx7G4i/7+aegEzxzF8=; b=bEoAHBYus7gV8JNk60ofG9hVOFcNUqQHBPoSF4eZkwZ2DMecwhCTAfluOL6FDOVQxl Vm+3pUmqgjs7zKqNoZcl0x6Bb+sa1hPw1Tng588vYZ5yeHgk5pdB8PNLAE/hPnUQUNnq W/XDnvIn5P6Hs9Afnno+9DX16JFwz1Nyp/EXM= 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=KPg79NY3sGvLdvwjFFRlkg3unWx7G4i/7+aegEzxzF8=; b=akGu2C7YecgTwP2oFXQosUvAa5u8uKUwu/mNqooM7RRq10gSOdRbB8IfnslOXY+0A6 lhfb/lIhDhXTAndD2yva1NPIApbuYCx+Dph1T1zcV0sHf5YkSabSA6EGHqRcd7+Lj91K //Jre+Njs6iwfQL0yFRrTWThlMtaSG0BtqwI1ar/RsoLg5fUAUP0v5K2OzDZ/Vfl/Dsq 9ZV1gTN6qRnUPxwtMXJCLkCZ2k0vvRNLhAy3Cdqt6U+GK8WI9koJabqijjwX3+YfdGVi Vh6BJQREp5M2jEBTdJyWY7cfnjrWxyg/aWqBKYi9ggKfRwji4D1OMUs9LzFaRq7RWIeD QCgQ== X-Gm-Message-State: AODbwcApQkUz8E/8irdWLiUqUTH2ezTjwnrrj81fk9M1t6DPmhlsMssV S9BF7DOHBojWlUIf X-Received: by 10.99.137.194 with SMTP id v185mr7990036pgd.206.1495168024455; Thu, 18 May 2017 21:27:04 -0700 (PDT) Received: from localhost.localdomain (li637-108.members.linode.com. [106.186.117.108]) by smtp.gmail.com with ESMTPSA id c29sm5823259pfj.101.2017.05.18.21.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 May 2017 21:27:03 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Catalin Marinas , Will Deacon , Wei Xu , Andy Gross , David Brown , Greg Kroah-Hartman , Suzuki K Poulose , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Stephen Boyd , Mike Leach Cc: Leo Yan Subject: [PATCH v10 05/10] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Fri, 19 May 2017 12:25:52 +0800 Message-Id: <1495167957-14923-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495167957-14923-1-git-send-email-leo.yan@linaro.org> References: <1495167957-14923-1-git-send-email-leo.yan@linaro.org> 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 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 2749853..225b2dd 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -109,7 +109,8 @@ of_get_coresight_platform_data(struct device *dev, 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; @@ -176,17 +177,19 @@ of_get_coresight_platform_data(struct device *dev, } 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);