mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-10-11 20:27:42 +10:00
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>
This commit is contained in:
parent
e534612ec7
commit
7fe3067b88
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/delay.h>
|
||||
@ -140,30 +141,26 @@ static int clk_spmi_pmic_div_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
{
|
||||
struct clkdiv *clkdiv = to_clkdiv(hw);
|
||||
unsigned int div_factor = div_to_div_factor(parent_rate / rate);
|
||||
unsigned long flags;
|
||||
bool enabled;
|
||||
int ret;
|
||||
|
||||
spin_lock_irqsave(&clkdiv->lock, flags);
|
||||
guard(spinlock_irqsave)(&clkdiv->lock);
|
||||
|
||||
enabled = is_spmi_pmic_clkdiv_enabled(clkdiv);
|
||||
if (enabled) {
|
||||
ret = spmi_pmic_clkdiv_set_enable_state(clkdiv, false);
|
||||
if (ret)
|
||||
goto unlock;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_update_bits(clkdiv->regmap, clkdiv->base + REG_DIV_CTL1,
|
||||
DIV_CTL1_DIV_FACTOR_MASK, div_factor);
|
||||
if (ret)
|
||||
goto unlock;
|
||||
return ret;
|
||||
|
||||
if (enabled)
|
||||
ret = __spmi_pmic_clkdiv_set_enable_state(clkdiv, true,
|
||||
div_factor);
|
||||
|
||||
unlock:
|
||||
spin_unlock_irqrestore(&clkdiv->lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user