From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 545A43AB299 for ; Wed, 29 Apr 2026 09:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777454209; cv=none; b=PWZ1hvlIG+f0gXbDjY8S2FEo2iPl+4tr33FuOTj++LAKwxXwt8v3Ik9ybjMscyGki//U9W++/MBPyqA2VMv9aSd+XFqGrNfVdnSJqqQKkMdOj9bHSKEUb4dHudrCxwaDnLtGWSKLn9bJJA+m1J1gz55AvAjEY3U4cu/IePh+KhU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777454209; c=relaxed/simple; bh=VjVSRWG2abSYsb/wTYHT+3dbM9kBQXjmurL6mO+xRKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lXR1ooux9VxBr1sCI58CQnBOn3PXnZwgUFEZiR6c7MTGtdLz2KjBgR5Rkun9bHdYzMLjJO+m7Ww0NU+nJPCd7wDv44CBI+mNSAUCrDu816crDFDpPk8JxoVInRFbzhkU19N7mq5Sfeb3vE0Kc+Y9ztguLQMLkSzFEjPJe9cKPCQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lPWBSdbt; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lPWBSdbt" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-82f943870baso5271879b3a.1 for ; Wed, 29 Apr 2026 02:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777454207; x=1778059007; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wOQASXH1zi/ymC17DpxSnsJj0Xv7qAzrcrKjqR45UNg=; b=lPWBSdbtgNRXNAF8V2igYjCWgjxe2SpCwh1bgKJzs9q7p1C20j2DSA3sVu/Sn8TwLw YBb6P4TvN77wSNcEQoJ1UQ2MG4n9YDDR+RJDi7RJYc9wqtCisjD8jrc+dtxGaP0D0aPe 9oV6McGLPoPNavRP9TJJFKc1orQLIcjLFoLIVr2GwfTxKacm06KQ8bpKeLIDULgBIqGd gBEgdOf9yzPhV8BRQCuLy6oZBQiJRlPw3CG6U9h+PZ8fU2cvUVlXOIzhoeG0UVrCPNoX BshN1YjzBiSOtEmcuXEp4CrtK24bavdXkK4JfiilFiMMdt2MFMeTACXXnCTSz1Vgrzmy +VPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777454207; x=1778059007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wOQASXH1zi/ymC17DpxSnsJj0Xv7qAzrcrKjqR45UNg=; b=Bbf9V1KLRiMX+8FQIAnomhR/WkOOAZqSwgen+P4qLBdJYU9k6o3qk7sE/DjgJXFnvW XDJJQuACOT0nywwQybGWI5R3ZPod5As/isFyJTjRjb9lK761U8F0FQMi4dKf1DbEa9F/ M7RI7CdmeqllLkrnXZLCH9+gSKySoR/3PvH8TJWU3YprL9WbEYeXFQqW+3MTJm1sHSjp 5ERtHJ2j21DpUcEb65w0QC1Fu6I+i2Rqq6B7jRHYDQtW+UNmJPWkjpUjlojRBVUpLI1F EuDo3aGdbwMfvg68Yhwvau9yN2HyZaJXBlDerElwSxPfwgPppWFWenCzy6wBkqP/8Imt S0OA== X-Forwarded-Encrypted: i=1; AFNElJ+cGV5z+3eZWZuewoI41FPFmW33lMk0Q2KAs2vhUIvvafGJUgY43+3IddDG6Xq5rptRgNDjFHauC9SumnA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxa2hK/Kdd++2oGxwjT4LxfJ9ZQPpnW+gMcqkbA06CreeRMUUDz q3ZlSE0TN5nhGxVVjPeQecvMaMNs1QTMy+9gTulAkg6o693cmqlDaaa0 X-Gm-Gg: AeBDiescNpnFsryUak93+rTeedxPlPGHu2nHaYI1AiHxssvv6iTTgxzKpnoj2kQ+krG sh0nsUg31difmfF2cCi6XktbjIrLHTgtSJjFpPjYGbWVEyJwT3W6DdwyR7eUYu8lRxIhQkXCoSM /nbODbqWkryegmTVRo7yU4pLkt7Aaly0RMh/28K61DNeghwlsfMeTy147/h6UkghuSUeCzRhs5z EdzN3OgaArv1AcSUH/Xrc6e/0JrrE+i6XiMNp06cb/OOgVKWTHylfvRiFTY5v/qCpu16dtzbDaA mM6R+qfxJpqpzaeAkIs+FjR+Jq9RaJC2e1yK6cmD3ew5BhIU0pUcPt7y8KB8ANC9AHO3YfKydmK 6qQIcgMmJHLZ2irNQm/UiQfopKVJ+sdCRa2URhT0WkxxRbeYtlrqstQSxb8exVn0UBYT7B84tvS ASYb9UKpLtitTHtwmIxqO5WXQBz5KbOGOcI/3a+vTSDY4iYuYYkQkEUIOo3AoX7XTjDls4 X-Received: by 2002:a05:6a00:1885:b0:82f:5c3f:94c6 with SMTP id d2e1a72fcca58-834ddc146c3mr6886356b3a.28.1777454207406; Wed, 29 Apr 2026 02:16:47 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-834ed5cd3b8sm1586865b3a.16.2026.04.29.02.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 02:16:47 -0700 (PDT) From: phucduc.bui@gmail.com To: Liam Girdwood , Mark Brown Cc: Jaroslav Kysela , Takashi Iwai , Kunihiko Hayashi , Masami Hiramatsu , Kuninori Morimoto , Joris Verhaegen , Miller Liang , linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 2/2] ASoC: uniphier: aio-dma: Use guard() for spin locks Date: Wed, 29 Apr 2026 16:16:14 +0700 Message-ID: <20260429091614.96667-3-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429091614.96667-1-phucduc.bui@gmail.com> References: <20260429091614.96667-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- sound/soc/uniphier/aio-dma.c | 52 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c index c1ca55997103..c01eae55d4fc 100644 --- a/sound/soc/uniphier/aio-dma.c +++ b/sound/soc/uniphier/aio-dma.c @@ -32,15 +32,15 @@ static void aiodma_pcm_irq(struct uniphier_aio_sub *sub) runtime->channels * samples_to_bytes(runtime, 1); int ret; - spin_lock(&sub->lock); - ret = aiodma_rb_set_threshold(sub, runtime->dma_bytes, - sub->threshold + bytes); - if (!ret) - sub->threshold += bytes; - - aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes); - aiodma_rb_clear_irq(sub); - spin_unlock(&sub->lock); + scoped_guard(spinlock, &sub->lock) { + ret = aiodma_rb_set_threshold(sub, runtime->dma_bytes, + sub->threshold + bytes); + if (!ret) + sub->threshold += bytes; + + aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes); + aiodma_rb_clear_irq(sub); + } snd_pcm_period_elapsed(sub->substream); } @@ -51,15 +51,15 @@ static void aiodma_compr_irq(struct uniphier_aio_sub *sub) int bytes = runtime->fragment_size; int ret; - spin_lock(&sub->lock); - ret = aiodma_rb_set_threshold(sub, sub->compr_bytes, - sub->threshold + bytes); - if (!ret) - sub->threshold += bytes; + scoped_guard(spinlock, &sub->lock) { + ret = aiodma_rb_set_threshold(sub, sub->compr_bytes, + sub->threshold + bytes); + if (!ret) + sub->threshold += bytes; - aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); - aiodma_rb_clear_irq(sub); - spin_unlock(&sub->lock); + aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); + aiodma_rb_clear_irq(sub); + } snd_compr_fragment_elapsed(sub->cstream); } @@ -113,18 +113,16 @@ static int uniphier_aiodma_prepare(struct snd_soc_component *component, struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; int bytes = runtime->period_size * runtime->channels * samples_to_bytes(runtime, 1); - unsigned long flags; int ret; ret = aiodma_ch_set_param(sub); if (ret) return ret; - spin_lock_irqsave(&sub->lock, flags); - ret = aiodma_rb_set_buffer(sub, runtime->dma_addr, - runtime->dma_addr + runtime->dma_bytes, - bytes); - spin_unlock_irqrestore(&sub->lock, flags); + scoped_guard(spinlock_irqsave, &sub->lock) + ret = aiodma_rb_set_buffer(sub, runtime->dma_addr, + runtime->dma_addr + runtime->dma_bytes, + bytes); if (ret) return ret; @@ -141,9 +139,8 @@ static int uniphier_aiodma_trigger(struct snd_soc_component *component, struct device *dev = &aio->chip->pdev->dev; int bytes = runtime->period_size * runtime->channels * samples_to_bytes(runtime, 1); - unsigned long flags; - spin_lock_irqsave(&sub->lock, flags); + guard(spinlock_irqsave)(&sub->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, @@ -161,7 +158,6 @@ static int uniphier_aiodma_trigger(struct snd_soc_component *component, dev_warn(dev, "Unknown trigger(%d) ignored\n", cmd); break; } - spin_unlock_irqrestore(&sub->lock, flags); return 0; } @@ -176,17 +172,15 @@ static snd_pcm_uframes_t uniphier_aiodma_pointer( struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; int bytes = runtime->period_size * runtime->channels * samples_to_bytes(runtime, 1); - unsigned long flags; snd_pcm_uframes_t pos; - spin_lock_irqsave(&sub->lock, flags); + guard(spinlock_irqsave)(&sub->lock); aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes); if (sub->swm->dir == PORT_DIR_OUTPUT) pos = bytes_to_frames(runtime, sub->rd_offs); else pos = bytes_to_frames(runtime, sub->wr_offs); - spin_unlock_irqrestore(&sub->lock, flags); return pos; } -- 2.43.0