public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
	ranjani.sridharan@linux.intel.com,
	yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
	daniel.baluta@nxp.com
Subject: [PATCH 7/7] ASoC: SOF: ipc/ops: Use guard() for spinlocks
Date: Mon, 12 Jan 2026 12:10:04 +0200	[thread overview]
Message-ID: <20260112101004.7648-8-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20260112101004.7648-1-peter.ujfalusi@linux.intel.com>

Replace the manual spinlock lock/unlock pairs with guard().

Only code refactoring, and no behavior change.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/sof/ipc.c |  4 +---
 sound/soc/sof/ops.c | 34 +++++++---------------------------
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index 3fdeb07bafa3..e6d8894b8ef6 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -47,7 +47,7 @@ int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
 	 * The spin-lock is needed to protect message objects against other
 	 * atomic contexts.
 	 */
-	spin_lock_irq(&sdev->ipc_lock);
+	guard(spinlock_irq)(&sdev->ipc_lock);
 
 	/* initialise the message */
 	msg = &ipc->msg;
@@ -66,8 +66,6 @@ int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
 	if (!ret)
 		msg->ipc_complete = false;
 
-	spin_unlock_irq(&sdev->ipc_lock);
-
 	return ret;
 }
 
diff --git a/sound/soc/sof/ops.c b/sound/soc/sof/ops.c
index bd52e7ec6883..74c04dcf4167 100644
--- a/sound/soc/sof/ops.c
+++ b/sound/soc/sof/ops.c
@@ -38,13 +38,8 @@ bool snd_sof_pci_update_bits_unlocked(struct snd_sof_dev *sdev, u32 offset,
 bool snd_sof_pci_update_bits(struct snd_sof_dev *sdev, u32 offset,
 			     u32 mask, u32 value)
 {
-	unsigned long flags;
-	bool change;
-
-	spin_lock_irqsave(&sdev->hw_lock, flags);
-	change = snd_sof_pci_update_bits_unlocked(sdev, offset, mask, value);
-	spin_unlock_irqrestore(&sdev->hw_lock, flags);
-	return change;
+	guard(spinlock_irqsave)(&sdev->hw_lock);
+	return snd_sof_pci_update_bits_unlocked(sdev, offset, mask, value);
 }
 EXPORT_SYMBOL(snd_sof_pci_update_bits);
 
@@ -90,28 +85,16 @@ EXPORT_SYMBOL(snd_sof_dsp_update_bits64_unlocked);
 bool snd_sof_dsp_update_bits(struct snd_sof_dev *sdev, u32 bar, u32 offset,
 			     u32 mask, u32 value)
 {
-	unsigned long flags;
-	bool change;
-
-	spin_lock_irqsave(&sdev->hw_lock, flags);
-	change = snd_sof_dsp_update_bits_unlocked(sdev, bar, offset, mask,
-						  value);
-	spin_unlock_irqrestore(&sdev->hw_lock, flags);
-	return change;
+	guard(spinlock_irqsave)(&sdev->hw_lock);
+	return snd_sof_dsp_update_bits_unlocked(sdev, bar, offset, mask, value);
 }
 EXPORT_SYMBOL(snd_sof_dsp_update_bits);
 
 bool snd_sof_dsp_update_bits64(struct snd_sof_dev *sdev, u32 bar, u32 offset,
 			       u64 mask, u64 value)
 {
-	unsigned long flags;
-	bool change;
-
-	spin_lock_irqsave(&sdev->hw_lock, flags);
-	change = snd_sof_dsp_update_bits64_unlocked(sdev, bar, offset, mask,
-						    value);
-	spin_unlock_irqrestore(&sdev->hw_lock, flags);
-	return change;
+	guard(spinlock_irqsave)(&sdev->hw_lock);
+	return snd_sof_dsp_update_bits64_unlocked(sdev, bar, offset, mask, value);
 }
 EXPORT_SYMBOL(snd_sof_dsp_update_bits64);
 
@@ -134,11 +117,8 @@ void snd_sof_dsp_update_bits_forced_unlocked(struct snd_sof_dev *sdev, u32 bar,
 void snd_sof_dsp_update_bits_forced(struct snd_sof_dev *sdev, u32 bar,
 				    u32 offset, u32 mask, u32 value)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&sdev->hw_lock, flags);
+	guard(spinlock_irqsave)(&sdev->hw_lock);
 	snd_sof_dsp_update_bits_forced_unlocked(sdev, bar, offset, mask, value);
-	spin_unlock_irqrestore(&sdev->hw_lock, flags);
 }
 EXPORT_SYMBOL(snd_sof_dsp_update_bits_forced);
 
-- 
2.52.0


  parent reply	other threads:[~2026-01-12 10:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 10:09 [PATCH 0/7] ASoC: SOF: Use guard()/scoped_guard() for locks when makes sense Peter Ujfalusi
2026-01-12 10:09 ` [PATCH 1/7] ASoC: SOF: Use guard()/scoped_guard() for mutex locks where it " Peter Ujfalusi
2026-01-12 10:09 ` [PATCH 2/7] ASoC: SOF: Intel: " Peter Ujfalusi
2026-01-12 10:10 ` [PATCH 3/7] ASoC: SOF: amd: acp-ipc: Use guard() for spinlock_irq() Peter Ujfalusi
2026-01-12 10:10 ` [PATCH 4/7] ASoC: SOF: imx: imx-common: Use guard() for spinlock_irqsafe() Peter Ujfalusi
2026-01-12 10:10 ` [PATCH 5/7] ASoC: SOF: mediatek: mtk-adsp-common: Use guard() for spinlock_irqsave Peter Ujfalusi
2026-01-12 10:10 ` [PATCH 6/7] ASoC: SOF: Intel: Use guard() for spinlocks where it makes sense Peter Ujfalusi
2026-01-12 10:10 ` Peter Ujfalusi [this message]
2026-01-13 13:49 ` [PATCH 0/7] ASoC: SOF: Use guard()/scoped_guard() for locks when " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260112101004.7648-8-peter.ujfalusi@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox