]> git.ipfire.org Git - thirdparty/linux.git/commit
ALSA: seq: Use auto-cleanup for client refcounting
authorTakashi Iwai <tiwai@suse.de>
Wed, 27 Aug 2025 08:05:10 +0000 (10:05 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 09:52:35 +0000 (11:52 +0200)
commit99e16633958b50ab4f9b6d171aca2c7be7bcab8c
tree6213153496ab51db266783757c5fa5e4195b32fe
parentd7cd16143bd8796f526806bfced721bd00dbb43e
ALSA: seq: Use auto-cleanup for client refcounting

The current code manages the refcount of client in a way like:

snd_seq_client *client;
client = clientptr(id);
....
snd_seq_client_unlock(client);

Now we introduce an auto-cleanup macro to manage the unlock
implicitly, namely, the above will be replaced like:

snd_seq_client *client __free(snd_seq_client) = NULL;
client = clientptr(id);

and we can forget the unref call.

A part of the code in snd_seq_deliver_single_event() is factored out
to a function, so that the auto-cleanups can be applied cleanly.

This also allows us to replace some left mutex lock/unlock with
guard(), and also reduce scoped_guard() to the normal guard(), too.

Only code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250827080520.7544-5-tiwai@suse.de
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_clientmgr.h
sound/core/seq/seq_ports.c