Re: [PATCH 01/20] ASoC: Intel: catpt: ipc: Use guard() for mutex & spin locks

From: Cezary Rojewski

Date: Thu Jun 11 2026 - 14:49:50 EST


On 6/11/2026 1:58 PM, phucduc.bui@xxxxxxxxx wrote:
From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Clean up the code using guard() for mutex & spin locks.
Merely code refactoring, and no behavior change.

The catpt_dsp_send_msg_timeout is already part of Mark's tree [1]. At the same time I'm against using scoped_guard() for catpt_dsp_do_send_msg(). The existing code is small and transparent, there is no need to tabify it.


[1]: https://lore.kernel.org/all/20260603085827.1964796-2-cezary.rojewski@xxxxxxxxx/

Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/intel/catpt/ipc.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/catpt/ipc.c b/sound/soc/intel/catpt/ipc.c
index 2e3b7a5cbb9b..9614ade5d31a 100644
--- a/sound/soc/intel/catpt/ipc.c
+++ b/sound/soc/intel/catpt/ipc.c
@@ -88,7 +88,6 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev,
struct catpt_ipc_msg *reply, int timeout, const char *name)
{
struct catpt_ipc *ipc = &cdev->ipc;
- unsigned long flags;
int ret;
if (!ipc->ready)
@@ -97,10 +96,10 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev,
(reply && reply->size > ipc->config.outbox_size))
return -EINVAL;
- spin_lock_irqsave(&ipc->lock, flags);
- catpt_ipc_msg_init(ipc, reply);
- catpt_dsp_send_tx(cdev, &request);
- spin_unlock_irqrestore(&ipc->lock, flags);
+ scoped_guard(spinlock_irqsave, &ipc->lock) {
+ catpt_ipc_msg_init(ipc, reply);
+ catpt_dsp_send_tx(cdev, &request);
+ }
ret = catpt_wait_msg_completion(cdev, timeout);
if (ret) {
@@ -131,9 +130,8 @@ int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
struct catpt_ipc *ipc = &cdev->ipc;
int ret;
- mutex_lock(&ipc->mutex);
+ guard(mutex)(&ipc->mutex);
ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout, name);
- mutex_unlock(&ipc->mutex);
return ret;
}