Thread (1 message) 1 message, 1 author, 2014-02-18

Re: [PATCH 2/2] of: search the best compatible match first in __of_match_node()

From: Kevin Hao <hidden>
Date: 2014-02-18 05:41:45
Also in: linuxppc-dev

Possibly related (same subject, not in this thread)

On Mon, Feb 17, 2014 at 05:58:34PM +0000, Grant Likely wrote:
This seems wrong also. The compatible order should be checked for even
when m->name or m->type are set.  You actually need to score the entries
to do this properly. The pseudo-code should look like this:

uint best_score = ~0;
of_device_id *best_match = NULL;
for_each(matches) {
	uint score = ~0;
	for_each_compatible(index) {
		if (match->compatible == compatible[index])
			score = index * 10;
	}

	/* Matching name is a bit better than not */
	if (match->name == node->name)
		score--;

	/* Matching type is better than matching name */
	/* (but matching both is even better than that */
	if (match->type == node->type)
		score -= 2;

	if (score < best_score)
		best_match = match;
}
return best_match;

This is actually very similar to the original code. It is an easy
modification. This is very similar to how the of_fdt_is_compatible()
function works.
I like this idea and will make a new patch based on this.

Thanks,
Kevin
g.

Attachments

  • (unnamed) [application/pgp-signature] 490 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help