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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

Attachment: pgpO9ofXyswQy.pgp
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux