]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc: qcom: smem_state: simplify locking with guard()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 22 Aug 2024 16:48:53 +0000 (18:48 +0200)
committerBjorn Andersson <andersson@kernel.org>
Sun, 6 Oct 2024 03:12:48 +0000 (22:12 -0500)
Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240822164853.231087-4-krzysztof.kozlowski@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/smem_state.c

index e848cc9a3cf801be1743e4ac1bcfc2701ae993df..d9bfac6c54fb8a05b8545c7ee4e451eabdd35822 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (c) 2015, Sony Mobile Communications Inc.
  * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  */
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -60,20 +61,15 @@ static struct qcom_smem_state *of_node_to_state(struct device_node *np)
 {
        struct qcom_smem_state *state;
 
-       mutex_lock(&list_lock);
+       guard(mutex)(&list_lock);
 
        list_for_each_entry(state, &smem_states, list) {
                if (state->of_node == np) {
                        kref_get(&state->refcount);
-                       goto unlock;
+                       return state;
                }
        }
-       state = ERR_PTR(-EPROBE_DEFER);
-
-unlock:
-       mutex_unlock(&list_lock);
-
-       return state;
+       return ERR_PTR(-EPROBE_DEFER);
 }
 
 /**