From patchwork Tue May 9 02:49:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 98864 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1616813qge; Mon, 8 May 2017 19:51:22 -0700 (PDT) X-Received: by 10.84.222.129 with SMTP id x1mr41011310pls.144.1494298282339; Mon, 08 May 2017 19:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494298282; cv=none; d=google.com; s=arc-20160816; b=Z5+438itPBfalMjZX87ywUO7K+QZmSKh5tiQyD5KChrcVvhZqDfpiEVjFZElMoV02G cVKc4ifIQDJj1u7hOZ0vLPFIbwQ+uuZn1+9iPIBU4FQPx6P+H0z7mmkaZGG6Fedr1WXF 2bRj8fp695atEB3nW1TOaNUJTUN/mMxaRlDFyGY5jZ+njYkf8of5grJ6BwtiuxsxYQbR 5dkZVPYI6V//IuidmkzCBeDSGBzB5gLLJAxPrB+2Up6PfgtXUN+EwML16oLapMXmHe6R Q+fT1D8RKlFAxzuOQds/3yHFxqKrvtS9pFx89gj3zjg8PINB8DfQ+/TSH2snTU6aOvWG jBjg== 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=yawquSNFHDOAvfdhsoHcdw6DB0pQD9McacisOKpWT9WQ1KjO7iE9FZ6w+/FVyP6wE4 7FieZUnXmbX199xyLkE1NZaMgi07Sbl4kzQDcq2tWa2DZ6RY7AvJbw1IrDYWHfCxAxqa Uq2Tqcs8LZ2UWZlBOUfQFUD0sm+oSyodF+kdsZ7ZX7JsZ8msNykP7kIP9nKia1WTMcEd g4Qb0pq3IgJVQRlWGmQVB8Bdy9kycL/QHvCL2jHgMnZAwtxZsm2MlC2eH0/jfaO+h4BE o/BZCBucolsvzGvxjw04pthrrCXIT3Eco6/unwnRYQ7mZPV17gbDlZhtAZ5++GBuN3H/ RaFg== 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 n17si15254207pfj.260.2017.05.08.19.51.22; Mon, 08 May 2017 19:51:22 -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 S1751309AbdEICvU (ORCPT + 7 others); Mon, 8 May 2017 22:51:20 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:33309 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbdEICvR (ORCPT ); Mon, 8 May 2017 22:51:17 -0400 Received: by mail-pf0-f178.google.com with SMTP id e193so19404797pfh.0 for ; Mon, 08 May 2017 19:51:17 -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=krQGLJjYgID56xxBcZTFi9iN++6uSS1k9c/Bj8OUKXPPTWQkxnqlmhnNqbsPho7CWj N4w7nfg0fZ5/MKPZKABef1uN1SI4FcTP5Qzl8BC5GVqhWN7K+nB4bSLI1gMhOdfozWBG UFly4yrg8q7LOx3jnkxVPT/L2h93mQNz4dfbo= 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=sVg0u5xHqkuiJqwvCHxTTT9fTG7z5wKNWZrS0ghGKSup0l4p7OrEwb8OMpDLcjyRkq fwMu5XPFZFqIvD5Pa4GjC4MsnPlgQQj8Jrg4cZO6gAMheUO1v721/DqA/uTAHo//JFlO p+oBNjBelfq3id/HBwpxnfGBds5HTxExEbjKL2pU4iAFsmoy9C53s+aSsQQl0jdAre8l V20tYM3d5kvdHzxBLmeIxBF7UqoRSO8dbYLDuKZgR/6/h/eFuFA/RmDfpTvaqdXZDdQj 5eFwnEQEn8KDIEJjPlHDDhdTUUl9J30k4s10/cTmCJViqqMPlGd+cdp+QLQZP7TtNUId 0zqA== X-Gm-Message-State: AODbwcABhpC4F9l3fPq9qc8FC+nn4ZVgWX0ZVxJN/FqxRGHdke+wAUMS Xl51SiGS254TdGG4 X-Received: by 10.99.151.10 with SMTP id n10mr5810552pge.199.1494298276964; Mon, 08 May 2017 19:51:16 -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.51.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 19:51:15 -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 6/9] coresight: refactor with function of_coresight_get_cpu Date: Tue, 9 May 2017 10:49:59 +0800 Message-Id: <1494298202-6739-7-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: 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