From patchwork Tue May 9 02:49:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9716973 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 0570260236 for ; Tue, 9 May 2017 02:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC0AB2074F for ; Tue, 9 May 2017 02:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD28726CFC; Tue, 9 May 2017 02:52:51 +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=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 59E682074F for ; Tue, 9 May 2017 02:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754876AbdEICwc (ORCPT ); Mon, 8 May 2017 22:52:32 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:33280 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755017AbdEICvI (ORCPT ); Mon, 8 May 2017 22:51:08 -0400 Received: by mail-pf0-f181.google.com with SMTP id e193so19403278pfh.0 for ; Mon, 08 May 2017 19:51:08 -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=WEjp4b2J3kiT59Wo7WK9YyPotimTQtlc4x1G90cluCy5QJdZz/UeZS98Qm3eE6uEH6 POMNWcwutlxkzsAygOOiFWyu68uqXvUPqSxVGWNkDvjdHw4/Qw1txGRoWp8TRqqhA098 loAOQ8PYejG7/vTwYGwTyFcpXVKjq/QRlcW2Y= 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=TARjUcdp5/Akh1+CMxRkfp3d0cLDUe5OBGeeYH6agS+UjWi7sREYNrk+34L+dOr6SV bu3wbkKeqbKBtqg9+eKsMKmKw/J3IANVzsQ9L7w9O34kMuvqOXi7vT0LnvZOYAYs/HrA bhDbM/HD1lF8cOm+z0cNHX/jUtuimhILyFZil28qzj3iWAXx2aE4uTHXLZ6zwmSEhJab uRw4qLDpdMTYdw1yqPMg4FgpuQFxpQRDJyGW2Ubi4/Or5K3GrjrGs1U6irzxnduR9w/6 JNwV9BCNZLpbg//Yrz0LA59MjMbne6phnGMwmAK7WQxKr2J04Qe3XQ+j/FzKqUAf3eGU 6Uzg== X-Gm-Message-State: AODbwcAGGCOj9XUBr8PTNjdqWyTHcmKMjk1Ks6UAlwL5uGweNpH2rwEG VL1q/I8QEWC7Bv0O X-Received: by 10.98.23.74 with SMTP id 71mr14045240pfx.30.1494298268128; Mon, 08 May 2017 19:51:08 -0700 (PDT) Received: from localhost.localdomain (li1627-128.members.linode.com. [172.104.47.128]) by smtp.gmail.com with ESMTPSA id 20sm35326370pfq.42.2017.05.08.19.50.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 19:51:06 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , 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 Cc: Leo Yan Subject: [PATCH v9 5/9] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Tue, 9 May 2017 10:49:58 +0800 Message-Id: <1494298202-6739-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494298202-6739-1-git-send-email-leo.yan@linaro.org> References: <1494298202-6739-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);