Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: backend: use __free(fwnode_handle) for automatic cleanup

Convert __devm_iio_backend_fwnode_get() to use the __free(fwnode_handle)
cleanup attribute for the fwnode_back variable, removing the need for
manual fwnode_handle_put() calls. Move the declaration closer to its
first use, narrowing its scope.

No functional change.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
0dc1147b e7ecdcbc

+2 -4
+2 -4
drivers/iio/industrialio-backend.c
··· 967 967 static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, const char *name, 968 968 struct fwnode_handle *fwnode) 969 969 { 970 - struct fwnode_handle *fwnode_back; 971 970 struct iio_backend *back; 972 971 unsigned int index; 973 972 int ret; ··· 981 982 index = 0; 982 983 } 983 984 984 - fwnode_back = fwnode_find_reference(fwnode, "io-backends", index); 985 + struct fwnode_handle *fwnode_back __free(fwnode_handle) = 986 + fwnode_find_reference(fwnode, "io-backends", index); 985 987 if (IS_ERR(fwnode_back)) 986 988 return dev_err_cast_probe(dev, fwnode_back, 987 989 "Cannot get Firmware reference\n"); ··· 992 992 if (!device_match_fwnode(back->dev, fwnode_back)) 993 993 continue; 994 994 995 - fwnode_handle_put(fwnode_back); 996 995 ret = __devm_iio_backend_get(dev, back); 997 996 if (ret) 998 997 return ERR_PTR(ret); ··· 1002 1003 return back; 1003 1004 } 1004 1005 1005 - fwnode_handle_put(fwnode_back); 1006 1006 return ERR_PTR(-EPROBE_DEFER); 1007 1007 } 1008 1008