Thread (17 messages) 17 messages, 5 authors, 2015-11-16

[PATCH 2/2] drm/rockchip: Convert the probe function to the generic drm_of_component_probe()

From: Liviu.Dudau@arm.com (Liviu Dudau)
Date: 2015-11-16 16:52:12
Also in: dri-devel, linux-rockchip, lkml

On Mon, Nov 16, 2015 at 04:30:16PM +0000, Russell King - ARM Linux wrote:
I've tweaked your patch to make the above (buggy) change a little clearer.

On Mon, Nov 16, 2015 at 02:44:53PM +0000, Liviu Dudau wrote:
quoted
-	for (i = 0;; i++) {
-		port = of_parse_phandle(np, "ports", i);
-		if (!port)
-			break;
-
-		if (!of_device_is_available(port->parent)) {
-			of_node_put(port);
-			continue;
-		}
 
-		component_match_add(dev, &match, compare_of, port->parent);
-		of_node_put(port);
-	}
quoted
-static int compare_of(struct device *dev, void *data)
-{
-	struct device_node *np = data;
-
-	return dev->of_node == np;
-}
The original above passes port->parent to component_match_add().  This
means 'np' in the above compare_of() function is 'port->parent'.

This means the above comparison is effectively:

	dev->of_node == port->parent

The generic code instead does this:

                component_match_add(dev, &match, compare_of, port);

So what we get in the comparison function is 'port' rather than
'port->parent':
quoted
+static int compare_port(struct device *dev, void *data)
 {
+	struct device_node *np = data;
+	return dev->parent->of_node == np;
+}
which means the comparison is:

	dev->parent->of_node == port

which is a different comparison from the above.

You instead want this to be:

	return dev->of_node == np->parent;

Heiko, please test the above change to compare_port() - I think you'll
find that will fix your issue.
Sorry, I admit I'm not very good at doing patches without being able
to test them. :(

Thanks for helping on this!

Liviu
Thanks.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ?\_(?)_/?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help