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

soc: qcom: smem_state: simplify locking with guard()

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>

authored by

Krzysztof Kozlowski and committed by
Bjorn Andersson
cd3a3e60 6187aaae

+4 -8
+4 -8
drivers/soc/qcom/smem_state.c
··· 3 3 * Copyright (c) 2015, Sony Mobile Communications Inc. 4 4 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 5 5 */ 6 + #include <linux/cleanup.h> 6 7 #include <linux/device.h> 7 8 #include <linux/list.h> 8 9 #include <linux/module.h> ··· 61 60 { 62 61 struct qcom_smem_state *state; 63 62 64 - mutex_lock(&list_lock); 63 + guard(mutex)(&list_lock); 65 64 66 65 list_for_each_entry(state, &smem_states, list) { 67 66 if (state->of_node == np) { 68 67 kref_get(&state->refcount); 69 - goto unlock; 68 + return state; 70 69 } 71 70 } 72 - state = ERR_PTR(-EPROBE_DEFER); 73 - 74 - unlock: 75 - mutex_unlock(&list_lock); 76 - 77 - return state; 71 + return ERR_PTR(-EPROBE_DEFER); 78 72 } 79 73 80 74 /**