From: Chancel Liu <chancel.liu@oss.nxp.com>
To: Mark Brown <broonie@kernel.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] ASoC: simple-card-utils: Add simple_util_remove_jack()
Date: Sun, 13 Sep 2026 19:24:59 +0900 [thread overview]
Message-ID: <20260913102502.2805912-2-chancel.liu@oss.nxp.com> (raw)
In-Reply-To: <20260913102502.2805912-1-chancel.liu@oss.nxp.com>
From: Chancel Liu <chancel.liu@nxp.com>
simple_util_init_jack() acquires a GPIO descriptor with
gpiod_get_optional() and hands it to snd_soc_jack_add_gpios(), which
additionally installs an IRQ handler, a PM notifier, a delayed work and
a sysfs export for it. simple-card-utils has no counterpart that
releases any of this again.
Add simple_util_remove_jack(), the counterpart of
simple_util_init_jack(). It releases the jack GPIO and everything
snd_soc_jack_add_gpios() installed for it via snd_soc_jack_free_gpios(),
and clears sjack->gpio.desc so the descriptor is not left dangling after
it has been put.
This gives the generic card drivers a card->remove() path to release the
jack when the card goes away. The devres cleanup alone is not enough:
it is tied to the platform device, so it does not run when the card is
unregistered and re-registered while the platform device stays bound -
for example when a codec component is unbound and bound again.
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
include/sound/simple_card_utils.h | 1 +
sound/soc/generic/simple-card-utils.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index bd8c3a033577..b0e00555092e 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -219,6 +219,7 @@ static inline int simple_util_parse_aux_devs(struct simple_util_priv *priv, char
int simple_util_init_jack(struct snd_soc_card *card,
struct simple_util_jack *sjack,
int is_hp, char *prefix, char *pin);
+void simple_util_remove_jack(struct simple_util_jack *sjack);
int simple_util_init_aux_jacks(struct snd_soc_card *card, char *prefix);
int simple_util_init_priv(struct simple_util_priv *priv,
struct link_info *li);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 7df5253499cd..b91924d31c1a 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -825,6 +825,16 @@ int simple_util_init_jack(struct snd_soc_card *card,
}
EXPORT_SYMBOL_GPL(simple_util_init_jack);
+void simple_util_remove_jack(struct simple_util_jack *sjack)
+{
+ if (!sjack->gpio.desc)
+ return;
+
+ snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio);
+ sjack->gpio.desc = NULL;
+}
+EXPORT_SYMBOL_GPL(simple_util_remove_jack);
+
int simple_util_init_aux_jacks(struct snd_soc_card *card, char *prefix)
{
struct simple_util_priv *priv = snd_soc_card_get_drvdata(card);
--
2.50.1
next prev parent reply other threads:[~2026-09-13 10:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 10:24 [PATCH 0/4] ASoC: generic: Free jack GPIOs on card remove Chancel Liu
2026-09-13 10:24 ` Chancel Liu [this message]
2026-09-13 10:25 ` [PATCH 2/4] ASoC: simple-card: " Chancel Liu
2026-09-13 10:25 ` [PATCH 3/4] ASoC: audio-graph-card: " Chancel Liu
2026-09-14 0:29 ` Kuninori Morimoto
2026-09-15 2:46 ` Chancel Liu
2026-09-15 3:16 ` Kuninori Morimoto
2026-09-13 10:25 ` [PATCH 4/4] ASoC: audio-graph-card2: " Chancel Liu
2026-09-15 16:36 ` [PATCH 0/4] ASoC: generic: " Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260913102502.2805912-2-chancel.liu@oss.nxp.com \
--to=chancel.liu@oss.nxp.com \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®