mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jarkko Nikula <jarkko.nikula@bitmer.com>, Sen Wang <sen@ti.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] ASoC: ti: omap-twl4030: use per-device instance of headset jack gpio
Date: Fri, 24 Jul 2026 16:34:30 -0700	[thread overview]
Message-ID: <20260724233432.31325-2-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20260724233432.31325-1-dmitry.torokhov@gmail.com>

hs_jack_gpios is being potentially shared among several instances of the
same device, and is being modified. This is not the best approach to
structuring the code (even if the device is in fact a singleton).
Change it to allocate a per-device instance.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 sound/soc/ti/omap-twl4030.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/sound/soc/ti/omap-twl4030.c b/sound/soc/ti/omap-twl4030.c
index 950879fc7275..4abcfff04bc7 100644
--- a/sound/soc/ti/omap-twl4030.c
+++ b/sound/soc/ti/omap-twl4030.c
@@ -28,6 +28,7 @@
 #include "omap-mcbsp.h"
 
 struct omap_twl4030 {
+	struct snd_soc_jack_gpio hs_jack_gpio;
 	struct snd_soc_jack hs_jack;
 };
 
@@ -123,15 +124,6 @@ static struct snd_soc_jack_pin hs_jack_pins[] = {
 	},
 };
 
-/* Headset jack detection gpios */
-static struct snd_soc_jack_gpio hs_jack_gpios[] = {
-	{
-		.name = "ti,jack-det",
-		.report = SND_JACK_HEADSET,
-		.debounce_time = 200,
-	},
-};
-
 static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_card *card = rtd->card;
@@ -144,9 +136,6 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
 	 * only want to add the jack detection if the GPIO is there.
 	 */
 	if (of_property_present(card->dev->of_node, "ti,jack-det-gpio")) {
-		hs_jack_gpios[0].gpiod_dev = card->dev;
-		hs_jack_gpios[0].idx = 0;
-
 		ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
 						 SND_JACK_HEADSET,
 						 &priv->hs_jack, hs_jack_pins,
@@ -154,9 +143,14 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
 		if (ret)
 			return ret;
 
-		ret = snd_soc_jack_add_gpios(&priv->hs_jack,
-					     ARRAY_SIZE(hs_jack_gpios),
-					     hs_jack_gpios);
+		priv->hs_jack_gpio.name = "ti,jack-det";
+		priv->hs_jack_gpio.report = SND_JACK_HEADSET;
+		priv->hs_jack_gpio.debounce_time = 200;
+		priv->hs_jack_gpio.gpiod_dev = card->dev;
+		priv->hs_jack_gpio.idx = 0;
+
+		ret = snd_soc_jack_add_gpios(&priv->hs_jack, 1,
+					     &priv->hs_jack_gpio);
 		if (ret)
 			return ret;
 	}
-- 
2.55.0.229.g6434b31f56-goog


  reply	other threads:[~2026-07-24 23:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 23:34 [PATCH 1/2] ASoC: ti: omap-twl4030: drop support for platform data Dmitry Torokhov
2026-07-24 23:34 ` Dmitry Torokhov [this message]
2026-07-25  1:10   ` [PATCH 2/2] ASoC: ti: omap-twl4030: use per-device instance of headset jack gpio Sebastian Reichel
2026-07-27 17:46   ` Jarkko Nikula
2026-07-25  1:09 ` [PATCH 1/2] ASoC: ti: omap-twl4030: drop support for platform data Sebastian Reichel
2026-07-27 17:46 ` Jarkko Nikula
2026-07-27 17:50 ` 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=20260724233432.31325-2-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jarkko.nikula@bitmer.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sen@ti.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 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®