From patchwork Thu Apr 6 13:30:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9667365 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 63E0A602B8 for ; Thu, 6 Apr 2017 13:33:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E8127FA3 for ; Thu, 6 Apr 2017 13:33:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3556C28179; Thu, 6 Apr 2017 13:33:17 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B615F27FA3 for ; Thu, 6 Apr 2017 13:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KDAW7Av6u2EfN/8rrwY17NlPqVYPYRUsF0GivjflyVQ=; b=dqTJ4suD6eO3+bKum+4eDKbpKP vYq1V3yTuxnDwzliuuxcGwcinrTJYIF2iIWKafRQ0XbbZSvVVg6Zi80jYl8UUsgJyipUejj5YBo28 mgouCNrYfMxdYRrr7SZDJasX0EEfQusWhR9hupQBLtGfYBplSwhK7ymZf3Ev/YNwkDf+P5W5JFJBl c0C+A/oPk1gEV24uDDpM7uetQPMp5SAGPG+8VZhru2Hywz9kgSFZetslwwGIp6XePMndUsqNxYe8t FlgTtQcF6OvUbi6RkRy3W7wNJtjhUyrXDXlKGea1uc+Vncx9f+179C/0sHffoCXO17q1IZ4uOEWZp kCHlGzfA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cw7XH-0003dj-HJ; Thu, 06 Apr 2017 13:33:15 +0000 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cw7Ww-0002zI-HU for linux-arm-kernel@lists.infradead.org; Thu, 06 Apr 2017 13:33:12 +0000 Received: by mail-pg0-x230.google.com with SMTP id 21so36664387pgg.1 for ; Thu, 06 Apr 2017 06:32:34 -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=2kt28QdepAfE78Y2GrWBtywn9xT4klQ/93D4FHlh/zY=; b=T85/78xfVVTKZoApzMy1I4tyjIKak4QZ3iPljRdRR2cKVOwdi9q2QN/LJYmZLWhqKv qQ7TJ7TD//tOI2FfVsiYCFM9JICEt4lCFc1Q4T1WceGv+h7lkBUPo7oqJTbWHXpCwKeB VTAdjFojlbwb7b+yM5Gnm92GaWthGRDETJryQ= 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=2kt28QdepAfE78Y2GrWBtywn9xT4klQ/93D4FHlh/zY=; b=iH9XzOcTLfgCJkbqCV5BYSQVRKfilCWVzrQcC9eJ9AOd/nC6JkuhdRawfxIpyk8is2 klbA0JnpJtQRySSrly4D3OIx+2WYLi7wiGqzO5y6fWJVCoRtnKD/jNpg6IZhsTRI+N3O UXdTHNnyC4CfihiP7afRwYujUGTiYivIBSY4j4l6CjeC7BIOo2VimoLOH2j1QfC4xF13 gKhObLu/Aq4LxLZWDVS8ivdUn6zegPvFIJiZkOIrD1pj5/wwfTzueHml75MmG4WCRr1I s441hfvDFCyaRdeAq6V6lp3ikSy5jSZfWYybErsjJ420jYWV9eC7lZ+A3CGD3Ho4u6WF MHkg== X-Gm-Message-State: AFeK/H1OEN3okxO+5XcA7dGrLaAHQtV6lXP3boblBOvRRl/YooeiC3CsZc/bEjfgA2sOkzgX X-Received: by 10.99.110.6 with SMTP id j6mr36932280pgc.64.1491485553570; Thu, 06 Apr 2017 06:32:33 -0700 (PDT) Received: from localhost.localdomain (li1627-128.members.linode.com. [172.104.47.128]) by smtp.gmail.com with ESMTPSA id 129sm4074223pgj.59.2017.04.06.06.32.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Apr 2017 06:32:32 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Mathieu Poirier , 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 Subject: [PATCH v6 4/8] coresight: refactor with function of_coresight_get_cpu Date: Thu, 6 Apr 2017 21:30:57 +0800 Message-Id: <1491485461-22800-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491485461-22800-1-git-send-email-leo.yan@linaro.org> References: <1491485461-22800-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170406_063255_313796_82CF15BC X-CRM114-Status: GOOD ( 16.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 2 ++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 1a77280..78d2399 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,15 +101,39 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(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, 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; @@ -176,18 +200,7 @@ struct coresight_platform_data *of_get_coresight_platform_data( } 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 2a5982c..bf96678 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,9 +263,11 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #endif #ifdef CONFIG_OF +extern int of_coresight_get_cpu(struct device_node *node); extern struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node); #else +static inline int of_coresight_get_cpu(struct device_node *node) { return 0; } static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } #endif