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: 98422 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1764335qgf; Tue, 2 May 2017 01:31:32 -0700 (PDT) X-Received: by 10.99.4.3 with SMTP id 3mr14633987pge.86.1493713892513; Tue, 02 May 2017 01:31:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t189si3894136pgb.83.2017.05.02.01.31.32; Tue, 02 May 2017 01:31:32 -0700 (PDT) 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; 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 S1752129AbdEBIbW (ORCPT + 25 others); Tue, 2 May 2017 04:31:22 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:33095 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751020AbdEBIbP (ORCPT ); Tue, 2 May 2017 04:31:15 -0400 Received: by mail-pg0-f54.google.com with SMTP id y4so52252019pge.0 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=kQ+eESRKL9Lc7hQS95cmwLgFq14K0cfhtADqS+u1H9dF5S6lXwreKtzwJT+ZyMUli0 jk/vJPKFS7ANzDigVJjRh2kO3Hxgr/nxUx+FbmBI1R0jD51RqTQiEMLOy4YpcFTob/GG 7z41HxhW5iuYvMRqOHSsB55ZBZkPdnYcYDrK2Mdbu9cHwgZalfaEzmJ2n41d09UPWcmf HtsNrU/yE4JUNAV0YvpfpTef88iGgwItOAvpXFJ5CTV4hJ0yXt/qqQVBYFf3o33AomFl 8p2LCWm84yDImTtbykV+yWxqDqQkvgJwwAQW9Ph7oshugJ1yf5SYo/erSrzJgyIZ286S RHWg== X-Gm-Message-State: AN3rC/7U6wnmo8DKyL1enYGYPfzFvchTRFZ/P/tiwECv4pPJ9nx1vsHY RNVXMriP/QzhXk5l 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 Cc: Leo Yan 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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);