Re: [PATCH 2/2] ASoC: ti: omap-twl4030: use per-device instance of headset jack gpio

From: Sebastian Reichel

Date: Fri Jul 24 2026 - 21:13:14 EST


Hi,

On Fri, Jul 24, 2026 at 04:34:30PM -0700, Dmitry Torokhov wrote:
> 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@xxxxxxxxx>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>

Greetings,

-- Sebastian

> 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
>
>

Attachment: signature.asc
Description: PGP signature