[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c4c0aeb-2870-4905-bcfc-642ae40c87f1@sirena.org.uk>
Date: Mon, 20 May 2024 15:41:17 +0100
From: Mark Brown <broonie@...nel.org>
To: Artur Weber <aweber.kernel@...il.com>
Cc: Sylwester Nawrocki <s.nawrocki@...sung.com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Rob Herring <robh@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Alim Akhtar <alim.akhtar@...sung.com>, alsa-devel@...a-project.org,
linux-sound@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org,
~postmarketos/upstreaming@...ts.sr.ht
Subject: Re: [PATCH v3 4/8] ASoC: samsung: midas_wm1811: Add GPIO-based
headset jack detection
On Sun, May 19, 2024 at 10:17:50AM +0200, Artur Weber wrote:
> + if (priv->reg_headset_mic_bias) {
> + /*
> + * Get state of Headset Mic switch by checking the headset mic
> + * bias regulator
> + */
> + bias_already_on = \
> + regulator_is_enabled(priv->reg_headset_mic_bias);
If you're going to do this you need to use regulator_get_exclusive() to
ensure that nothing else can enable the regulator, otherwise you should
just unconditionally enable the regulator.
> + /*
> + * Revert the headset mic bias supply to its previous state
> + * (i.e. if it was disabled before the check, disable it again)
> + */
> + if (priv->reg_headset_mic_bias && bias_already_on == 0) {
> + ret = regulator_disable(priv->reg_headset_mic_bias);
> + if (ret)
> + pr_err("%s: Failed to disable micbias: %d\n",
> + __func__, ret);
> + }
Given that you're just briefly bouncing the regulator on and off it'd be
best to just unconditionally enable and disable here, I can't see what
the enable check gains you other than possible race conditions.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists