[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240211174237.182947-9-jic23@kernel.org>
Date: Sun, 11 Feb 2024 17:42:36 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: linux-iio@...r.kernel.org,
Rob Herring <robh@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
linux-kernel@...r.kernel.org,
Julia Lawall <Julia.Lawall@...ia.fr>
Cc: Peter Zijlstra <peterz@...radead.org>,
Nicolas Palix <nicolas.palix@...g.fr>,
Sumera Priyadarsini <sylphrenadin@...il.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>,
linux-acpi@...r.kernel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nuno Sá <nuno.sa@...log.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: [PATCH 8/8] iio: adc: adi-axi-adc: Use __free(device_node) and guard(mutex)
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Avoid need to manually handle of_node_put() or the unlocking of the
mutex.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
---
drivers/iio/adc/adi-axi-adc.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index c247ff1541d2..3c85e8a6467b 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -248,19 +248,19 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)
{
const struct adi_axi_adc_core_info *info;
struct adi_axi_adc_client *cl;
- struct device_node *cln;
info = of_device_get_match_data(dev);
if (!info)
return ERR_PTR(-ENODEV);
- cln = of_parse_phandle(dev->of_node, "adi,adc-dev", 0);
+ struct device_node *cln __free(device_node) =
+ of_parse_phandle(dev->of_node, "adi,adc-dev", 0);
if (!cln) {
dev_err(dev, "No 'adi,adc-dev' node defined\n");
return ERR_PTR(-ENODEV);
}
- mutex_lock(®istered_clients_lock);
+ guard(mutex)(®istered_clients_lock);
list_for_each_entry(cl, ®istered_clients, entry) {
if (!cl->dev)
@@ -269,22 +269,14 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)
if (cl->dev->of_node != cln)
continue;
- if (!try_module_get(cl->dev->driver->owner)) {
- mutex_unlock(®istered_clients_lock);
- of_node_put(cln);
+ if (!try_module_get(cl->dev->driver->owner))
return ERR_PTR(-ENODEV);
- }
get_device(cl->dev);
cl->info = info;
- mutex_unlock(®istered_clients_lock);
- of_node_put(cln);
return cl;
}
- mutex_unlock(®istered_clients_lock);
- of_node_put(cln);
-
return ERR_PTR(-EPROBE_DEFER);
}
--
2.43.1
Powered by blists - more mailing lists