]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: backend: use __free(fwnode_handle) for automatic cleanup
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Sat, 21 Mar 2026 10:01:51 +0000 (12:01 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 21 Mar 2026 12:02:24 +0000 (12:02 +0000)
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>
drivers/iio/industrialio-backend.c

index 1afd00763da9e1f07160990fe3f729cbb7295d7f..10e689f494419b99a47364c258c42a979a332176 100644 (file)
@@ -967,7 +967,6 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_data_transfer_addr, "IIO_BACKEND");
 static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, const char *name,
                                                         struct fwnode_handle *fwnode)
 {
-       struct fwnode_handle *fwnode_back;
        struct iio_backend *back;
        unsigned int index;
        int ret;
@@ -982,7 +981,8 @@ static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, con
                index = 0;
        }
 
-       fwnode_back = fwnode_find_reference(fwnode, "io-backends", index);
+       struct fwnode_handle *fwnode_back __free(fwnode_handle) =
+               fwnode_find_reference(fwnode, "io-backends", index);
        if (IS_ERR(fwnode_back))
                return dev_err_cast_probe(dev, fwnode_back,
                                          "Cannot get Firmware reference\n");
@@ -992,7 +992,6 @@ static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, con
                if (!device_match_fwnode(back->dev, fwnode_back))
                        continue;
 
-               fwnode_handle_put(fwnode_back);
                ret = __devm_iio_backend_get(dev, back);
                if (ret)
                        return ERR_PTR(ret);
@@ -1003,7 +1002,6 @@ static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, con
                return back;
        }
 
-       fwnode_handle_put(fwnode_back);
        return ERR_PTR(-EPROBE_DEFER);
 }