Re: [PATCH 15/24] ASoC: codecs: cs42l43: Use guard() and PM runtime scope helpers

Charles Keepax <[email protected]>
Newsgroups dev.linux.lists.asahi,dev.linux.lists.chrome-platform,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <[email protected]>
On Fri, Jun 26, 2026 at 01:13:20PM +0700, [email protected] wrote:
> From: bui duc phuc <[email protected]>
> 
> Convert mutex locking to guard(mutex) and replace explicit runtime
> PM handling with runtime PM scope helpers.
> This simplifies the control flow by removing explicit cleanup paths
> and unnecessary 'goto' labels.
> 
> Signed-off-by: bui duc phuc <[email protected]>
> ---
> -	if (!jack)
> -		goto done;
> +	if (!jack) {
> +		regmap_update_bits(cs42l43->regmap, CS42L43_HS_BIAS_SENSE_AND_CLAMP_AUTOCONTROL,
> +				   CS42L43_JACKDET_MODE_MASK |
> +				   CS42L43_S0_AUTO_ADCMUTE_DISABLE_MASK |
> +				   CS42L43_HSBIAS_SENSE_TRIP_MASK, autocontrol);
> +		regmap_update_bits(cs42l43->regmap, CS42L43_PDNCNTL,
> +				   CS42L43_RING_SENSE_EN_MASK, pdncntl);
> +		dev_dbg(priv->dev, "Successfully configured accessory detect\n");
> +
> +		return 0;

I really don't like this duplicating of code blocks, it takes us
to a situation we always need to remember to update both blocks
in sync which feels like it makes reviewing future patches very
error prone.

Thanks,
Charles
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.