Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2497016lqo; Mon, 20 May 2024 07:41:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHn0P0d9bzEw57RdCvJdp48boleWPDDWqUjWpYBIZwKiG+rLrVVSibNhSUd0dyjAfU2+uQVOPed+7zb+ATYyWCHrSNRkpXSzYY7uULJw== X-Google-Smtp-Source: AGHT+IH4MfGtSH/otGPaLmB7sM6BsJ0VvfzTWQPfFA9BjSeUSt8SdL6pZTfnQp2PwPuMy/CEOlBR X-Received: by 2002:a05:6214:2b0b:b0:6a3:5fc8:8ef0 with SMTP id 6a1803df08f44-6a841a50b36mr109967676d6.3.1716216092461; Mon, 20 May 2024 07:41:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716216092; cv=pass; d=google.com; s=arc-20160816; b=LiRSiHooPuzXRbYstNCjZn4OQ+oxtAQLyXddBwFjKviwkNIPoj9Pf3LZAKN1WJgT4X eR182qTkXoNvGI4EqBj316g2FEzvYV5vIfNbjOIATG9l7T/+L/EvtWwGvvxoDAON5az/ uw62lmRZcQuTU+01l5dE0iXiySUf6PIz70BIuqvd8WtDwshApUYFcl//4OZYySshKpxv u0HSiY2gZG7ZjhLop8SIdv1F+3WrxXueG5YYcRhFc8h7nwez6WuEvDZyjh9R5JNjoh+v zTQQDRM2kCMIP2K2bjLMhqKMaKj7BuJLX17o/Af0zgBE8NablroLeeX/dJknthbjY4Oe ccmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kIhZXIebgAZIQMqO6XdDJTBktZzwpPReDdDI/vH8sz8=; fh=HVNh7L3jbqbJTIxCR0rbaO3N+Xc3w/fq81e4NrlSrAE=; b=TSQ3Kbmy58CQx6sIIhj2uHOC5ttGzZV6REmh/RWfwx3XxG1BA8+SlktM+r6/0DV/DA ek382ln3se/6zX0KWuDFhZa3pHRIWC/eug/BqdNhUU1M2sqRmLg0EFBvPtZTbNH/gfQJ spN0RSYzxKauq0txXMqG4VFRh7FlcvEjzVMPyA0mBT4VDFeYktFIBVftqHfyN/sfHfmF m2n4AtWClmyUg8PWzg+qYuDBBqqjxwhD71imXql4bpcSkUVWpJkCDZ4+LtUuknP5iFnh 04VuxCFMzow0wBH+xJwfnpu9hnC/xUyszzsMlofMvQeNZpTKKVV+EMx/8boS8UXpgxfD ygUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uFJ6jtkj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ab3547853bsi15057786d6.202.2024.05.20.07.41.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 07:41:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uFJ6jtkj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E5DFC1C20EDD for ; Mon, 20 May 2024 14:41:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D6591369AF; Mon, 20 May 2024 14:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uFJ6jtkj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 235B77D3FB; Mon, 20 May 2024 14:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716216084; cv=none; b=HHgsFpyEcr+3PfDjvubYyhknJrwn2K95OIDoRBkTHKAZZf41NZyEjFf/es4XPoPWKmUXktfdeVh3Jj/VIGvnbwc9SW9lBJIIxN4HwxKpQNG4FmusuQK0a2+Bc84hbfmKK0tpDXQlwYp/qx1kPmeKaVitEwsjM63efKHW/MV1Hxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716216084; c=relaxed/simple; bh=619Z6jy0Nar5HnINkMj+OqkRlvVm8QNHCVeJy2e8Qus=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cpxr8JxNTw23d3kiL9Kwl54VqUOAYzHBD7z5F2T1V3l/WIrLPf6UNDWZ/vvvkZx8Kkjef5CuvAzGflJSTOrGfXvV6Aawh7yT6OhSjkPiaQ9oJmz2IURh+V3he/qPCpO/n3F0d42+QstCLtr2ZUzfJo95nHx+DfiSoGFHA4FU4+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uFJ6jtkj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67A25C2BD10; Mon, 20 May 2024 14:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716216083; bh=619Z6jy0Nar5HnINkMj+OqkRlvVm8QNHCVeJy2e8Qus=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uFJ6jtkjLSCdTwIjLDYa5L963tzFoaUCzXZoLvXojXsEzX3rq4zqiEoKSb989dzzn OMNPSzJtGW4QGIoQjqNh14Y0j0jAg2qRYHXaYBX8u3Ryd73zrixwepaDGhD3xTh6LV p7MinFwEhedpSYyWxmZHCZlLtCYlhYjrnGrBwwW1NSfGK3V3h3thQ0dMbKWnIMd9u/ IIEa3DMLhD3fAD3fGFrGzd8w8JWZTH8VqItKNzg75AHRslBCQ80N4gWTClRvCHswyX hQyieUmwjPZbnRGnNciIXQkTXaBhvSK2p2jduQLg9aVUY8VXO0Canm4CtQ2hkQyWel oA1uGVgq5faDQ== Date: Mon, 20 May 2024 15:41:17 +0100 From: Mark Brown To: Artur Weber Cc: Sylwester Nawrocki , Krzysztof Kozlowski , Liam Girdwood , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: Re: [PATCH v3 4/8] ASoC: samsung: midas_wm1811: Add GPIO-based headset jack detection Message-ID: <2c4c0aeb-2870-4905-bcfc-642ae40c87f1@sirena.org.uk> References: <20240519-midas-wm1811-gpio-jack-v3-0-0c1736144c0e@gmail.com> <20240519-midas-wm1811-gpio-jack-v3-4-0c1736144c0e@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lfTGNXXe0eUJp9Hl" Content-Disposition: inline In-Reply-To: <20240519-midas-wm1811-gpio-jack-v3-4-0c1736144c0e@gmail.com> X-Cookie: We are what we are. --lfTGNXXe0eUJp9Hl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --lfTGNXXe0eUJp9Hl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmZLYQwACgkQJNaLcl1U h9Dwjgf/WnkaIdmy+K4GxTBYERrrATUvQAIiQ6PjAPC/Gf9ZYNuIgC/EEe6k4Nlw WkBAfRhzMebnNCagnadq8ZyPNKp5zUVpGo2/r0QOvrJ3Ajk3RD7e18nKipsWpb7D DFrusOYqlUdIRUjWCPn/u6WWRojAH9UhnF7XiuL/NSnz9F/g0xvd8wyWa2a5+LjK NrAKc2Xd0jpBvcTGmTzS+hgFW+xr10HGoG6nutfh9Gm3hi7b9WQ2dl5eo5rGzMqO kJNvPmQA6kFPcJkCtkLFSgEARq7edL6c+l3rIr42nORS6PtmclS/vRVlkIvXBHyZ CtJveZ2pcrft4S204mzZk+4vNymYzg== =EEPv -----END PGP SIGNATURE----- --lfTGNXXe0eUJp9Hl--