@@ -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);
}