From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E56B44D6BB for ; Wed, 8 Jul 2026 14:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783520370; cv=none; b=lbh8O+FysRNXwEBplWOXC2biGIIC91715hLezQx0dp8FfjpaDLgLb6JPNuiBLSGr6TucPz3KSlkD7DMPjt37QsbWiDjmhBaFyRoIo/1ahJLMJKOIzikw2cJZtcTdC63mCapZT6I+i1HM9j5l8YltJGz9amiPiauLcliqag0pFiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783520370; c=relaxed/simple; bh=vGG3xbNRD9aTcWhmHrqO23PJ1N/lJS4R0ZsiliefWlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y/lrqqixQEXsk/M6t+WgSdLDiqhK6VlxP6icrqTMB9yE/TWaLptpy7MOMPoNRYjtCEiqamlBcYDibb/fVAaHjza9qBSi6Ezcyfv9y1w21OkB9IV9BsV4eDou2SMWPVsgCL82+tSK9zZ2rjAsCtOLUEEeKiO+bZI/EbRmLoWnb4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RHnIz9ik; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RHnIz9ik" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2cace91f112so8237235ad.0 for ; Wed, 08 Jul 2026 07:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783520367; x=1784125167; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RozeYceB4iwycNfbGDK46tH90J5JBru51kfxpqOiyNk=; b=RHnIz9ikvYpo7/5m3Lv/wD+hLKgADmCSXXATNl/tXz7CK/OfN84PViBiesv4tV3GkK Bvd8/m4VotMI1kZ9PR/HQZscBmNBb92y0arzgyJxOjOxGkx2Xux2UN5T8RYINsppp0u8 FqfFhF84k4VhLfISjtvyzlucP3C4eVtznDWk6x4wlY03evVIyzqu1/QY//z+7+uYB0nS iC7Z1ONqDWfPSLXYS0bMCMneEgqzddSGkuqUN9mnja0QRnmkxRojCuvymisfbTHV7r2M kr9ZXvB+ubHKh9oHO85bekN3iKvE9SAGtHzzZowQwMfbf0jblou20LWut+eLq/PVZ+Yk azeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783520367; x=1784125167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RozeYceB4iwycNfbGDK46tH90J5JBru51kfxpqOiyNk=; b=ReDBiotWrOTBGHYzo0LMRQSFUXWLsdvLiEel7/BGZLy49TtErQcjbwEkkHUBmQ7gw1 f8hIQLzRTdIkNjp7ihjXrZGoFvLPiFqgzBhKmxmVcnFUbCKQJYIBoa4Kb2quEDmx+DU6 t9RN/Or9WxjE/PLcNMpxzolr4mab7MeISaGDzVs5elLhogYQGifaWN/WX3V99Yjv8TKz NhfwNPlsL4wN1fZE7IQHBz7CNY+AguiFUHJ6PF/HiRDYCVdCLXUeitfuaZlj51tiUlH3 055Fag7BMI/O2JEO2n/e/m+4Xf4wQpQe8zTxK0NlbVB6fXN2WMhrrUQWiQQie9ebep0k j79Q== X-Forwarded-Encrypted: i=1; AHgh+Ro8Aopc0T7MkiHBVIJVRD5ngQzKqD08QZUPdjBwDXEicpY6aFM3/f3Me/aJcnAwh7KFdQKFXsdoWPGxxzE=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3llHnLs3Bb2E+Na0b3zvt2xa+97QXA5yOuyIpP8ZnLJfZJ3Em ysB4j3KAr7EomiJla7iNlGHI2GF+3h40Hm0OArk+Yx2o+g/7GAslSolA X-Gm-Gg: AfdE7ckOwvZzwDfDRPKbj0/YunNTlNnnrtzgoT6IhcsN6/BWmJAjBoNoGUOX28PQ4a2 F2VyGlITjlgYfnPiUCrKzfrQ4mRGC1FtAoQmbpQNS3r+6vmigbFnI87K7DWAiNsDNL6iGHiwtJy YQHl4kYgh6OMsFwm97iQl0svBx5cMoi7dVNcy5sx5l/sG82/vP7JBu/ybtEvk9f8Xid2jmRidU7 bgGj7F7zx2qhvA2jldQqVIBDe04dLR8JzCaCQCGI14itSYmc54e2cLDnjtsku/dzz84Huz/H47O sOD09IqEgvFSOr2k01wSVdszDnXxnG8ul0X93yd7mtQPZUw0idokluj3Kjh0c6UTULklUejtMXw 47TPKnbPdDlJpZ3mX38a+AwNrJrZCW2z2FfDgKs0PnMdGhK3SSyBPSMZ18Wh+dIE/Al4SLnjiMX PRmZM5TEdAKO2xj7v325iwzvkM3pmDVXdyejTH97X0lL4ODI8= X-Received: by 2002:a17:903:2984:b0:2cb:ea0b:9164 with SMTP id d9443c01a7336-2ccea3849d2mr28129135ad.6.1783520367125; Wed, 08 Jul 2026 07:19:27 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9d3bcc0sm28841575ad.67.2026.07.08.07.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:19:26 -0700 (PDT) From: phucduc.bui@gmail.com To: Mark Brown , Takashi Iwai , Nick Li , Herve Codina Cc: Support Opensource , Liam Girdwood , Jaroslav Kysela , Srinivas Kandagatla , Charles Keepax , Richard Fitzgerald , Matthias Brugger , AngeloGioacchino Del Regno , Shenghao Ding , Kevin Lu , Baojun Xu , Sen Wang , Oder Chiou , Linus Walleij , Kuninori Morimoto , u.kleine-koenig@baylibre.com, Zhang Yi , Marco Crivellari , Kees Cook , HyeongJun An , Arnd Bergmann , Qianfeng Rong , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bui duc phuc Subject: [PATCH v2 03/27] ASoC: codecs: es8316: Use guard() for mutex locks Date: Wed, 8 Jul 2026 21:17:10 +0700 Message-ID: <20260708141734.578926-4-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260708141734.578926-1-phucduc.bui@gmail.com> References: <20260708141734.578926-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- sound/soc/codecs/es8316.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index 6a428387e496..e83dab0b7083 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -621,15 +622,15 @@ static irqreturn_t es8316_irq(int irq, void *data) struct snd_soc_component *comp = es8316->component; unsigned int flags; - mutex_lock(&es8316->lock); + guard(mutex)(&es8316->lock); regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags); if (flags == 0x00) - goto out; /* Powered-down / reset */ + return IRQ_HANDLED; /* Powered-down / reset */ /* Catch spurious IRQ before set_jack is called */ if (!es8316->jack) - goto out; + return IRQ_HANDLED; if (es8316->jd_inverted) flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED; @@ -682,8 +683,6 @@ static irqreturn_t es8316_irq(int irq, void *data) } } -out: - mutex_unlock(&es8316->lock); return IRQ_HANDLED; } @@ -700,18 +699,16 @@ static void es8316_enable_jack_detect(struct snd_soc_component *component, es8316->jd_inverted = device_property_read_bool(component->dev, "everest,jack-detect-inverted"); - mutex_lock(&es8316->lock); + scoped_guard(mutex, &es8316->lock) { + es8316->jack = jack; - es8316->jack = jack; - - if (es8316->jack->status & SND_JACK_MICROPHONE) - es8316_enable_micbias_for_mic_gnd_short_detect(component); - - snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE, - ES8316_GPIO_ENABLE_INTERRUPT, - ES8316_GPIO_ENABLE_INTERRUPT); + if (es8316->jack->status & SND_JACK_MICROPHONE) + es8316_enable_micbias_for_mic_gnd_short_detect(component); - mutex_unlock(&es8316->lock); + snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE, + ES8316_GPIO_ENABLE_INTERRUPT, + ES8316_GPIO_ENABLE_INTERRUPT); + } /* Enable irq and sync initial jack state */ enable_irq(es8316->irq); @@ -727,7 +724,7 @@ static void es8316_disable_jack_detect(struct snd_soc_component *component) disable_irq(es8316->irq); - mutex_lock(&es8316->lock); + guard(mutex)(&es8316->lock); snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE, ES8316_GPIO_ENABLE_INTERRUPT, 0); @@ -738,8 +735,6 @@ static void es8316_disable_jack_detect(struct snd_soc_component *component) } es8316->jack = NULL; - - mutex_unlock(&es8316->lock); } static int es8316_set_jack(struct snd_soc_component *component, -- 2.43.0