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.
Attachment:
signature.asc
Description: PGP signature