[PATCH v9 01/12] device property: add fwnode_find_reference_args()

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

 



Similarly to fwnode_find_reference(), find and return a named reference
to a fwnode handle, including its arguments. This wrapper facilitates
cleanup handling and improves readability.

Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
---
v9 Changes:
* New patch.
---
 drivers/base/property.c  | 32 ++++++++++++++++++++++++++++++++
 include/linux/property.h |  6 ++++++
 2 files changed, 38 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f42f32ff45fc..b5d82facd7c5 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -645,6 +645,38 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(fwnode_find_reference);
 
+/**
+ * fwnode_find_reference_args - Find named reference to a fwnode_handle with arguments
+ * @fwnode:	Firmware node where to look for the reference
+ * @name:	The name of the reference
+ * @nargs_prop:	The name of the property telling the number of
+ *		arguments in the reference. NULL if @nargs is known,
+ *		otherwise @nargs is ignored. Only relevant on OF.
+ * @nargs:	Number of arguments. Ignored if @nargs_prop is non-NULL.
+ * @index:	Index of the reference
+ *
+ * @index can be used when the named reference holds a table of references.
+ *
+ * The caller is responsible for calling fwnode_handle_put() on the returned
+ * fwnode pointer.
+ *
+ * Return: a pointer to the reference fwnode, when found. Otherwise,
+ * returns an error pointer.
+ */
+struct fwnode_handle *
+fwnode_find_reference_args(const struct fwnode_handle *fwnode,
+			   const char *name, const char *nargs_prop,
+			   unsigned int nargs, unsigned int index,
+			   struct fwnode_reference_args *args)
+{
+	int ret;
+
+	ret = fwnode_property_get_reference_args(fwnode, name, nargs_prop,
+						 nargs, index, args);
+	return ret ? ERR_PTR(ret) : args->fwnode;
+}
+EXPORT_SYMBOL_GPL(fwnode_find_reference_args);
+
 /**
  * fwnode_get_name - Return the name of a node
  * @fwnode: The firmware node
diff --git a/include/linux/property.h b/include/linux/property.h
index 3e83babac0b0..f35ced8f50f7 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -144,6 +144,12 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
 					    const char *name,
 					    unsigned int index);
 
+struct fwnode_handle *
+fwnode_find_reference_args(const struct fwnode_handle *fwnode,
+			   const char *name, const char *nargs_prop,
+			   unsigned int nargs, unsigned int index,
+			   struct fwnode_reference_args *args);
+
 const char *fwnode_get_name(const struct fwnode_handle *fwnode);
 const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
 bool fwnode_name_eq(const struct fwnode_handle *fwnode, const char *name);
-- 
2.34.1





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux