diff mbox series

[v3,1/9] of: add of_property_read_string_array_index()

Message ID 20220325113148.588163-2-clement.leger@bootlin.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series introduce fwnode in the I2C subsystem | expand

Commit Message

Clément Léger March 25, 2022, 11:31 a.m. UTC
Add of_property_read_string_array_index() which allows to read a string
array starting at a specific index.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 include/linux/of.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Rob Herring (Arm) March 29, 2022, 11:32 p.m. UTC | #1
On Fri, 25 Mar 2022 12:31:40 +0100, Clément Léger wrote:
> Add of_property_read_string_array_index() which allows to read a string
> array starting at a specific index.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
>  include/linux/of.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>
diff mbox series

Patch

diff --git a/include/linux/of.h b/include/linux/of.h
index 2dc77430a91a..93f04c530bd1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1115,6 +1115,28 @@  static inline int of_property_read_string_array(const struct device_node *np,
 	return of_property_read_string_helper(np, propname, out_strs, sz, 0);
 }
 
+/**
+ * of_property_read_string_array_index() - Read an array of strings from a
+ * multiple strings property starting at a specified index
+ * @np:		device node from which the property value is to be read.
+ * @propname:	name of the property to be searched.
+ * @out_strs:	output array of string pointers.
+ * @sz:		number of array elements to read.
+ * @index:	index to start reading from
+ *
+ * Search for a property in a device tree node and retrieve a list of
+ * terminated string values (pointer to data, not a copy) in that property
+ * starting at specified index.
+ *
+ * Return: If @out_strs is NULL, the number of strings in the property is returned.
+ */
+static inline int of_property_read_string_array_index(const struct device_node *np,
+						      const char *propname,
+						      const char **out_strs,
+						      size_t sz, int index)
+{
+	return of_property_read_string_helper(np, propname, out_strs, sz, index);
+}
 /**
  * of_property_count_strings() - Find and return the number of strings from a
  * multiple strings property.