diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-02-17 16:42:36 +0000 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-02-26 22:00:23 +0000 |
commit | 1a47625aab7dfab21554048d9191c1aa5c96cc7a (patch) | |
tree | 0cb011ca9bfd3bdba9719a161a82da1bb5babaee | |
parent | b5b70383ef761a705c78995f9ab92fdf1b4dea03 (diff) | |
download | iio-1a47625aab7dfab21554048d9191c1aa5c96cc7a.tar.gz |
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240217164249.921878-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | include/linux/property.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/property.h b/include/linux/property.h index 151bcab4f92a1b..9e67c3c4df6efa 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -12,6 +12,7 @@ #include <linux/args.h> #include <linux/bits.h> +#include <linux/cleanup.h> #include <linux/fwnode.h> #include <linux/stddef.h> #include <linux/types.h> @@ -201,6 +202,8 @@ static inline void fwnode_handle_put(struct fwnode_handle *fwnode) 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_byname(const struct fwnode_handle *fwnode, const char *name); |