]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: qcom: q6asm: Use guard() for spin locks
authorSrinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Thu, 23 Oct 2025 10:24:44 +0000 (11:24 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 5 Nov 2025 13:28:35 +0000 (13:28 +0000)
Clean up the code using guard() for spin locks.

No functional changes, just cleanup.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20251023102444.88158-21-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/qcom/qdsp6/q6asm.c

index 431a99776dccb0d489466be6133c6d188e8d9f23..e7295b7b246105733a3728d7e0f21e68fa6a730b 100644 (file)
@@ -571,9 +571,8 @@ static struct audio_client *q6asm_get_audio_client(struct q6asm *a,
                                                   int session_id)
 {
        struct audio_client *ac = NULL;
-       unsigned long flags;
 
-       spin_lock_irqsave(&a->slock, flags);
+       guard(spinlock_irqsave)(&a->slock);
        if ((session_id <= 0) || (session_id > MAX_SESSIONS)) {
                dev_err(a->dev, "invalid session: %d\n", session_id);
                goto err;
@@ -588,7 +587,6 @@ static struct audio_client *q6asm_get_audio_client(struct q6asm *a,
        ac = a->session[session_id];
        kref_get(&ac->refcount);
 err:
-       spin_unlock_irqrestore(&a->slock, flags);
        return ac;
 }
 
@@ -681,15 +679,13 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
                client_event = ASM_CLIENT_EVENT_DATA_WRITE_DONE;
                if (ac->io_mode & ASM_SYNC_IO_MODE) {
                        phys_addr_t phys;
-                       unsigned long flags;
                        int token = hdr->token & ASM_WRITE_TOKEN_MASK;
 
-                       spin_lock_irqsave(&ac->lock, flags);
+                       guard(spinlock_irqsave)(&ac->lock);
 
                        port =  &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
 
                        if (!port->buf) {
-                               spin_unlock_irqrestore(&ac->lock, flags);
                                ret = 0;
                                goto done;
                        }
@@ -700,11 +696,9 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
                            upper_32_bits(phys) != result->status) {
                                dev_err(ac->dev, "Expected addr %pa\n",
                                        &port->buf[token].phys);
-                               spin_unlock_irqrestore(&ac->lock, flags);
                                ret = -EINVAL;
                                goto done;
                        }
-                       spin_unlock_irqrestore(&ac->lock, flags);
                        atomic_set(&port->hw_ptr, token + 1);
                }
                break;
@@ -712,13 +706,11 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
                client_event = ASM_CLIENT_EVENT_DATA_READ_DONE;
                if (ac->io_mode & ASM_SYNC_IO_MODE) {
                        struct asm_data_cmd_read_v2_done *done = data->payload;
-                       unsigned long flags;
                        phys_addr_t phys;
 
-                       spin_lock_irqsave(&ac->lock, flags);
+                       guard(spinlock_irqsave)(&ac->lock);
                        port =  &ac->port[SNDRV_PCM_STREAM_CAPTURE];
                        if (!port->buf) {
-                               spin_unlock_irqrestore(&ac->lock, flags);
                                ret = 0;
                                goto done;
                        }
@@ -732,11 +724,9 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
                                        &port->buf[hdr->token].phys,
                                        done->buf_addr_lsw,
                                        done->buf_addr_msw);
-                               spin_unlock_irqrestore(&ac->lock, flags);
                                ret = -EINVAL;
                                goto done;
                        }
-                       spin_unlock_irqrestore(&ac->lock, flags);
                }
 
                break;
@@ -1561,14 +1551,12 @@ EXPORT_SYMBOL_GPL(q6asm_write_async);
 static void q6asm_reset_buf_state(struct audio_client *ac)
 {
        struct audio_port_data *port;
-       unsigned long flags;
 
-       spin_lock_irqsave(&ac->lock, flags);
+       guard(spinlock_irqsave)(&ac->lock);
        port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
        port->dsp_buf = 0;
        port = &ac->port[SNDRV_PCM_STREAM_CAPTURE];
        port->dsp_buf = 0;
-       spin_unlock_irqrestore(&ac->lock, flags);
 }
 
 static int __q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd,