From patchwork Sat Mar 25 18:23:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9644745 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 E9C7A601D7 for ; Sat, 25 Mar 2017 18:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA32326220 for ; Sat, 25 Mar 2017 18:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CECC027FAE; Sat, 25 Mar 2017 18:25:42 +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 0755426490 for ; Sat, 25 Mar 2017 18:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751744AbdCYSYv (ORCPT ); Sat, 25 Mar 2017 14:24:51 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:34824 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbdCYSYr (ORCPT ); Sat, 25 Mar 2017 14:24:47 -0400 Received: by mail-wm0-f42.google.com with SMTP id u132so34022593wmg.0 for ; Sat, 25 Mar 2017 11:24:16 -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=3Av8iWToggPzcj0Ikq904mM+c9jlhlxGamEgFpH5NSk=; b=K14904O/wGulpm0bhInDH0Yvdhqbrr1oIQOKo7xzevswnotbIDqjNeipYdXzfPInRl INuJcMVe+gUHkF4olVDQ3I7VorZJG9UNMdAKi2vSEx+0AFRqzTgGo5SG9KGep59dPIck si3cocOY9oW4XN6II7TBV7TJW+aADgZ6mvOiI= 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=3Av8iWToggPzcj0Ikq904mM+c9jlhlxGamEgFpH5NSk=; b=awp98OAm3IDcfGF3RJ5OIdqJa7Vbjg+heLS5WTnUq+rnfinol9Wv7nYYmvfFXX0z15 tRVnQQPDyhalvRIqbkVTs5kCmBrKkXc7w0HUuFnVTf8Csi6zxMUSG3wMA7kpmuRw3r+L 6wzWgXn0D3T47WhUkTiBE9pUy+oQ34zdCzw87cur+Jm6OaGLg8rMfYq5ycq10KOdorD/ WYWmFhbUZxPnFOSEsMM7Yx+H2KB3JQ5don/LqAtFiIonV4UMUmUWZNyQAU7GqovU1bik UK0nTWRdzn6bJeR00oL1QF6E0itdYwAEZToG6Dg1y8Br25CDfnL/TW2aEAO2Lp/JPTkO hdDw== X-Gm-Message-State: AFeK/H1dm7n7R3ZeDDyPD2ipcc2phiROLwgi/5Tu4mevtmvDoC68+nCEWXprW2lcJPxpT0uv X-Received: by 10.28.105.92 with SMTP id e89mr2683771wmc.93.1490466255415; Sat, 25 Mar 2017 11:24:15 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id e72sm7464075wma.5.2017.03.25.11.24.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Mar 2017 11:24:14 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Michael Turquette , Stephen Boyd , Mathieu Poirier , Guodong Xu , John Stultz , 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, linux-clk@vger.kernel.org, mike.leach@linaro.org, Suzuki.Poulose@arm.com, sudeep.holla@arm.com Cc: Suzuki K Poulose , Leo Yan Subject: [PATCH v5 3/9] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Sun, 26 Mar 2017 02:23:11 +0800 Message-Id: <1490466197-29163-4-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490466197-29163-1-git-send-email-leo.yan@linaro.org> References: <1490466197-29163-1-git-send-email-leo.yan@linaro.org> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@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 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 629e031..1a77280 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);