* [PATCH] of: fix device compatibility scoring @ 2016-05-05 18:30 Reza Arbab [not found] ` <1462473048-10001-1-git-send-email-arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Reza Arbab @ 2016-05-05 18:30 UTC (permalink / raw) To: Rob Herring, Frank Rowand, Grant Likely, Kevin Hao, devicetree, linux-kernel 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 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1462473048-10001-1-git-send-email-arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>]
* Re: [PATCH] of: fix device compatibility scoring [not found] ` <1462473048-10001-1-git-send-email-arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> @ 2016-05-05 19:47 ` Rob Herring 2016-05-06 15:10 ` Reza Arbab 0 siblings, 1 reply; 3+ messages in thread From: Rob Herring @ 2016-05-05 19:47 UTC (permalink / raw) To: Reza Arbab Cc: Frank Rowand, Grant Likely, Kevin Hao, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, May 5, 2016 at 1:30 PM, Reza Arbab <arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> 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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] of: fix device compatibility scoring 2016-05-05 19:47 ` Rob Herring @ 2016-05-06 15:10 ` Reza Arbab 0 siblings, 0 replies; 3+ messages in thread From: Reza Arbab @ 2016-05-06 15:10 UTC (permalink / raw) To: Rob Herring Cc: Frank Rowand, Grant Likely, Kevin Hao, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-06 15:10 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-05 18:30 [PATCH] of: fix device compatibility scoring Reza Arbab [not found] ` <1462473048-10001-1-git-send-email-arbab-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> 2016-05-05 19:47 ` Rob Herring 2016-05-06 15:10 ` Reza Arbab
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).