[PATCH v3 4/8] ASoC: samsung: midas_wm1811: Add GPIO-based headset jack detection
Mark Brown
broonie at kernel.org
Mon May 20 07:41:17 PDT 2024
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240520/a8a70667/attachment.sig>
More information about the linux-arm-kernel
mailing list