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

Configure Feed

Select the types of activity you want to include in your feed.

clk: qcom: spmi-pmic-div: 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/20240823-cleanup-h-guard-clk-qcom-v1-3-68bb9601c9dd@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Bjorn Andersson
7fe3067b e534612e

+5 -8
+5 -8
drivers/clk/qcom/clk-spmi-pmic-div.c
··· 3 3 */ 4 4 5 5 #include <linux/bitops.h> 6 + #include <linux/cleanup.h> 6 7 #include <linux/clk.h> 7 8 #include <linux/clk-provider.h> 8 9 #include <linux/delay.h> ··· 141 140 { 142 141 struct clkdiv *clkdiv = to_clkdiv(hw); 143 142 unsigned int div_factor = div_to_div_factor(parent_rate / rate); 144 - unsigned long flags; 145 143 bool enabled; 146 144 int ret; 147 145 148 - spin_lock_irqsave(&clkdiv->lock, flags); 146 + guard(spinlock_irqsave)(&clkdiv->lock); 147 + 149 148 enabled = is_spmi_pmic_clkdiv_enabled(clkdiv); 150 149 if (enabled) { 151 150 ret = spmi_pmic_clkdiv_set_enable_state(clkdiv, false); 152 151 if (ret) 153 - goto unlock; 152 + return ret; 154 153 } 155 154 156 155 ret = regmap_update_bits(clkdiv->regmap, clkdiv->base + REG_DIV_CTL1, 157 156 DIV_CTL1_DIV_FACTOR_MASK, div_factor); 158 157 if (ret) 159 - goto unlock; 158 + return ret; 160 159 161 160 if (enabled) 162 161 ret = __spmi_pmic_clkdiv_set_enable_state(clkdiv, true, 163 162 div_factor); 164 - 165 - unlock: 166 - spin_unlock_irqrestore(&clkdiv->lock, flags); 167 - 168 163 return ret; 169 164 } 170 165