if (!matches)
return NULL;
-------- cp = __of_get_property(node, "compatible", &cplen);
-------- do {
-------- const struct of_device_id *m = matches;
--------
-------- /* Check against matches with current compatible string */
-------- while (m->name[0] || m->type[0] || m->compatible[0]) {
-------- int match = 1;
-------- if (m->name[0])
-------- match &= node->name
-------- && !strcmp(m->name, node->name);
-------- if (m->type[0])
-------- match &= node->type
-------- && !strcmp(m->type, node->type);
-------- if (m->compatible[0])
-------- match &= cp
-------- && !of_compat_cmp(m->compatible, cp,
-------- strlen(m->compatible));
-------- if (match)
-------- return m;
-------- m++;
---- --- }
---- ---
---- --- /* Get node's next compatible string */
---- --- if (cp) {
---- --- l = strlen(cp) + 1;
---- --- cp += l;
---- --- cplen -= l;
++++++++ for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) {
++++++++ score = __of_device_is_compatible(node, matches->compatible,
++++++++ matches->type, matches->name);
++++++++ if (score > best_score) {
++++++++ best_match = matches;
++++++++ best_score = score;
}
---- --- } while (cp && (cplen > 0));
++++++++ }
- /* Get node's next compatible string */
- if (cp) {
- l = strlen(cp) + 1;
- cp += l;
- cplen -= l;
- }
- } while (cp && (cplen > 0));
-
-------- return NULL;
++++++++ return best_match;
}
/**
static inline int of_node_to_nid(struct device_node *device) { return 0; }
#endif
++++++++static inline struct device_node *of_find_matching_node(
++++++++ struct device_node *from,
++++++++ const struct of_device_id *matches)
++++++++{
++++++++ return of_find_matching_node_and_match(from, matches, NULL);
++++++++}
++++++++
+++++ +++/**
+++++ +++ * of_property_count_u8_elems - Count the number of u8 elements in a property
+++++ +++ *
+++++ +++ * @np: device node from which the property value is to be read.
+++++ +++ * @propname: name of the property to be searched.
+++++ +++ *
+++++ +++ * Search for a property in a device node and count the number of u8 elements
+++++ +++ * in it. Returns number of elements on sucess, -EINVAL if the property does
+++++ +++ * not exist or its length does not match a multiple of u8 and -ENODATA if the
+++++ +++ * property does not have a value.
+++++ +++ */
+++++ +++static inline int of_property_count_u8_elems(const struct device_node *np,
+++++ +++ const char *propname)
+++++ +++{
+++++ +++ return of_property_count_elems_of_size(np, propname, sizeof(u8));
+++++ +++}
+++++ +++
+++++ +++/**
+++++ +++ * of_property_count_u16_elems - Count the number of u16 elements in a property
+++++ +++ *
+++++ +++ * @np: device node from which the property value is to be read.
+++++ +++ * @propname: name of the property to be searched.
+++++ +++ *
+++++ +++ * Search for a property in a device node and count the number of u16 elements
+++++ +++ * in it. Returns number of elements on sucess, -EINVAL if the property does
+++++ +++ * not exist or its length does not match a multiple of u16 and -ENODATA if the
+++++ +++ * property does not have a value.
+++++ +++ */
+++++ +++static inline int of_property_count_u16_elems(const struct device_node *np,
+++++ +++ const char *propname)
+++++ +++{
+++++ +++ return of_property_count_elems_of_size(np, propname, sizeof(u16));
+++++ +++}
+++++ +++
+++++ +++/**
+++++ +++ * of_property_count_u32_elems - Count the number of u32 elements in a property
+++++ +++ *
+++++ +++ * @np: device node from which the property value is to be read.
+++++ +++ * @propname: name of the property to be searched.
+++++ +++ *
+++++ +++ * Search for a property in a device node and count the number of u32 elements
+++++ +++ * in it. Returns number of elements on sucess, -EINVAL if the property does
+++++ +++ * not exist or its length does not match a multiple of u32 and -ENODATA if the
+++++ +++ * property does not have a value.
+++++ +++ */
+++++ +++static inline int of_property_count_u32_elems(const struct device_node *np,
+++++ +++ const char *propname)
+++++ +++{
+++++ +++ return of_property_count_elems_of_size(np, propname, sizeof(u32));
+++++ +++}
+++++ +++
+++++ +++/**
+++++ +++ * of_property_count_u64_elems - Count the number of u64 elements in a property
+++++ +++ *
+++++ +++ * @np: device node from which the property value is to be read.
+++++ +++ * @propname: name of the property to be searched.
+++++ +++ *
+++++ +++ * Search for a property in a device node and count the number of u64 elements
+++++ +++ * in it. Returns number of elements on sucess, -EINVAL if the property does
+++++ +++ * not exist or its length does not match a multiple of u64 and -ENODATA if the
+++++ +++ * property does not have a value.
+++++ +++ */
+++++ +++static inline int of_property_count_u64_elems(const struct device_node *np,
+++++ +++ const char *propname)
+++++ +++{
+++++ +++ return of_property_count_elems_of_size(np, propname, sizeof(u64));
+++++ +++}
+++++ +++
/**
* of_property_read_bool - Findfrom a property
* @np: device node from which the property value is to be read.