From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 7BE86369D62 for ; Fri, 10 Jul 2026 05:05:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783659931; cv=none; b=pbdB7PB6JVXd+EnAOjEonUB9h1LFxB082JmqmUPsKIC8kARwSzDre1hQG7/TU2Jjv+5d+HthDFRSI6l0OeAZK59hdrsZ2xMqRtcPmpBzypxn9uDw1XYOt6MYzu9ydOIemn6GK6Zmvxf3tnmQZFZ5ijUdz6oHG5h1yg27SGsazQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783659931; c=relaxed/simple; bh=XWI4jCnd/t/sfMXYAr8klk5lyo9qyWRg1g/x4qLIB2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eb21g2+PkOdvkBLhxFRduxsr+Dh1mdDR9IUjEdtCCqI0UN7Cm5wCLmpAHz3NFEuZ7hhJ7b7iPbnpSHyI+FkD6Qr5rwx5fD1CTGyMT4oISLX/C5dggKwHPxyhi1AaL4yUJktafjCNt/VTMkK/oKdmD0W6QejVfHSYdI1jc7ntfik= 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=WNQlyv2B; arc=none smtp.client-ip=209.85.210.180 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="WNQlyv2B" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-848479c9bd5so340797b3a.3 for ; Thu, 09 Jul 2026 22:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783659930; x=1784264730; 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=8FKz6zL2lYGruFgrXSmVh8CpNcaMm/DKeCPXfcKM2u4=; b=WNQlyv2BB5sZzZX4H+nzmWrCc5ZWL4M7Km+7xOqnx6zoVsQ3X5/iMB/AD7MXu3NhBD RMEbO9VX2bC53Y8AsfxeRGRACAW0W+cC0qlKS3KZHylzPuEPdDD1FWgABB2GQPXXEU35 ewLoAmpb/zSTkLvl/ENuAqtaVdqVJZFpBjkWJnchaOswFXmotGViIHY0twnyP4WLxwxD noreLd9Pmb+oC6x6XeUeUeB0/h3EYRmCu1xQn/89DZR5AzES1gRmWX3fU6e9/PsU7ZxL q34Jj75DK36N4Ir1hDN5Pq11J43Nr+9gSXLMLGKCoHKHrTFGSNmc4YhyMHp2jfwX9dIh fiQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783659930; x=1784264730; 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=8FKz6zL2lYGruFgrXSmVh8CpNcaMm/DKeCPXfcKM2u4=; b=IyjSaKroVFJoxDJPseA+dhL0DJfqimgS66fngCrv/6e4v36oeRkAVo46y5KK1OzitR Em7cblqkGZWOS3c2plWo3K2MoX8LrASEajio7sL9mOSJkX8PHU0e3mRJRdcarFjiJ5uL fGYu6Gm9jsYTwu5IX6wke+Tpu+w2VIvarQ3YzVITbBNr5BrxAA746O1pdn3KmSC369jI tYTokjyT528nGlH7ZxLwR1J5JGnDo+OvD8I3nNzcrsyWK3OWuPPQX6fZL5k6I5FyhZpB 42HKNszDPV/iZywtgNkzlKva1BA753+h4cf7C4cWvoy/AmbWslQGLfp6rc29OcKS8BiO QPAA== X-Forwarded-Encrypted: i=1; AHgh+RoDMzhvwqvSY4ZzedWluoEqD8Nu+5joVBathR9oHKwQewCV6w+vq+M9kYmt85L6532xsIIKe9zwKrK7vlQr@vger.kernel.org X-Gm-Message-State: AOJu0Ywh8xqfvFSdQsrpyLDtZdYd3M08ZPuHgnOB5+tQGFr4B5lnbPkR h0c/ZrRJMWNmPRqXT6vVc71D2Z5IglQdH0TZBhzzqPKX6GsaSKFqpDV9 X-Gm-Gg: AfdE7cks8fDnelqM/na0UMm/U89CpbWjl6pNrtc9Seu4tmDkckaPqzUG8TLHrg4quhs 6f6zvtq7HHgiZi8s2NfThgYxgXojlLV4uXr/vYmoyiBKc9wR4QiaMZ4HMQH/eUMJrgB2TX7JwgV 1uX4zCTh4K0JfiLXTyin3/XoiHTYrmxL/UMOqPI7zD5RblDxE80Jf3x81VeM1j57NpXb/XlAwet J65W1mhwDSAnCCgskKyNOtTyADM2p7BAsLAadGLRLfXyHqX2AFS6rOjdXx958A+ifZQZjMVHsHK jsbl65jr6mBH+6Eatl6SQ8xJbYo50zBDkQr+dw6WGKAF2IQ48yfs5v1ZXIJ7BmmLygaTSKjyd1w wECePD3WbOSPDS7TV5Yf4sna+nSJIZr1hp0XMXSu2H0m8GqVR1Ggj6UPQEqOUPy1qFoOGRvocn4 6z5BFIPK4H/7WzsjzlBJNElG/kRd2RnxO/+6d1o94gj7D1g8BGarGRQ+Haxg== X-Received: by 2002:a05:6a00:400d:b0:848:6447:e09c with SMTP id d2e1a72fcca58-8486447e365mr3946827b3a.39.1783659929668; Thu, 09 Jul 2026 22:05:29 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84847275fa0sm3400499b3a.22.2026.07.09.22.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 22:05:29 -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 v3 03/27] ASoC: codecs: es8316: Use guard() for mutex locks Date: Fri, 10 Jul 2026 12:04:47 +0700 Message-ID: <20260710050511.14439-1-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709045902.498848-1-phucduc.bui@gmail.com> References: <20260709045902.498848-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-arm-msm@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 3abe77423f29..87f331868dc7 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -620,15 +621,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; @@ -681,8 +682,6 @@ static irqreturn_t es8316_irq(int irq, void *data) } } -out: - mutex_unlock(&es8316->lock); return IRQ_HANDLED; } @@ -699,18 +698,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); @@ -726,7 +723,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); @@ -737,8 +734,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