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

soc: qcom: pbs: 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-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Bjorn Andersson
6187aaae 35791e56

+8 -14
+8 -14
drivers/soc/qcom/qcom-pbs.c
··· 84 84 if (IS_ERR_OR_NULL(pbs)) 85 85 return -EINVAL; 86 86 87 - mutex_lock(&pbs->lock); 87 + guard(mutex)(&pbs->lock); 88 88 ret = regmap_read(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, &val); 89 89 if (ret < 0) 90 - goto out; 90 + return ret; 91 91 92 92 if (val == PBS_CLIENT_SCRATCH2_ERROR) { 93 93 /* PBS error - clear SCRATCH2 register */ 94 94 ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0); 95 95 if (ret < 0) 96 - goto out; 96 + return ret; 97 97 } 98 98 99 99 for (bit_pos = 0; bit_pos < 8; bit_pos++) { ··· 104 104 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 105 105 BIT(bit_pos), 0); 106 106 if (ret < 0) 107 - goto out_clear_scratch1; 107 + break; 108 108 109 109 /* Set the PBS sequence bit position */ 110 110 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, 111 111 BIT(bit_pos), BIT(bit_pos)); 112 112 if (ret < 0) 113 - goto out_clear_scratch1; 113 + break; 114 114 115 115 /* Initiate the SW trigger */ 116 116 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_TRIG_CTL, 117 117 PBS_CLIENT_SW_TRIG_BIT, PBS_CLIENT_SW_TRIG_BIT); 118 118 if (ret < 0) 119 - goto out_clear_scratch1; 119 + break; 120 120 121 121 ret = qcom_pbs_wait_for_ack(pbs, bit_pos); 122 122 if (ret < 0) 123 - goto out_clear_scratch1; 123 + break; 124 124 125 125 /* Clear the PBS sequence bit position */ 126 126 regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, BIT(bit_pos), 0); 127 127 regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, BIT(bit_pos), 0); 128 128 } 129 129 130 - out_clear_scratch1: 131 130 /* Clear all the requested bitmap */ 132 - ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, bitmap, 0); 133 - 134 - out: 135 - mutex_unlock(&pbs->lock); 136 - 137 - return ret; 131 + return regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, bitmap, 0); 138 132 } 139 133 EXPORT_SYMBOL_GPL(qcom_pbs_trigger_event); 140 134