On Wed, 19 Feb 2014 08:54:57 -0600, Rob Herring <robherring2@xxxxxxxxx> wrote: > On Wed, Feb 19, 2014 at 8:14 AM, Grant Likely <grant.likely@xxxxxxxxxx> wrote: > > From: Kevin Hao <haokexin@xxxxxxxxx> > > > > In the current implementation of __of_match_node(), it will compare > > each given match entry against all the node's compatible strings > > with of_device_is_compatible(). > > > > To achieve multiple compatible strings per node with ordering from > > specific to generic, this requires given matches to be ordered from > > specific to generic. For most of the drivers this is not true and > > also an alphabetical ordering is more sane there. > > > > Therefore, we define a following priority order for the match, and > > then scan all the entries to find the best match. > > 1. specific compatible && type && name > > 2. specific compatible && type > > 3. specific compatible && name > > 4. specific compatible > > 5. general compatible && type && name > > 6. general compatible && type > > 7. general compatible && name > > 8. general compatible > > 9. type && name > > 10. type > > 11. name > > While I agree this should be the right order, I worry that this may be > changing the matching in some case as all previous attempts have done. True, but they should be few and far between, and they can be fixed up with bugfixes in drivers. This time we actually have test cases that show the behaviour is correct. The previous versions failed the current test cases (I checked). > > + /* Compatible match has highest priority */ > > + if (compat && compat[0]) { > > + cp = __of_get_property(device, "compatible", &cplen); > > + if (!cp) > > + return 0; > > + for (index = 0; cplen > 0; index++, cp += l, cplen -= l) { > > + l = strlen(cp) + 1; > > This could use of_property_for_each_string. Good point. Changed. g. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html