summaryrefslogtreecommitdiff
path: root/include/linux/property.h
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2024-02-17 19:42:35 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-03-25 22:50:08 +0300
commit77fc5151f9c0e6068f1567b73d33e75a0c35333d (patch)
tree969f055d2b40c70d8c6a0fdcab8cc7917226ad91 /include/linux/property.h
parent4cece764965020c22cff7665b18a012006359095 (diff)
downloadlinux-77fc5151f9c0e6068f1567b73d33e75a0c35333d.tar.xz
device property: Move fwnode_handle_put() into property.h
By having this function as static inline in the header, the compiler is able to see if can optmize the call out if (IS_ERR_OR_NULL(fwnode)) This will allow a simpler DEFINE_FREE() call in the following patch. Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20240217164249.921878-2-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'include/linux/property.h')
-rw-r--r--include/linux/property.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/property.h b/include/linux/property.h
index 3a1045eb786c..93d992a92f59 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -180,7 +180,19 @@ struct fwnode_handle *device_get_named_child_node(const struct device *dev,
const char *childname);
struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
-void fwnode_handle_put(struct fwnode_handle *fwnode);
+
+/**
+ * fwnode_handle_put - Drop reference to a device node
+ * @fwnode: Pointer to the device node to drop the reference to.
+ *
+ * This has to be used when terminating device_for_each_child_node() iteration
+ * with break or return to prevent stale device node references from being left
+ * behind.
+ */
+static inline void fwnode_handle_put(struct fwnode_handle *fwnode)
+{
+ fwnode_call_void_op(fwnode, put);
+}
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);