From: bui duc phuc <[email protected]>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <[email protected]>
---
sound/soc/codecs/cs35l56-shared.c | 6 ++--
sound/soc/codecs/cs35l56.c | 56 +++++++++++++++----------------
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
index f14e2eaaa4ee..6cb835a5aaac 100644
--- a/sound/soc/codecs/cs35l56-shared.c
+++ b/sound/soc/codecs/cs35l56-shared.c
@@ -645,12 +645,12 @@ irqreturn_t cs35l56_irq(int irq, void *data)
if (!cs35l56_base->init_done)
return IRQ_NONE;
- mutex_lock(&cs35l56_base->irq_lock);
+ guard(mutex)(&cs35l56_base->irq_lock);
rv = pm_runtime_resume_and_get(cs35l56_base->dev);
if (rv < 0) {
dev_err(cs35l56_base->dev, "irq: failed to get pm_runtime: %d\n", rv);
- goto err_unlock;
+ return ret;
}
regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_STATUS, &val);
@@ -692,8 +692,6 @@ irqreturn_t cs35l56_irq(int irq, void *data)
err:
pm_runtime_put(cs35l56_base->dev);
-err_unlock:
- mutex_unlock(&cs35l56_base->irq_lock);
return ret;
}
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 570a68829ccd..98ebf38c9bb7 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -848,42 +848,40 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56, bool firmware_missing
if (ret)
goto err;
- mutex_lock(&cs35l56->base.irq_lock);
+ scoped_guard(mutex, &cs35l56->base.irq_lock) {
+ reinit_completion(&cs35l56->init_completion);
- reinit_completion(&cs35l56->init_completion);
-
- cs35l56->soft_resetting = true;
- cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
+ cs35l56->soft_resetting = true;
+ cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
- if (cs35l56->sdw_peripheral) {
- /*
- * The system-reset causes the CS35L56 to detach from the bus.
- * Wait for the manager to re-enumerate the CS35L56 and
- * cs35l56_init() to run again.
- */
- if (!wait_for_completion_timeout(&cs35l56->init_completion,
- msecs_to_jiffies(5000))) {
- dev_err(cs35l56->base.dev, "%s: init_completion timed out (SDW)\n",
- __func__);
- goto err_unlock;
+ if (cs35l56->sdw_peripheral) {
+ /*
+ * The system-reset causes the CS35L56 to detach from the bus.
+ * Wait for the manager to re-enumerate the CS35L56 and
+ * cs35l56_init() to run again.
+ */
+ if (!wait_for_completion_timeout(&cs35l56->init_completion,
+ msecs_to_jiffies(5000))) {
+ dev_err(cs35l56->base.dev, "%s: init_completion timed out (SDW)\n",
+ __func__);
+ goto err;
+ }
+ } else if (cs35l56_init(cs35l56)) {
+ goto err;
}
- } else if (cs35l56_init(cs35l56)) {
- goto err_unlock;
- }
- /* Check if the firmware is still reported missing */
- cs35l56_warn_if_firmware_missing(&cs35l56->base);
+ /* Check if the firmware is still reported missing */
+ cs35l56_warn_if_firmware_missing(&cs35l56->base);
- regmap_clear_bits(cs35l56->base.regmap,
- cs35l56->base.fw_reg->prot_sts,
- CS35L56_FIRMWARE_MISSING);
- cs35l56->base.fw_patched = true;
+ regmap_clear_bits(cs35l56->base.regmap,
+ cs35l56->base.fw_reg->prot_sts,
+ CS35L56_FIRMWARE_MISSING);
+ cs35l56->base.fw_patched = true;
- if (cs35l56_write_cal(cs35l56) == 0)
- cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT);
+ if (cs35l56_write_cal(cs35l56) == 0)
+ cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT);
+ }
-err_unlock:
- mutex_unlock(&cs35l56->base.irq_lock);
err:
cs35l56_enable_sdw_interrupts(cs35l56);
}
--
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.