Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1395277 > unrolled thread

[PATCH] of: fix device compatibility scoring

Started byReza Arbab <arbab@linux.vnet.ibm.com>
First post2016-05-05 20:40 +0200
Last post2016-05-06 17:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] of: fix device compatibility scoring Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-05-05 20:40 +0200
    Re: [PATCH] of: fix device compatibility scoring Rob Herring <robh+dt@kernel.org> - 2016-05-05 21:50 +0200
      Re: [PATCH] of: fix device compatibility scoring Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-05-06 17:20 +0200

#1395277 — [PATCH] of: fix device compatibility scoring

FromReza Arbab <arbab@linux.vnet.ibm.com>
Date2016-05-05 20:40 +0200
Subject[PATCH] of: fix device compatibility scoring
Message-ID<rvwlQ-5gq-19@gated-at.bofh.it>
If a constraint given to __of_device_is_compatible() does not
match, we should just move to the next constraint without adding
to the compatibility score. Instead, the function immediately
returns 0.

Do not return from __of_device_is_compatible() until a complete
score has been calculated.

Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
---
 drivers/of/base.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 017dd94..942a60e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -455,22 +455,18 @@ static int __of_device_is_compatible(const struct device_node *device,
 				break;
 			}
 		}
-		if (!score)
-			return 0;
 	}
 
 	/* Matching type is better than matching name */
 	if (type && type[0]) {
-		if (!device->type || of_node_cmp(type, device->type))
-			return 0;
-		score += 2;
+		if (device->type && !of_node_cmp(type, device->type))
+			score += 2;
 	}
 
 	/* Matching name is a bit better than not */
 	if (name && name[0]) {
-		if (!device->name || of_node_cmp(name, device->name))
-			return 0;
-		score++;
+		if (device->name && !of_node_cmp(name, device->name))
+			score++;
 	}
 
 	return score;
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1395328

FromRob Herring <robh+dt@kernel.org>
Date2016-05-05 21:50 +0200
Message-ID<rvxrz-6ic-9@gated-at.bofh.it>
In reply to#1395277
On Thu, May 5, 2016 at 1:30 PM, Reza Arbab <arbab@linux.vnet.ibm.com> wrote:
> If a constraint given to __of_device_is_compatible() does not
> match, we should just move to the next constraint without adding
> to the compatibility score. Instead, the function immediately
> returns 0.
>
> Do not return from __of_device_is_compatible() until a complete
> score has been calculated.

This matching is very sensitive to changes. Can you please describe
what conditions don't work for you and add a test case for that
condition to the unit test.

Rob

[toc] | [prev] | [next] | [standalone]


#1395924

FromReza Arbab <arbab@linux.vnet.ibm.com>
Date2016-05-06 17:20 +0200
Message-ID<rvPHQ-7CY-13@gated-at.bofh.it>
In reply to#1395328
On Thu, May 05, 2016 at 02:47:18PM -0500, Rob Herring wrote:
>This matching is very sensitive to changes. Can you please describe
>what conditions don't work for you and add a test case for that
>condition to the unit test.

Ah, thanks for pointing out the unit test.

Looking at the test cases there cleared up the misunderstanding I had 
which led me to suggest the patch. It does seem that the 
short-circuiting in __of_device_is_compatible() is intentional.

Please disregard. Sorry for the noise.

-- 
Reza Arbab

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web