linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org,
	mike.leach@linaro.org, robert.walker@arm.com,
	coresight@lists.linaro.org, robh@kernel.org,
	frowand.list@gmail.com, devicetree@vger.kernel.org,
	matt.sealey@arm.com, charles.garcia-tobin@arm.com,
	john.horley@arm.com, al.grant@arm.com,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: [PATCH v3 5/9] coresight: Fix remote endpoint parsing
Date: Fri, 27 Jul 2018 11:15:33 +0100	[thread overview]
Message-ID: <1532686537-12380-6-git-send-email-suzuki.poulose@arm.com> (raw)
In-Reply-To: <1532686537-12380-1-git-send-email-suzuki.poulose@arm.com>

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.

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 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 4b279f8..2ecdd14 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -134,7 +134,7 @@ static int of_coresight_parse_endpoint(struct device *dev,
 	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 {
@@ -142,16 +142,16 @@ static int of_coresight_parse_endpoint(struct device *dev,
 		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 *dev,
 		pdata->child_names[i] = devm_kstrdup(dev,
 						     dev_name(rdev),
 						     GFP_KERNEL);
-		pdata->child_ports[i] = rendpoint.id;
+		pdata->child_ports[i] = rendpoint.port;
 		/* Connection record updated */
 		ret = 1;
 	} while (0);
 
 	if (rparent)
 		of_node_put(rparent);
-	if (rport)
-		of_node_put(rport);
+	if (rep)
+		of_node_put(rep);
 	if (rdev)
 		put_device(rdev);
 
-- 
2.7.4


  parent reply	other threads:[~2018-07-27 10:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 10:15 [PATCH v3 0/9] coresight: Update device tree bindings Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 1/9] coresight: Document error handling in coresight_register Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 2/9] coresight: platform: Refactor graph endpoint parsing Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 3/9] coresight: platform: Fix refcounting for graph nodes Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 4/9] coresight: platform: Fix leaking device reference Suzuki K Poulose
2018-07-27 10:15 ` Suzuki K Poulose [this message]
2018-07-27 10:15 ` [PATCH v3 6/9] coresight: Add helper to check if the endpoint is input Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 7/9] coresight: platform: Cleanup coresight connection handling Suzuki K Poulose
2018-07-27 10:15 ` [PATCH v3 8/9] coresight: Cleanup coresight DT bindings Suzuki K Poulose
2018-07-30 23:13   ` Rob Herring
2018-07-27 10:15 ` [PATCH v3 9/9] dts: juno: Update coresight bindings Suzuki K Poulose
2018-07-27 10:17   ` Liviu Dudau
2018-07-30 23:14   ` Rob Herring
2018-07-30 20:02 ` [PATCH v3 0/9] coresight: Update device tree bindings Mathieu Poirier
2018-07-31 15:06   ` Mathieu Poirier
2018-09-10 15:35     ` Sudeep Holla
2018-09-10 15:49       ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532686537-12380-6-git-send-email-suzuki.poulose@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=al.grant@arm.com \
    --cc=charles.garcia-tobin@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=john.horley@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=matt.sealey@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=robert.walker@arm.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).