From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 D2FD2360EF7 for ; Thu, 23 Jul 2026 04:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784782479; cv=none; b=HO16Vbov8tMmQnidRsM6uikcBShJcs8LWx3iVnjzboJcF4mfV4LQhC6ufP0uOORFDX4bisrkA76YYQP0XPiCDCsZMEc/3PC5JbkKrandcpZMizyt9Ne5hxS0sgMKuDBto9CBVj1ln9l/U5M0aL8YAu3OgAvsQIQnZ8aPPOY3dbc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784782479; c=relaxed/simple; bh=jJta1wP6Gxka/gvOOEwLo5cIEFpwWGZWGRX7SMxpNTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AXF4l885rmv1b43KCMi8PJcRhwG/J9ERqdefCUsM/hKahTgwgKQpj6PUcoury9b/fUFKYNrsWdU1Ut+Hy5CYR1jcJLlgtVvMQGOfZc9+hcfLFGcLwYPdtGsR56t9wh7vrUf7nr5TV0gIZFYUSMxfkhQWOdpVWhXNVreUTRbUK7I= 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=lXL7602S; arc=none smtp.client-ip=209.85.214.177 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="lXL7602S" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2ceb096e675so2709725ad.0 for ; Wed, 22 Jul 2026 21:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784782470; x=1785387270; 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=GJN91k1ihxweTvZ2euRdyyI5ivn2nMtlaxC9t7yRgHQ=; b=lXL7602StTcqlCMOIO+t8C+pB8OKPkJ4SyYxBZZ6vgyHfcwpD1k+GPj6T/Qj8YAQzu H3t+DKTdP5Vd7aHHPJ3msyyui7FLlq+2DbKEkMKqSSDTFBzfxCkRCzKa9Y7Q1IkGl0PU J5BboR/YjV6Lc37T0RWaJmi2V3oUIQwbOgNt2xbx7Ody0rw1qxsapKQsN//rgz46PCnu EYbSl+V+vhDS9CFowy9MRdIoADtnrCj1eEGv9/58BUVhh7PaSo3U1C1BOeUeiC6I2+9x tzZIpg1n8N/NQsixyVFmDbapaYefH2cMLqNGHC/cwHIMTH9fdf0HLI7aDbe4uqkZ3x7R rB4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784782470; x=1785387270; 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=GJN91k1ihxweTvZ2euRdyyI5ivn2nMtlaxC9t7yRgHQ=; b=PcrumrCJrftRYMn+99oCn3r3m055uqqa1alDwKGBwHwRgzbwScuqbMUsK2fKAVayT6 SJdryFfhmP9+c86F4pPZbc98//yLPA/PuzdM5YoUQP2glNUvMcFn0c7VAib5YuhxgR8K gg0smBv5hnFsoiFo/20LQAIAMZnIhSAcCSIXjfYyELOM6+0dttsou9EMZ1SGOx2De9t9 YNlo9LzslXpLsNUAiZRc0Fo4ChdmKIyhgO4eMjfByPRb/hSTRvT65O8lTD3bEk5616S8 IOjUP5G96peIQHzauyr3btBAorFZ+Eu3F+PTjhmy5It9diCLRfqahV/yxqgCRew3xavs 3UhQ== X-Forwarded-Encrypted: i=1; AHgh+RpvF8G8VA7vi2vhQBHyNhnL4yON24XsQ/rrdnsZfWzsPKyyJkwu4QInpGytv8VJkGEIIvZcmpvlrdjEpRE=@vger.kernel.org X-Gm-Message-State: AOJu0YzHc525+x6p+NH6MxLM68oI7r0NEFC/788bToiRp2m+mgKwrw78 yZQ+i2YBwoHmMbe6U8LGPtkAa11osVNBc/UZs2Hn5xY5rei3yiGZDohw X-Gm-Gg: AR+sD12z4JkDTd2vXPHrqC2c20vmk/MQApDvNgYoVBUxABoVUDR+9mqiFABGBFpRUu1 58eRrc/OTxhRltMWBTEW2PUGD1HPcORbtGsMQy/SwDS3ocsVlt81OwNl1CKqZVfVy/Iv8bVuTwR FhKhGFgqr/0iupA/xY7IrQ8mPURmNLzcG8CSXWBmrCYMOKiu3QXqL1OBMfdlKZtZpEwh2cCPrpo HxuQbd48BdJQell59aFWb7M4yHvuWQBk90PXaMzVS3MKLmLEjEmqT9Ct9XRGRdxYEDDhp5ajGA+ V3DTlTJVIvSyeXEjiR8TPx+l/fw2IYhMPe8on0TZB0F0rugmUxjUtPscAZq36vcDggHPdSmRxi6 ymEhGlhM1tdr54Whlacqn45zo34GNDicNr6cWIYSjgeMXi+LqhaReAdML4hLUhBK5pKepJkd+Qm uhmOp7/Lsdcf3EoTuDlrqyTdyqbAqtFX2iO6XP X-Received: by 2002:a17:902:ecc4:b0:2cc:9473:97c8 with SMTP id d9443c01a7336-2cfa6b7dbbemr19302125ad.15.1784782469929; Wed, 22 Jul 2026 21:54:29 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cfa57542e0sm7258365ad.67.2026.07.22.21.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 21:54:29 -0700 (PDT) From: phucduc.bui@gmail.com To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Lars-Peter Clausen , nuno.sa@analog.com, Shenghao Ding , Kevin Lu Cc: Baojun Xu , Sen Wang , Steven Eckhoff , Srinivas Kandagatla , Kuninori Morimoto , Charles Keepax , Linus Walleij , u.kleine-koenig@baylibre.com, Thorsten Blum , Kees Cook , Chen Ni , Bartosz Golaszewski , Shengjiu Wang , Sebastian Krzyszkowiak , Pengpeng Hou , Richard Fitzgerald , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, bui duc phuc Subject: [PATCH 06/26] ASoC: codecs: tas5805m: Use guard() for mutex locks Date: Thu, 23 Jul 2026 11:53:07 +0700 Message-ID: <20260723045327.28260-7-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723045327.28260-1-phucduc.bui@gmail.com> References: <20260723045327.28260-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/tas5805m.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c index bcc8cab8d667..f76e04b403b5 100644 --- a/sound/soc/codecs/tas5805m.c +++ b/sound/soc/codecs/tas5805m.c @@ -12,6 +12,7 @@ // // It has been simplified a little and reworked for the 5.x ALSA SoC API. +#include #include #include #include @@ -230,10 +231,9 @@ static int tas5805m_vol_get(struct snd_kcontrol *kcontrol, struct tas5805m_priv *tas5805m = snd_soc_component_get_drvdata(component); - mutex_lock(&tas5805m->lock); + guard(mutex)(&tas5805m->lock); ucontrol->value.integer.value[0] = tas5805m->vol[0]; ucontrol->value.integer.value[1] = tas5805m->vol[1]; - mutex_unlock(&tas5805m->lock); return 0; } @@ -249,13 +249,12 @@ static int tas5805m_vol_put(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas5805m_priv *tas5805m = snd_soc_component_get_drvdata(component); - int ret = 0; if (!(volume_is_valid(ucontrol->value.integer.value[0]) && volume_is_valid(ucontrol->value.integer.value[1]))) return -EINVAL; - mutex_lock(&tas5805m->lock); + guard(mutex)(&tas5805m->lock); if (tas5805m->vol[0] != ucontrol->value.integer.value[0] || tas5805m->vol[1] != ucontrol->value.integer.value[1]) { tas5805m->vol[0] = ucontrol->value.integer.value[0]; @@ -265,11 +264,10 @@ static int tas5805m_vol_put(struct snd_kcontrol *kcontrol, tas5805m->is_powered); if (tas5805m->is_powered) tas5805m_refresh(tas5805m); - ret = 1; + return 1; } - mutex_unlock(&tas5805m->lock); - return ret; + return 0; } static const struct snd_kcontrol_new tas5805m_snd_controls[] = { @@ -332,7 +330,7 @@ static void do_work(struct work_struct *work) dev_dbg(&tas5805m->i2c->dev, "DSP startup\n"); - mutex_lock(&tas5805m->lock); + guard(mutex)(&tas5805m->lock); /* We mustn't issue any I2C transactions until the I2S * clock is stable. Furthermore, we must allow a 5ms * delay after the first set of register writes to @@ -345,7 +343,6 @@ static void do_work(struct work_struct *work) tas5805m->is_powered = true; tas5805m_refresh(tas5805m); - mutex_unlock(&tas5805m->lock); } static int tas5805m_dac_event(struct snd_soc_dapm_widget *w, @@ -362,7 +359,7 @@ static int tas5805m_dac_event(struct snd_soc_dapm_widget *w, dev_dbg(component->dev, "DSP shutdown\n"); cancel_work_sync(&tas5805m->work); - mutex_lock(&tas5805m->lock); + guard(mutex)(&tas5805m->lock); if (tas5805m->is_powered) { tas5805m->is_powered = false; @@ -379,7 +376,6 @@ static int tas5805m_dac_event(struct snd_soc_dapm_widget *w, regmap_write(rm, REG_DEVICE_CTRL_2, DCTRL2_MODE_HIZ); } - mutex_unlock(&tas5805m->lock); } return 0; @@ -414,14 +410,13 @@ static int tas5805m_mute(struct snd_soc_dai *dai, int mute, int direction) struct tas5805m_priv *tas5805m = snd_soc_component_get_drvdata(component); - mutex_lock(&tas5805m->lock); + guard(mutex)(&tas5805m->lock); dev_dbg(component->dev, "set mute=%d (is_powered=%d)\n", mute, tas5805m->is_powered); tas5805m->is_muted = mute; if (tas5805m->is_powered) tas5805m_refresh(tas5805m); - mutex_unlock(&tas5805m->lock); return 0; } -- 2.43.0