| Message ID | 20260513105003.81880-1-phucduc.bui@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23327-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mxe881.netcup.net (Postfix) with ESMTPS id F2B651C07B4
for <noreply@patchwork.local>; Wed, 13 May 2026 12:53:00 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.105.105.114)
smtp.mailfrom=linux-sunxi+bounces-23327-noreply=patchwork.local@lists.linux.dev
smtp.helo=tor.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.105.105.114 as permitted sender) client-ip=172.105.105.114;
envelope-from=linux-sunxi+bounces-23327-noreply=patchwork.local@lists.linux.dev;
helo=tor.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 3619430684D5
for <noreply@patchwork.local>; Wed, 13 May 2026 10:50:31 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id A9DAF38F935;
Wed, 13 May 2026 10:50:30 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="LTM56xA+"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com
[209.85.216.50])
(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 4631C1427A
for <linux-sunxi@lists.linux.dev>; Wed, 13 May 2026 10:50:29 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=209.85.216.50
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1778669430; cv=none;
b=JvQhfXaB8mkWBzeS7d+cXuv3CzEUNC9rlG3xWPBbPuDlMyRiDRH+7TKfGLffiA4/wepMnaHUiJzuj7HvHzMjqxwMiiVQolajUxsuwXAmSpbhRXNsPsAmt5CWDZTrfp2noSl/zk9A77HEVR2UvQ2v6OsZuB3DvT6f7ib+ObX15q0=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1778669430; c=relaxed/simple;
bh=PITbxzoqk9Z0GWsxXYBjlIF56iXx3q7LP7uqXiKTMNs=;
h=From:To:Cc:Subject:Date:Message-ID:MIME-Version;
b=JxKmPF0vQceQEtB+Q2lt9DAM9Kzws6C+ZN9Lc0rH5f7td8RoLHtyM9XhuNzrt7TGwpBAgVzWsi5pW4HAwzYItmLZ/u8a7My6w3z/6tuWAEpSl/PqCjUOsO6qQTPaXMEnXMgJS7Zdm8myBzZftO54hNR7f0q53boavtlXdD6S21g=
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=LTM56xA+; arc=none smtp.client-ip=209.85.216.50
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
Received: by mail-pj1-f50.google.com with SMTP id
98e67ed59e1d1-367cbac9c37so3065980a91.2
for <linux-sunxi@lists.linux.dev>;
Wed, 13 May 2026 03:50:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1778669428; x=1779274228;
darn=lists.linux.dev;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=3gq8AnA9QGLhuYSw+tICygG0pQw5Dug4NgZkZsPxWBA=;
b=LTM56xA+43yf6yfwqfMcKac4HusDEb2HatlfB0rVjokbXBtaa19iSTBJVW91vOynUB
txKHMYNQl/bfO4VrpdfdTyTmzzCHeFFAHJCthvl+/wT6bFBkl+VYp7I9vig3ATh8Kl00
2If7HDp4ve/TeQ93rcgiMiiCYLghJHmTF0NAap4pKydXOtCh1nTFrD8UBojyqNlGyS1G
xfSYgnBk/dA4RJx3Fr9QccDCYizwHM1WvQJGPRbvPeMODsPOeEBuSZX5WTziyjDxtd4K
CyuvdoP7SFNBObKV+WReXPQ04XTZFh7Y0hmUw3ZB8rEZeEOuy3zoTIYqR/7B7Q4NpEbx
IN3w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1778669428; x=1779274228;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to;
bh=3gq8AnA9QGLhuYSw+tICygG0pQw5Dug4NgZkZsPxWBA=;
b=sy6xARlT+njy+d107Qla9RYptz2nJsOrahZJFZvi5f+8p6hg3A4q4m8XAHxcqLhnX4
JaC2m0E49gjmN+kgo2vHufrJVCkcyg3ySUo7uyVOeN4YrntmJm3t4TljUJ1n1vUBBxGy
MuyxYeVkGYaf7vTHIV7OYxGz1afEPKTX9zj3E41NdLwftPq03JcYPSpSBOh5Jf9K1bTX
QUKMdMwrb6gSiPPqdygOLB8mw1ClgtGBiX81MmNTzyms0g5T7b06tlMEyCxI2AZwDepr
kvggTrwKcr8KfB1bWVJJtYlYwt0CGnabAh8HXcNOSiW9D2D8hRTDEIJZ8e2VUiBeZ3Og
GDPw==
X-Forwarded-Encrypted: i=1;
AFNElJ+xg3GRUuaO+HTUqR8cgbp4LIl1RYVTKLA34PNhbB+rszJfMoijujedYV1aePBzQBeaxJixCFCtqEttvw==@lists.linux.dev
X-Gm-Message-State: AOJu0YyCnLPMI4rW1pgzC6QWqcXGRfOTp8t5b6OO2Hew/K6SJCKrLGXw
gxRXX/aIESeuTG9+dZwyC7pRpme/Y7luHFYlCPrm2MHVvc8YQXzF10ZG
X-Gm-Gg: Acq92OH0Yabq+n/I7YaUecm3SZy9Q6yq2ih5HoN0lAIffYH5AZqNt0TJLZQvyhE/+Nu
nMbPM8ov+od8MOkVMcRDFSdsI/R3X1h7bDm8QYj9fFefhHqlVAhkiu6CJJdG8ye1vOvbI2fi9g3
GokP40g6aX0RVhAdyCNvbiEWlvXumrpA7ZTonOYn0uqESATW0OKz8g87uoosbm5TPXgvkiaGhH7
l86DLe7kjgcxu8CkOhbLrzUqknyHIKKLFJYtDumirOioPJuYH4h4NTEqw/xolWoxpDbZxIbqzPz
0JT0OzKli0CXsstXdq5rVKY2tucGZBNmh3dG6O3kZ50w9Iuv2bMpxSuvkMLF7mXH4JvTDxZuPHr
dawoHPy6HlDJ1C0aUhU99tZjSX5FffmQcQtOOIAGKkUAT3RcFQDuXWrs5I8YcufCxgxqnPBIIFB
g0VI7X0QJd173YYKThov+1lezj1oybd5C5jS6DQ1G3XLkrZQKHu4/42NL48A==
X-Received: by 2002:a17:90b:54cb:b0:368:65bc:e32b with SMTP id
98e67ed59e1d1-368f3c151d8mr2923432a91.15.1778669428352;
Wed, 13 May 2026 03:50:28 -0700 (PDT)
Received: from phuc-desktop.. ([183.91.15.56])
by smtp.gmail.com with ESMTPSA id
98e67ed59e1d1-368edf9b543sm2843136a91.16.2026.05.13.03.50.24
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 13 May 2026 03:50:28 -0700 (PDT)
From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Marcus Cooper <codekipper@gmail.com>,
Chen Ni <nichen@iscas.ac.cn>,
linux-sound@vger.kernel.org,
linux-sunxi@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH] ASoC: sun4i-spdif: Use guard() for spin locks
Date: Wed, 13 May 2026 17:50:03 +0700
Message-ID: <20260513105003.81880-1-phucduc.bui@gmail.com>
X-Mailer: git-send-email 2.43.0
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [-0.66 / 15.00];
BAYES_HAM(-5.50)[99.99%];
RBL_SENDERSCORE(2.00)[172.105.105.114:from];
SUSPICIOUS_RECIPS(1.50)[];
DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed),
No valid DKIM,none];
R_MISSING_CHARSET(0.50)[];
MAILLIST(-0.15)[generic];
BAD_REP_POLICIES(0.10)[];
MIME_GOOD(-0.10)[text/plain];
HAS_LIST_UNSUB(-0.01)[];
FROM_NO_DN(0.00)[];
DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo];
RCPT_COUNT_TWELVE(0.00)[14];
TO_DN_SOME(0.00)[];
FUZZY_BLOCKED(0.00)[rspamd.com];
FORGED_SENDER_MAILLIST(0.00)[];
FREEMAIL_CC(0.00)[gmail.com,perex.cz,suse.com,kernel.org,sholland.org,iscas.ac.cn,vger.kernel.org,lists.linux.dev,lists.infradead.org];
TAGGED_RCPT(0.00)[];
PRECEDENCE_BULK(0.00)[];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
RCVD_TLS_LAST(0.00)[];
MID_RHS_MATCH_FROM(0.00)[];
MIME_TRACE(0.00)[0:+];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
R_SPF_ALLOW(0.00)[+ip4:172.105.105.114];
TAGGED_FROM(0.00)[bounces-23327-noreply=patchwork.local];
FROM_NEQ_ENVFROM(0.00)[phucducbui@gmail.com,linux-sunxi@lists.linux.dev];
ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG];
FREEMAIL_FROM(0.00)[gmail.com];
RCVD_COUNT_FIVE(0.00)[6];
RCVD_VIA_SMTP_AUTH(0.00)[]
X-Rspamd-Queue-Id: F2B651C07B4
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
ASoC: sun4i-spdif: Use guard() for spin locks
|
|
Commit Message
Bui Duc Phuc
May 13, 2026, 10:50 a.m. UTC
From: bui duc phuc <phucduc.bui@gmail.com> Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- sound/soc/sunxi/sun4i-spdif.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Hardware State / PM Violation leading to bus hang -- commit 0686001584788d984a0f16403183bcad78fe4176 Author: bui duc phuc <phucduc.bui@gmail.com> ASoC: sun4i-spdif: Use guard() for spin locks This commit refactors the locking in the sun4i-spdif driver to use the guard() macro for spinlocks. It replaces manual spin_lock_irqsave() and spin_unlock_irqrestore() calls with scope-based cleanup. > diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c > --- a/sound/soc/sunxi/sun4i-spdif.c > +++ b/sound/soc/sunxi/sun4i-spdif.c > @@ -427,10 +427,9 @@ static int sun4i_spdif_get_status(struct snd_kcontrol *kcontrol, > struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); > struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai); > u8 *status = ucontrol->value.iec958.status; > - unsigned long flags; > unsigned int reg; > > - spin_lock_irqsave(&host->lock, flags); > + guard(spinlock_irqsave)(&host->lock); > > regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA0, ®); While this issue isn't new to this patch, does this code risk a bus hang if the device is runtime-suspended? The regmap configuration lacks a cache, and these ALSA kcontrols can be accessed by userspace at any time. If the audio stream is idle, the device will be runtime-suspended and its APB bus clock (apb_clk) will be disabled. Accessing the physical registers with the clock disabled will trigger an asynchronous external abort. Would it make sense to ensure the device is runtime-resumed (perhaps via pm_runtime_get_sync() outside the spinlock guard) before touching the hardware? [ ... ]
Thanks for the review. This seems to be pre-existing behavior rather than something introduced by this patch, since the current change only converts the locking to use guard() helpers and does not modify the runtime PM handling. If this turns out to be a real issue, it would probably be better addressed separately from this cleanup patch. On Thu, May 14, 2026 at 11:33 AM <sashiko-bot@kernel.org> wrote: > > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [High] Hardware State / PM Violation leading to bus hang > -- > > commit 0686001584788d984a0f16403183bcad78fe4176 > Author: bui duc phuc <phucduc.bui@gmail.com> > > ASoC: sun4i-spdif: Use guard() for spin locks > > This commit refactors the locking in the sun4i-spdif driver to use the > guard() macro for spinlocks. It replaces manual spin_lock_irqsave() and > spin_unlock_irqrestore() calls with scope-based cleanup. > > > diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c > > --- a/sound/soc/sunxi/sun4i-spdif.c > > +++ b/sound/soc/sunxi/sun4i-spdif.c > > @@ -427,10 +427,9 @@ static int sun4i_spdif_get_status(struct snd_kcontrol *kcontrol, > > struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); > > struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai); > > u8 *status = ucontrol->value.iec958.status; > > - unsigned long flags; > > unsigned int reg; > > > > - spin_lock_irqsave(&host->lock, flags); > > + guard(spinlock_irqsave)(&host->lock); > > > > regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA0, ®); > > While this issue isn't new to this patch, does this code risk a bus hang if > the device is runtime-suspended? > > The regmap configuration lacks a cache, and these ALSA kcontrols can be > accessed by userspace at any time. If the audio stream is idle, the device > will be runtime-suspended and its APB bus clock (apb_clk) will be disabled. > > Accessing the physical registers with the clock disabled will trigger an > asynchronous external abort. > > Would it make sense to ensure the device is runtime-resumed (perhaps via > pm_runtime_get_sync() outside the spinlock guard) before touching the > hardware? > > [ ... ] > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20260513105003.81880-1-phucduc.bui@gmail.com?part=1
Hi,
I am not entirely sure whether the issue is exactly as
described in the Sashiko review.
However, I also looked at a similar case in the
micfil_rate_set() function from the fsl_micfil driver:
https://elixir.bootlin.com/linux/v7.1-rc3/source/sound/soc/fsl/fsl_micfil.c
There, pm_runtime_resume_and_get() is also used to ensure
that the device is runtime-resumed before accessing the
registers.
To address the review comments and avoid mixing functional
changes with the cleanup/refactoring using guard/scoped_guard,
I am planning to split this into two separate patches:
Patch 1: replace spin_lock_irqsave() /
spin_unlock_irqrestore() with scoped_guard() / guard()
+ scoped_guard(spinlock_irqsave, &host->lock) {
regmap_read(...);
+ }
Patch 2: add runtime PM handling around register accesses
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ return ret;
scoped_guard(spinlock_irqsave, &host->lock) {
regmap_read(...);
}
+ pm_runtime_put(dev);
This should make the review easier and clearly separate the
functional change from the refactoring.
Does this approach look reasonable to you?
If so, please let me know and I will prepare the
corresponding patches.
Best Regard,
Phuc
On Thu, May 14, 2026 at 6:22 PM Bui Duc Phuc <phucduc.bui@gmail.com> wrote:
>
> Thanks for the review.
>
> This seems to be pre-existing behavior rather than something
> introduced by this patch, since the current change only converts
> the locking to use guard() helpers and does not modify the
> runtime PM handling.
>
> If this turns out to be a real issue, it would probably be better
> addressed separately from this cleanup patch.
>
>
> On Thu, May 14, 2026 at 11:33 AM <sashiko-bot@kernel.org> wrote:
> >
> > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > - [High] Hardware State / PM Violation leading to bus hang
> > --
> >
> > commit 0686001584788d984a0f16403183bcad78fe4176
> > Author: bui duc phuc <phucduc.bui@gmail.com>
> >
> > ASoC: sun4i-spdif: Use guard() for spin locks
> >
> > This commit refactors the locking in the sun4i-spdif driver to use the
> > guard() macro for spinlocks. It replaces manual spin_lock_irqsave() and
> > spin_unlock_irqrestore() calls with scope-based cleanup.
> >
> > > diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c
> > > --- a/sound/soc/sunxi/sun4i-spdif.c
> > > +++ b/sound/soc/sunxi/sun4i-spdif.c
> > > @@ -427,10 +427,9 @@ static int sun4i_spdif_get_status(struct snd_kcontrol *kcontrol,
> > > struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
> > > struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai);
> > > u8 *status = ucontrol->value.iec958.status;
> > > - unsigned long flags;
> > > unsigned int reg;
> > >
> > > - spin_lock_irqsave(&host->lock, flags);
> > > + guard(spinlock_irqsave)(&host->lock);
> > >
> > > regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA0, ®);
> >
> > While this issue isn't new to this patch, does this code risk a bus hang if
> > the device is runtime-suspended?
> >
> > The regmap configuration lacks a cache, and these ALSA kcontrols can be
> > accessed by userspace at any time. If the audio stream is idle, the device
> > will be runtime-suspended and its APB bus clock (apb_clk) will be disabled.
> >
> > Accessing the physical registers with the clock disabled will trigger an
> > asynchronous external abort.
> >
> > Would it make sense to ensure the device is runtime-resumed (perhaps via
> > pm_runtime_get_sync() outside the spinlock guard) before touching the
> > hardware?
> >
> > [ ... ]
> >
> > --
> > Sashiko AI review · https://sashiko.dev/#/patchset/20260513105003.81880-1-phucduc.bui@gmail.com?part=1
Hi all I would like to make a small correction to my previous email, and also confirm one additional point before preparing another patch. Correction: > However, I also looked at a similar case in the > micfil_rate_set() function from the fsl_micfil driver: > https://elixir.bootlin.com/linux/v7.1-rc3/source/sound/soc/fsl/fsl_micfil.c In my previous email, I referred to the function as micfil_rate_set(), but the correct name is micfil_range_set(). Additional point for confirmation: Currently, in sun4i_spdif_runtime_suspend(), the clocks are disabled in the following order: clk_disable_unprepare(host->spdif_clk); clk_disable_unprepare(host->apb_clk); Meanwhile, in sun4i_spdif_runtime_resume(), the clocks are enabled in this order: clk_prepare_enable(host->spdif_clk); ret = clk_prepare_enable(host->apb_clk); I checked the binding documentation here: https://elixir.bootlin.com/linux/v7.1-rc3/source/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml It describes the clocks as: properties: clocks: items: - description: Bus Clock - description: Module Clock clock-names: items: - const: apb - const: spdif >From my understanding, apb_clk is the bus clock, while spdif_clk is the module clock. If that understanding is correct, then the suspend path seems reasonable since the module clock is disabled before the bus clock. However, in the resume path, the module clock is currently enabled before the bus clock. It may make more sense to enable the bus clock first, followed by the module clock. If my understanding is correct, I would like to prepare an additional patch to reorder the clock enable sequence. Please let me know if this interpretation makes sense. Best Regard, Phuc
diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index c2ec19437cd7..ec00779182db 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -427,10 +427,9 @@ static int sun4i_spdif_get_status(struct snd_kcontrol *kcontrol, struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai); u8 *status = ucontrol->value.iec958.status; - unsigned long flags; unsigned int reg; - spin_lock_irqsave(&host->lock, flags); + guard(spinlock_irqsave)(&host->lock); regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA0, ®); @@ -444,8 +443,6 @@ static int sun4i_spdif_get_status(struct snd_kcontrol *kcontrol, status[4] = reg & 0xff; status[5] = (reg >> 8) & 0x3; - spin_unlock_irqrestore(&host->lock, flags); - return 0; } @@ -455,11 +452,10 @@ static int sun4i_spdif_set_status(struct snd_kcontrol *kcontrol, struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai); u8 *status = ucontrol->value.iec958.status; - unsigned long flags; unsigned int reg; bool chg0, chg1; - spin_lock_irqsave(&host->lock, flags); + guard(spinlock_irqsave)(&host->lock); reg = (u32)status[3] << 24; reg |= (u32)status[2] << 16; @@ -483,8 +479,6 @@ static int sun4i_spdif_set_status(struct snd_kcontrol *kcontrol, SUN4I_SPDIF_TXCFG_CHSTMODE | SUN4I_SPDIF_TXCFG_NONAUDIO, reg); - spin_unlock_irqrestore(&host->lock, flags); - return chg0 || chg1; }