From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Oder Chiou <oder_chiou@realtek.com>, Mark Brown <broonie@kernel.org>
Cc: "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
"Cezary Rojewski" <cezary.rojewski@intel.com>,
alsa-devel@alsa-project.org, "Takashi Iwai" <tiwai@suse.com>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
Subject: [PATCH 06/11] ASoC: codecs: rt298: Move irq registration and cleanup
Date: Thu, 9 Jun 2022 15:35:36 +0200 [thread overview]
Message-ID: <20220609133541.3984886-7-amadeuszx.slawinski@linux.intel.com> (raw)
In-Reply-To: <20220609133541.3984886-1-amadeuszx.slawinski@linux.intel.com>
Currently irq is registered when i2c driver is loaded, it is unnecessary
when component is unused. Initialize irq only when we probe ASoC
component.
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/codecs/rt298.c | 43 +++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 1a27e5e63289..078810f2ec7b 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -1009,13 +1009,22 @@ static irqreturn_t rt298_irq(int irq, void *data)
static int rt298_probe(struct snd_soc_component *component)
{
struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
+ int ret;
rt298->component = component;
INIT_DELAYED_WORK(&rt298->jack_detect_work, rt298_jack_detect_work);
- if (rt298->i2c->irq)
- schedule_delayed_work(&rt298->jack_detect_work,
- msecs_to_jiffies(1250));
+ if (rt298->i2c->irq) {
+ ret = request_threaded_irq(rt298->i2c->irq, NULL, rt298_irq,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt298", rt298);
+ if (ret) {
+ dev_err(&rt298->i2c->dev, "Failed to reguest IRQ: %d\n", ret);
+ return ret;
+ }
+
+ schedule_delayed_work(&rt298->jack_detect_work, msecs_to_jiffies(1250));
+ }
+
return 0;
}
@@ -1023,7 +1032,12 @@ static void rt298_remove(struct snd_soc_component *component)
{
struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
- cancel_delayed_work_sync(&rt298->jack_detect_work);
+ if (rt298->i2c->irq) {
+ cancel_delayed_work_sync(&rt298->jack_detect_work);
+
+ disable_irq(rt298->i2c->irq);
+ free_irq(rt298->i2c->irq, rt298);
+ }
}
#ifdef CONFIG_PM
@@ -1275,16 +1289,6 @@ static int rt298_i2c_probe(struct i2c_client *i2c)
rt298->is_hp_in = -1;
- if (rt298->i2c->irq) {
- ret = request_threaded_irq(rt298->i2c->irq, NULL, rt298_irq,
- IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt298", rt298);
- if (ret != 0) {
- dev_err(&i2c->dev,
- "Failed to reguest IRQ: %d\n", ret);
- return ret;
- }
- }
-
ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_rt298,
rt298_dai, ARRAY_SIZE(rt298_dai));
@@ -1292,17 +1296,6 @@ static int rt298_i2c_probe(struct i2c_client *i2c)
return ret;
}
-static int rt298_i2c_remove(struct i2c_client *i2c)
-{
- struct rt298_priv *rt298 = i2c_get_clientdata(i2c);
-
- if (i2c->irq)
- free_irq(i2c->irq, rt298);
-
- return 0;
-}
-
-
static struct i2c_driver rt298_i2c_driver = {
.driver = {
.name = "rt298",
--
2.25.1
next prev parent reply other threads:[~2022-06-09 13:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 13:35 [PATCH 00/11] ASoC: codecs: Series of fixes for realtek codecs used on RVPs Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 01/11] ASoC: codecs: rt274: Always init jack_detect_work Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 02/11] ASoC: codecs: rt286: Reorganize jack detect handling Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 03/11] ASoC: codecs: rt298: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 04/11] ASoC: codecs: rt274: Move irq registration and cleanup Amadeusz Sławiński
2022-06-09 14:17 ` Mark Brown
2022-06-09 13:35 ` [PATCH 05/11] ASoC: codecs: rt286: " Amadeusz Sławiński
2022-06-09 13:35 ` Amadeusz Sławiński [this message]
2022-06-09 13:35 ` [PATCH 07/11] ASoC: codecs: rt274: Enable irq only when needed Amadeusz Sławiński
2022-06-09 14:18 ` Mark Brown
2022-06-10 9:33 ` Amadeusz Sławiński
2022-06-10 10:38 ` Mark Brown
2022-06-23 13:53 ` Amadeusz Sławiński
2022-06-23 14:23 ` Mark Brown
2022-06-09 13:35 ` [PATCH 08/11] ASoC: codecs: rt286: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 09/11] ASoC: codecs: rt298: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 10/11] ASoC: codecs: rt298: Fix NULL jack in interrupt Amadeusz Sławiński
2022-06-09 14:19 ` Mark Brown
2022-06-09 13:35 ` [PATCH 11/11] ASoC: codecs: rt298: Fix jack detection Amadeusz Sławiński
2022-06-09 14:55 ` Mark Brown
2022-06-10 9:46 ` Amadeusz Sławiński
2022-06-10 12:25 ` Mark Brown
2022-06-10 15:58 ` (subset) [PATCH 00/11] ASoC: codecs: Series of fixes for realtek codecs used on RVPs 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=20220609133541.3984886-7-amadeuszx.slawinski@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=lgirdwood@gmail.com \
--cc=oder_chiou@realtek.com \
--cc=pierre-louis.bossart@linux.intel.com \
--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 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.