From patchwork Tue May 23 14:16:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 100374 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp1896414obb; Tue, 23 May 2017 07:20:26 -0700 (PDT) X-Received: by 10.99.138.194 with SMTP id y185mr14711163pgd.70.1495549226491; Tue, 23 May 2017 07:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495549226; cv=none; d=google.com; s=arc-20160816; b=kjwAhNDEiROkZhTORhi+H2bEnoMAE0Hn3N6nkVWpWMEzuj5veXRKZYd8uHe7r1kPox 0/xQsnSwKhIJ1TwLNE/NiPA33VdIkJHXOH8Bfa5hWG5eThWMatgfIer0KB+OBq5r+my5 TAJYTpeDhle7/YzXKeoUGhej1/0ZadHjxnP/2OYeZDHH31Ch7p69b+RBoOiqYgAeeEX5 zgl7M+WPft8t0rH9L75voUxrLSrArDGYhV6rHua6SLBBCa7RLalZOMIkBmXVKzw40P3q Nrb0MO0hbxp2nqwz466hrM5wZI8qfCRmU5ZWeFNRnf5MnPQcjbLYChovkT2iNwLpmPC/ T6uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PnpN8Va5xDrvbAb6sO2mTuizYThuGNG8c3U1vVTHVw8=; b=yGn8wZ9i492y/q6a3fpMkSa2UQ1yQuPDezi9X6HlT5mDFFiWtuZ/GdcSZYQsZPskW8 1Jn9uKhJpAfg6HPaUt5HFcZ+NnyAalZa9LsYpfxE3lqeW+zO/6TSlhlKQiHmv+nvnOX4 /AkSOEh1m+BKis4f0otad7cPmH1PCle8vHj4IbNO4jUIlfPKE9njELjJ1IG2jaNQgHC3 NhfQw63eUQg40S0CbAMSoiiqYQNqOtmbhQx7ZUky6GoxBR3k4JFzuYi1lSsLEbGozNFz jWo0XdcxYu1uzN33d7YIt2aE0XyswRLjfJZv6rhLwRdFS9xnmNF8agsEGKV9VMWKczuY GZVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si21275689pld.330.2017.05.23.07.20.26; Tue, 23 May 2017 07:20:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030487AbdEWORt (ORCPT + 7 others); Tue, 23 May 2017 10:17:49 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:36336 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937272AbdEWORg (ORCPT ); Tue, 23 May 2017 10:17:36 -0400 Received: by mail-pf0-f175.google.com with SMTP id m17so116125471pfg.3 for ; Tue, 23 May 2017 07:17:35 -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=YwQvc6e7fdSqIntv72ZIGe7cFsPwXFMBk/X5rEWZ8+dqz/teiBg2L8ZDSjqTBODp5g vzFG3wTxN+5PbfeUZa42ZqPePlUCP50nN6Naz4gJhvXZ3Zgg5QYvskQlLDzcvTAawYs2 IlmMtPcp5HscU32R7h3/erK8CeSPU2SO7lhcU= 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=rlRVR0WyfyTSqKhKvm5sP4snpSatM7EEgC+hXZiBKiNBWzCKAhRNA0wK/HciBshsg8 ZAsl0RyA1SKYtAI2F54SuNHC9QYBrAdXbClhhk9c7atrosQtBB+6Z1UX5rR6wz3uqRfV gIPaAf5uNlLRb13qO9vw1AmhSHpTSoC6XZ/uIF8zCKoi1ymj/ItVCKgU6vmz4Pegw7Ob WtgnCbHeAR9BvC0N7Z2j8M9u1jglvAQW+UhWNs5WlwKDB2gKywUOHixorS2pRa5k+sVf ovab/ZZOaEpdtlleVekTYBhgqXsdAxLHWdv+WUYH01SF7EQs/2ynkfRueJVDgTs76gXX W6HA== X-Gm-Message-State: AODbwcD/bGtMsPgcZJUQG64rQH8cGYtqV5SjDdEZFJJWeNxIT07i3MPD C9LPsTSmhaQNFq0s X-Received: by 10.99.169.26 with SMTP id u26mr2918728pge.177.1495549055280; Tue, 23 May 2017 07:17:35 -0700 (PDT) Received: from localhost.localdomain (li1068-205.members.linode.com. [106.184.3.205]) by smtp.gmail.com with ESMTPSA id x80sm1953334pff.105.2017.05.23.07.17.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 May 2017 07:17:34 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Wei Xu , Catalin Marinas , Will Deacon , 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 v11 5/9] coresight: of_get_coresight_platform_data: Add missing of_node_put Date: Tue, 23 May 2017 22:16:16 +0800 Message-Id: <1495548980-30432-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495548980-30432-1-git-send-email-leo.yan@linaro.org> References: <1495548980-30432-1-git-send-email-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); From patchwork Tue May 23 14:16:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 100375 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp1896522obb; Tue, 23 May 2017 07:20:40 -0700 (PDT) X-Received: by 10.84.149.102 with SMTP id b35mr36244260plh.151.1495549240330; Tue, 23 May 2017 07:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495549240; cv=none; d=google.com; s=arc-20160816; b=wVBt1ncdVKsCy2fHZGgf0KLJO+Gzlr6VFuTbByb+6znvsm59g8H0LhbnzWOiow6QQk GFABD7yGhqjEAAJBLClg6jwE3vshVRunwoBzn3/N2M3BUcoGCxKfFoM7W6+lWut2x/Pe zD4I06UxUFgoR0Jdg/rHBwMRdtBplAC2R5EtCLB3i1SX74Yen5bi4dOrdnojLFOqJdfL BvaM/URarZHBktmna0V8PkhCGBki2FTk/Il+ri/noimac0Kn5wnsZFes62+bJ8ZC0t0W r+rrcz2bg02gAMhpkDkGAypHQS74WwmTEl9/KA0h5fkOuOq+aMIIog7HNO2jaQlanr3G g12A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tKG/BB0MfZvHs6Xy8plsaOYGZwjyw5T9RTPKbQ1rU1M=; b=QU3uOVeynCJEI9d2ZD2yGhzp7NKrMzR/zxzikLRgYnOA3K72xlSJJRA/q33C3feK6i pOna6wTOP5Sv9WCYTq4N3478NJYrSbvGMVM7f/y3S+sT2kKZUZCZrhVIevNs0uFEWtAF 3GEFvOLK8XB+0GymA6RvsBCwNknG1wAnu2FHfmPnadcPDgZ1Bi52GtUpnFKugBtI7hOf Y8jc0Dv3U6oTBxui//R4hA03kFsrQoSnDLj3lTFa8j0L9xdOUMcrdpWwbMFAuJ3Gza+d 4tDXIyTh5lbup56AbkrK2WqM+o6RmS+xToyriJaq+1IdjsHfpSj7FcNadM9WCIDZDHN/ vCZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si7611662pgc.55.2017.05.23.07.20.40; Tue, 23 May 2017 07:20:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934714AbdEWOUi (ORCPT + 7 others); Tue, 23 May 2017 10:20:38 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34784 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030467AbdEWORq (ORCPT ); Tue, 23 May 2017 10:17:46 -0400 Received: by mail-pf0-f171.google.com with SMTP id 9so116070793pfj.1 for ; Tue, 23 May 2017 07:17:45 -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=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=XBLTnV23gCMFP1U7FYOgtOaowix0ui1zZ9slF0BStI8otRnbFqy7p6bo144GwXC5sX ZDN1ERxPpMbImgXwQAd6mdpzKsRCLKIOh2oXuImpSffElB3X4GxXm5xXCfy7J/VLVkcv qu9k6z70B68eUBZyX82e2Ot91Sgczf4i3nuCc= 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=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=tmcBh7F0pHi+Rk8HHIgqKAJqMcsSKaA+EV2SVRcCooKSmomEvIES9Fc1gJFXKI8Q/d h86QqGUq6E/BC0JtciXQW4cd+92vrUWz7vPLDdtofagSBcLxVxlzLTav0NeJIGVM/WtT cR5uVGjumQdK1nGSOL0FF0UkVAxi26No+F4QuWJyjOMypeTgCbeDDcThx10cLeYl0EEw 3KQ/TOUPWsOuSJ0qfkFt/5Y2+5FNnt/xBmpzZGZNYJjO9LDAj04H7QkQpHgSU1A17W/v yA3S0X3ZJicFAK9s4GkX/2se34D6qR8qC4v48EBdIuTs7tft7vlpeqfpDbzHETztzCKu f3JQ== X-Gm-Message-State: AODbwcBjvgemuxErG1eneqlX8K5a5r3ffZtyrkhk4MVHJwGsNgNaAiKD VG+Im7zCdaEbmGeH X-Received: by 10.98.245.155 with SMTP id b27mr32008153pfm.181.1495549064098; Tue, 23 May 2017 07:17:44 -0700 (PDT) Received: from localhost.localdomain (li1068-205.members.linode.com. [106.184.3.205]) by smtp.gmail.com with ESMTPSA id x80sm1953334pff.105.2017.05.23.07.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 May 2017 07:17:42 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Wei Xu , Catalin Marinas , Will Deacon , 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 v11 6/9] coresight: refactor with function of_coresight_get_cpu Date: Tue, 23 May 2017 22:16:17 +0800 Message-Id: <1495548980-30432-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495548980-30432-1-git-send-email-leo.yan@linaro.org> References: <1495548980-30432-1-git-send-email-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This is refactor to add function of_coresight_get_cpu(), so it's used to retrieve CPU id for coresight component. Finally can use it as a common function for multiple places. Suggested-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/of_coresight.c | 43 +++++++++++++++++++----------- include/linux/coresight.h | 3 +++ 2 files changed, 31 insertions(+), 15 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 225b2dd..a187941 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,16 +101,40 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(const struct device_node *node) +{ + int cpu; + bool found; + struct device_node *dn, *np; + + dn = of_parse_phandle(node, "cpu", 0); + + /* Affinity defaults to CPU0 */ + if (!dn) + return 0; + + 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 */ + return found ? cpu : 0; +} +EXPORT_SYMBOL_GPL(of_coresight_get_cpu); + struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, const struct device_node *node) { - int i = 0, ret = 0, cpu; + int i = 0, ret = 0; struct coresight_platform_data *pdata; struct of_endpoint endpoint, rendpoint; struct device *rdev; - bool found; - struct device_node *dn, *np; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -177,18 +201,7 @@ of_get_coresight_platform_data(struct device *dev, } while (ep); } - dn = of_parse_phandle(node, "cpu", 0); - 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; + pdata->cpu = of_coresight_get_cpu(node); return pdata; } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index bf0aa50..d950dad 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,10 +263,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #endif #ifdef CONFIG_OF +extern int of_coresight_get_cpu(const struct device_node *node); extern struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, const struct device_node *node); #else +static inline int of_coresight_get_cpu(const struct device_node *node) +{ return 0; } static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, const struct device_node *node) { return NULL; } #endif