lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55924e747e4891ae75288343d9f3ad2361174bd2.1748447035.git.Jonathan.Santos@analog.com>
Date: Thu, 29 May 2025 19:48:17 -0300
From: Jonathan Santos <Jonathan.Santos@...log.com>
To: <linux-iio@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-gpio@...r.kernel.org>,
        <linux-acpi@...r.kernel.org>
CC: Jonathan Santos <Jonathan.Santos@...log.com>, <andy@...nel.org>,
        <nuno.sa@...log.com>, <Michael.Hennerich@...log.com>,
        <marcelo.schmitt@...log.com>, <jic23@...nel.org>, <robh@...nel.org>,
        <krzk+dt@...nel.org>, <conor+dt@...nel.org>,
        <marcelo.schmitt1@...il.com>, <linus.walleij@...aro.org>,
        <brgl@...ev.pl>, <lgirdwood@...il.com>, <broonie@...nel.org>,
        <jonath4nns@...il.com>, <dlechner@...libre.com>,
        <andriy.shevchenko@...ux.intel.com>, <rafael@...nel.org>,
        <djrscally@...il.com>
Subject: [PATCH v9 01/12] device property: add fwnode_find_reference_args()

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@...log.com>
---
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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ