Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp46358imm; Tue, 5 Jun 2018 14:46:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKXQU1LxaXibpFHBLDkSzH2j7KwbUuVG7mZO5OrqtDndIigZMjDeRh0d3ZUFUmrxts2SKc1 X-Received: by 2002:a17:902:aa8f:: with SMTP id d15-v6mr313780plr.359.1528235185012; Tue, 05 Jun 2018 14:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528235184; cv=none; d=google.com; s=arc-20160816; b=x4AECDtMVM2y8WcehuOqL1Zf49Kb4VVLFF4WsC+2HuTK8rrqcOlpV63HTchumQB7LC fILTXV0LTWAx/b1CESRZs5kaUdBOivhliCra3NvqqyEEv8AjW16pYwDX1Y9Nlxy1cTXb h6wqqBb62rOULGQ59HVd8/Ad1kYdV+yEQJErttA4OaTUUs5O1nCT66WX0NCieLbePOtg T44TMVnNqONX7LgCxJ5Ca99NRV7vKTFybyi55aYisYu7sd+7Lct+f+hKbaUvJGnHvDY2 c7fY3KRrbDHMYblgo4Tc++mILANdItWEJ2BZ4uZk0gq0eMkP6QEqIP9MXjhjrPVA4Zed 1xzw== 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:arc-authentication-results; bh=xyVt5Rev5Ed71sGmjRrfiM5XpKB0c0IQSsaVuQdc8yo=; b=sBUqrUAK7a59e8DganKr4Jsfx+Yz6RhcQGAsfsVJLn9pq/j/WuT7A+Z56smX9sn3H2 KwQPPegE1qiPfCpPHeryaOPcf6szYxxbClM1R6YR1dTyz6OfnvL8R/Y9lJ5xAggNStp5 pfopBQoIGk6yl/cXU5FEf3GX8ytx+zHQ2HLzG2ljEzpPrnpFf3ymuW2Bgdhg9X8Q0OjI eroyNvMdBkv7Ki7OqF+KAYDV/T9CUiHidFqAaW7616HYY4ndGQKZpVJXM+CyFlDF253W mLV7m6+bp9nB1cj6DmuaqlYMCz8ivRvW0dpmIbxM4mDbHpoQwXtqwLJme+LI53/N2oHH KBNw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5-v6si38492682pgn.453.2018.06.05.14.46.10; Tue, 05 Jun 2018 14:46:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628AbeFEVoz (ORCPT + 99 others); Tue, 5 Jun 2018 17:44:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34450 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbeFEVox (ORCPT ); Tue, 5 Jun 2018 17:44:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C360D15AB; Tue, 5 Jun 2018 14:44:52 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4917D3F59D; Tue, 5 Jun 2018 14:44:50 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose Subject: [PATCH 03/20] coresight: Fix remote endpoint parsing Date: Tue, 5 Jun 2018 22:43:14 +0100 Message-Id: <1528235011-30691-4-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When parsing the remote endpoint of an output port, we do : rport = of_graph_get_remote_port(ep); rparent = of_graph_get_remote_port_parent(ep); and then parse the "remote_port" as if it was the remote endpoint, which is wrong. The code worked fine because we used endpoint number as the port number. Let us fix it and optimise a bit as: remote_ep = of_graph_get_remote_endpoint(ep); if (remote_ep) remote_parent = of_graph_get_port_parent(remote_ep); and then, parse the remote_ep for the port/endpoint details. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/of_coresight.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 8a23c63..ada4f07 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -129,7 +129,7 @@ static int of_coresight_parse_endpoint(struct device_node *ep, int ret = 0; struct of_endpoint endpoint, rendpoint; struct device_node *rparent = NULL; - struct device_node *rport = NULL; + struct device_node *rep = NULL; struct device *rdev = NULL; do { @@ -144,16 +144,16 @@ static int of_coresight_parse_endpoint(struct device_node *ep, if (of_graph_parse_endpoint(ep, &endpoint)) break; /* - * Get a handle on the remote port and parent - * attached to it. + * Get a handle on the remote endpoint and the device it is + * attached to. */ - rparent = of_graph_get_remote_port_parent(ep); + rep = of_graph_get_remote_endpoint(ep); + if (!rep) + break; + rparent = of_graph_get_port_parent(rep); if (!rparent) break; - rport = of_graph_get_remote_port(ep); - if (!rport) - break; - if (of_graph_parse_endpoint(rport, &rendpoint)) + if (of_graph_parse_endpoint(rep, &rendpoint)) break; /* If the remote device is not available, defer probing */ @@ -165,15 +165,15 @@ static int of_coresight_parse_endpoint(struct device_node *ep, pdata->outports[*i] = endpoint.port; pdata->child_names[*i] = dev_name(rdev); - pdata->child_ports[*i] = rendpoint.id; + pdata->child_ports[*i] = rendpoint.port; /* Move the index */ (*i)++; } while (0); if (rparent) of_node_put(rparent); - if (rport) - of_node_put(rport); + if (rep) + of_node_put(rep); return ret; } -- 2.7.4