From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.dev, shumingf@realtek.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH v4 3/7] ASoC: SDCA: Remove devm from primary IRQ cleanup
Date: Tue, 21 Jul 2026 15:36:32 +0100 [thread overview]
Message-ID: <20260721143636.361814-4-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20260721143636.361814-1-ckeepax@opensource.cirrus.com>
To provide greater flexibility on when the IRQs are requested for
client drivers don't use devm for the primary IRQ request/cleanup
helper functions.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
New since v3.
include/sound/sdca_fdl.h | 2 ++
include/sound/sdca_interrupts.h | 2 ++
include/sound/sdca_jack.h | 2 ++
sound/soc/sdca/sdca_fdl.c | 13 +++++++++++--
sound/soc/sdca/sdca_interrupts.c | 8 ++++++++
sound/soc/sdca/sdca_jack.c | 13 +++++++++++--
6 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/include/sound/sdca_fdl.h b/include/sound/sdca_fdl.h
index fbaf4b384c8af..dc33927b82bde 100644
--- a/include/sound/sdca_fdl.h
+++ b/include/sound/sdca_fdl.h
@@ -67,6 +67,8 @@ struct fdl_state {
#if IS_ENABLED(CONFIG_SND_SOC_SDCA_FDL)
int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt);
+void sdca_fdl_free_state(struct sdca_interrupt *interrupt);
+
int sdca_fdl_process(struct sdca_interrupt *interrupt);
int sdca_fdl_sync(struct device *dev, struct sdca_function_data *function,
struct sdca_interrupt_info *info);
diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interrupts.h
index 38c6c58c2cc78..8a44c19e917ce 100644
--- a/include/sound/sdca_interrupts.h
+++ b/include/sound/sdca_interrupts.h
@@ -31,6 +31,7 @@ struct sdca_function_data;
* @entity: Pointer to the Entity that the interrupt is associated with.
* @control: Pointer to the Control that the interrupt is associated with.
* @priv: Pointer to private data for use by the handler.
+ * @free_priv: Pointer to a function that can be used to free the priv data.
* @irq: IRQ number allocated to this interrupt, also used internally to track
* the IRQ being assigned.
* @early_request: Flag to indicate this IRQ was requested at bus probe time.
@@ -47,6 +48,7 @@ struct sdca_interrupt {
struct sdca_control *control;
void *priv;
+ void (*free_priv)(struct sdca_interrupt *interrupt);
int irq;
bool early_request;
diff --git a/include/sound/sdca_jack.h b/include/sound/sdca_jack.h
index 181541f0f4d8c..59de40b7d7d01 100644
--- a/include/sound/sdca_jack.h
+++ b/include/sound/sdca_jack.h
@@ -28,6 +28,8 @@ struct jack_state {
};
int sdca_jack_alloc_state(struct sdca_interrupt *interrupt);
+void sdca_jack_free_state(struct sdca_interrupt *interrupt);
+
int sdca_jack_process(struct sdca_interrupt *interrupt);
int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *jack);
int sdca_jack_report(struct sdca_interrupt *interrupt);
diff --git a/sound/soc/sdca/sdca_fdl.c b/sound/soc/sdca/sdca_fdl.c
index 994821a6df617..82e09d960c127 100644
--- a/sound/soc/sdca/sdca_fdl.c
+++ b/sound/soc/sdca/sdca_fdl.c
@@ -481,10 +481,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_fdl_process, "SND_SOC_SDCA");
*/
int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt)
{
- struct device *dev = interrupt->dev;
struct fdl_state *fdl_state;
- fdl_state = devm_kzalloc(dev, sizeof(*fdl_state), GFP_KERNEL);
+ fdl_state = kzalloc_obj(*fdl_state);
if (!fdl_state)
return -ENOMEM;
@@ -499,3 +498,13 @@ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt)
return 0;
}
EXPORT_SYMBOL_NS_GPL(sdca_fdl_alloc_state, "SND_SOC_SDCA");
+
+/**
+ * sdca_fdl_free_state - free state for an FDL interrupt
+ * @interrupt: SDCA interrupt structure.
+ */
+void sdca_fdl_free_state(struct sdca_interrupt *interrupt)
+{
+ kfree(interrupt->priv);
+}
+EXPORT_SYMBOL_NS_GPL(sdca_fdl_free_state, "SND_SOC_SDCA");
diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c
index d86884a89c405..cd2c5d49bb95b 100644
--- a/sound/soc/sdca/sdca_interrupts.c
+++ b/sound/soc/sdca/sdca_interrupts.c
@@ -457,6 +457,7 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap,
return ret;
interrupt->early_request = true;
+ interrupt->free_priv = sdca_fdl_free_state;
ret = sdca_fdl_alloc_state(interrupt);
if (ret)
@@ -530,6 +531,8 @@ int sdca_irq_populate(struct sdca_function_data *function,
handler = function_status_handler;
break;
case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
+ interrupt->free_priv = sdca_jack_free_state;
+
ret = sdca_jack_alloc_state(interrupt);
if (ret)
return ret;
@@ -537,6 +540,8 @@ int sdca_irq_populate(struct sdca_function_data *function,
handler = detected_mode_handler;
break;
case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
+ interrupt->free_priv = sdca_fdl_free_state;
+
ret = sdca_fdl_alloc_state(interrupt);
if (ret)
return ret;
@@ -584,6 +589,9 @@ static void sdca_irq_cleanup_flags(struct device *dev,
sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt);
+ if (interrupt->free_priv)
+ interrupt->free_priv(interrupt);
+
kfree(interrupt->name);
}
}
diff --git a/sound/soc/sdca/sdca_jack.c b/sound/soc/sdca/sdca_jack.c
index ae9636622a840..ffa8709649248 100644
--- a/sound/soc/sdca/sdca_jack.c
+++ b/sound/soc/sdca/sdca_jack.c
@@ -132,10 +132,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA");
*/
int sdca_jack_alloc_state(struct sdca_interrupt *interrupt)
{
- struct device *dev = interrupt->dev;
struct jack_state *jack_state;
- jack_state = devm_kzalloc(dev, sizeof(*jack_state), GFP_KERNEL);
+ jack_state = kzalloc_obj(*jack_state);
if (!jack_state)
return -ENOMEM;
@@ -145,6 +144,16 @@ int sdca_jack_alloc_state(struct sdca_interrupt *interrupt)
}
EXPORT_SYMBOL_NS_GPL(sdca_jack_alloc_state, "SND_SOC_SDCA");
+/**
+ * sdca_jack_free_state - free state for a jack interrupt
+ * @interrupt: SDCA interrupt structure.
+ */
+void sdca_jack_free_state(struct sdca_interrupt *interrupt)
+{
+ kfree(interrupt->priv);
+}
+EXPORT_SYMBOL_NS_GPL(sdca_jack_free_state, "SND_SOC_SDCA");
+
static int type_get_mask(enum sdca_terminal_type type)
{
switch (type) {
--
2.47.3
next prev parent reply other threads:[~2026-07-21 14:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 14:36 [PATCH v4 0/7] Fix races on creation of SDCA jack detection Charles Keepax
2026-07-21 14:36 ` [PATCH v4 1/7] ASoC: SDCA: Rename sdca_irq_allocate() to include devm Charles Keepax
2026-07-21 14:36 ` [PATCH v4 2/7] ASoC: SDCA: Add sdca_irq_cleanup_late() Charles Keepax
2026-07-21 14:36 ` Charles Keepax [this message]
2026-07-21 14:36 ` [PATCH v4 4/7] ASoC: SDCA: Populate IRQ data earlier Charles Keepax
2026-07-21 14:36 ` [PATCH v4 5/7] ASoC: Add a component fixup_controls callback Charles Keepax
2026-07-21 14:36 ` [PATCH v4 6/7] ASoC: SDCA: Switch to fixup_controls callback for IRQ registration Charles Keepax
2026-07-21 14:36 ` [PATCH v4 7/7] ASoC: SDCA: Move kcontrol search out of IRQ Charles Keepax
2026-07-27 17:47 ` [PATCH v4 0/7] Fix races on creation of SDCA jack detection 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=20260721143636.361814-4-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=shumingf@realtek.com \
--cc=yung-chuan.liao@linux.intel.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