Commit 59ed5e2d authored by Jonathan Cameron's avatar Jonathan Cameron

device property: Add cleanup.h based fwnode_handle_put() scope based cleanup.

Useful where the fwnode_handle was obtained from a call such as
fwnode_find_reference() as it will safely do nothing if IS_ERR() is true
and will automatically release the reference on the variable leaving
scope.
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240217164249.921878-3-jic23@kernel.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 77fc5151
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/args.h> #include <linux/args.h>
#include <linux/array_size.h> #include <linux/array_size.h>
#include <linux/bits.h> #include <linux/bits.h>
#include <linux/cleanup.h>
#include <linux/fwnode.h> #include <linux/fwnode.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -194,6 +195,8 @@ static inline void fwnode_handle_put(struct fwnode_handle *fwnode) ...@@ -194,6 +195,8 @@ static inline void fwnode_handle_put(struct fwnode_handle *fwnode)
fwnode_call_void_op(fwnode, put); fwnode_call_void_op(fwnode, put);
} }
DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T))
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); 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); int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment