|
@@ -250,6 +250,8 @@ extern struct device_node *of_find_node_with_property(
|
|
|
extern struct property *of_find_property(const struct device_node *np,
|
|
|
const char *name,
|
|
|
int *lenp);
|
|
|
+extern int of_property_count_elems_of_size(const struct device_node *np,
|
|
|
+ const char *propname, int elem_size);
|
|
|
extern int of_property_read_u32_index(const struct device_node *np,
|
|
|
const char *propname,
|
|
|
u32 index, u32 *out_value);
|
|
@@ -431,6 +433,12 @@ static inline struct device_node *of_find_compatible_node(
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+static inline int of_property_count_elems_of_size(const struct device_node *np,
|
|
|
+ const char *propname, int elem_size)
|
|
|
+{
|
|
|
+ return -ENOSYS;
|
|
|
+}
|
|
|
+
|
|
|
static inline int of_property_read_u32_index(const struct device_node *np,
|
|
|
const char *propname, u32 index, u32 *out_value)
|
|
|
{
|
|
@@ -569,6 +577,74 @@ extern int of_node_to_nid(struct device_node *np);
|
|
|
static inline int of_node_to_nid(struct device_node *device) { return 0; }
|
|
|
#endif
|
|
|
|
|
|
+/**
|
|
|
+ * 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.
|