All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ALSA: hda: Use scoped_guard() for remaining manual mutex handling
@ 2026-07-10  8:40 wangdich9700
  2026-07-10  8:40 ` [PATCH v2 1/3] ALSA: hda/cs35l41: Use scoped_guard() for fw_mutex in cs35l41_hda_bind() wangdich9700
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: wangdich9700 @ 2026-07-10  8:40 UTC (permalink / raw)
  To: tiwai, david.rhodes, wangdich9700; +Cc: linux-sound, linux-kernel, wangdicheng

From: wangdicheng <wangdicheng@kylinos.cn>

This is a cleanup that lets the compiler guarantee the mutex is
released on all exit paths, reducing the risk of accidental lock
leaks in future changes.  The same pattern is already used in
these files: azx_pcm_close() uses scoped_guard() for open_mutex,
and the rest of cs35l41 and cs35l56 drivers already use
guard()/scoped_guard() for their respective mutexes.

Most of the diff is indentation change from wrapping the code
inside scoped_guard() {}; the logical changes are minimal and
can be reviewed with git diff/show -w.

Verified with clang-17 W=1 build, no warnings.

In v1, some goto statements jumped out of the
scoped_guard() block, which is problematic because scoped_guard()
is implemented as a for-loop and such gotos change the control
flow in non-obvious ways.  This has caused real bugs before; see
commit a5c627d90809 ("gpio: adnp: fix flow control regression caused by scoped_guard()").
In v2, all goto targets are within the scoped_guard() block,
or replaced with break where the original label only served
to reach mutex_unlock.

No functional changes in any patch.

Changes in v2:
  - Patch 2: replaced 'goto err' (jumped out of scoped_guard to
    mutex_unlock) with 'goto err_powered_up' (stays within block),
    removed the 'err' label.
  - Patch 3: replaced 'goto unlock' (jumped out of scoped_guard)
    with 'break' (exits the scoped_guard for-loop naturally), and
    removed the now-unused 'unlock' label.

wangdicheng (3):
  ALSA: hda/cs35l41: Use scoped_guard() for fw_mutex in
    cs35l41_hda_bind()
  ALSA: hda/cs35l56: Use scoped_guard() for irq_lock in
    cs35l56_hda_fw_load()
  ALSA: hda: Use scoped_guard() for open_mutex in azx_pcm_open()

 sound/hda/codecs/side-codecs/cs35l41_hda.c |  57 ++++----
 sound/hda/codecs/side-codecs/cs35l56_hda.c | 104 +++++++-------
 sound/hda/common/controller.c              | 158 +++++++++++----------
 3 files changed, 160 insertions(+), 159 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-14  6:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10  8:40 [PATCH v2 0/3] ALSA: hda: Use scoped_guard() for remaining manual mutex handling wangdich9700
2026-07-10  8:40 ` [PATCH v2 1/3] ALSA: hda/cs35l41: Use scoped_guard() for fw_mutex in cs35l41_hda_bind() wangdich9700
2026-07-10  8:40 ` [PATCH v2 2/3] ALSA: hda/cs35l56: Use scoped_guard() for irq_lock in cs35l56_hda_fw_load() wangdich9700
2026-07-14  6:09   ` Takashi Iwai
2026-07-10  8:40 ` [PATCH v2 3/3] ALSA: hda: Use scoped_guard() for open_mutex in azx_pcm_open() wangdich9700
2026-07-14  6:11   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.