@@ -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
@@ -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);
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@analog.com> --- v9 Changes: * New patch. --- drivers/base/property.c | 32 ++++++++++++++++++++++++++++++++ include/linux/property.h | 6 ++++++ 2 files changed, 38 insertions(+)