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 88D50340A46 for ; Fri, 31 Jul 2026 03:10:37 +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=1785467440; cv=none; b=nK4kEy2ViN1Tohm1TDJknKcmnbNyI8YT+O8tG8XpaUpLzEOiyzdj2vbwCSVdIjaWfkSNTg6DXk8eSvCRiI3heswGe7NZS1uLvuw+FxdJRbB6DMY0lo3sgLaMM2SnWSOclJGH2WC5+LwR91UHOPUPi9KS6WrjTy6nNB1PFsgxi7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785467440; c=relaxed/simple; bh=jJta1wP6Gxka/gvOOEwLo5cIEFpwWGZWGRX7SMxpNTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J4JaiFk5rkyaQkdOqVygnaQpSOl7FKZVSrkk5wS6aAfZg7tZUpxkWoFNrTxJuLFKC7Zm4BhwTfWJllaJT/ZGLTZ7i+t/xxzeZl85fOxjyuQFqqRmitanC8eASJPha+/PwsbJxycLw4SlpUwi2S7WDTjb1EpacTGSpF67wdCfQOU= 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=ct4IBZNu; 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="ct4IBZNu" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2cfff5f88dbso5035485ad.3 for ; Thu, 30 Jul 2026 20:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785467437; x=1786072237; 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=ct4IBZNueNkKk5K1g5s150TxSvoR5qT3WoT/PK6u1maF36nu4sM3vydJaGPdDhMfu4 Q+1Q7dafZFDY3iNxllQ5e+dIvKH+wDIgRb84G6mxdac78qvJj0WxEdgqkE9QAT5PCLku eknBZx25xR9Dm0VFdHhymfOotDFGVTEf5KHvMxsTWJ6suCYnQZqn26aZ8RVbouVGhCNf C+Kr2iVilI3pWDW/ASzTmh8tsO1Ku+4kwgYG3B89P8evDzEfwu7ma6PdeFwGg8Hfdtc/ g8RvMnaCUYFtRFJEVqq2b7TmBZBKAg1lpHplmi3Fa2E03r+She2gJhbqrPuFdcZiyXU4 XoSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785467437; x=1786072237; 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=V42Gvr9hUoEBZa84+Hy4KS3DHFzo6NxQsFhcAJI3lNOaOd/Qe+eVHB3ut3uad8/NxB bcxHWUkfdse3tS77hwqd9TP2d1zWsScEWz8USzJvwAkeEsLkDIsg3f+/gUddFR6IYCkd gI0GlVj7D5zfqcSkKi2y3qYFe85XbMAfzsMLE+1Rrq6UIv1UfhiB4qrkLVEzaLJL33SB Zj4MlpviRCSsqgEwozQq0bCCVW6t5uNUorDGvDV0Z5+MMcqwvkJ/yr928ESTuD3F3XaY pqrrGyi3KgI6nhtg3MyjCA9xyplDE+eIi/ftMDPtfXSIntKxXbbAywfv4MvznvpNWlAC B/MA== X-Forwarded-Encrypted: i=1; AHgh+Rpit/x7TvAKu9wVCf+e8EbVfxpqozENX4MDZKM9BwQwaiWBgZkM5jBsingKMchi9bq640stAydpUk3vRBQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzftSRd7rG/GCPFGzklAVRQs4TPooK4jmjzxic1LZ7VUBijz2IK +iVRDFihYdB2moJfU73+brDHBcC9+hb8UggR9xII1p3MTY5EH5qB1UuZ X-Gm-Gg: AR+sD12ydL+v9mufu+yTNLDJyGJVVl8sw4Z51aveQjMlJTIupJempO046omvskGfvS+ sNzJKD6BsomaBkSdFIGd9obZDRlwNrexsZmWTLhBmx87aawucZ36ziN6V0n0NJYGM34hlPGveCa zaPXKWE8lJDi5k+G4acd4CeufLEI3UKh+i1ei4YCjMARhIr9zTooHcWnP8YtRjUmUMIz8FxlaI3 Rd8p+83D/2Pfbkyh0Qg6s976X3d35K9dUyIE11ReELytujwF/2h3KSLY/BWujhobMLKE64p4TSg UjEVvgk6STRSyi/2JTOXGLXdeuzi7o18deHgPNTd1ea1Ivb6mDxEGU6QXty2riHihb1xVpjLiXt qAHLnv39F+zUhbosMN6qe6ztg/MtuLYYXOTM9aCelxmfixTCOuQA9T+xLJiysT1lbDYmy/cvCQi AgQl3GnOGHl1GuglZzAp/khDQOj6I7fWCmdwTcTJtkvbEsPjDKpyWXUjHt1uC2bPqERc0eNiSk9 cf/a6JmjN+28Q33zqYJkrXpVXlM/dBYaynrVSYGfGG0Y7WGRl5ma7CFWFC7lMo4YayMn5BZTLJO WlKWhBK2h2iHAis= X-Received: by 2002:a17:903:2b07:b0:2c9:cf41:adf9 with SMTP id d9443c01a7336-2d046ecdafemr5179845ad.47.1785467436860; Thu, 30 Jul 2026 20:10:36 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d047ae9f31sm737595ad.60.2026.07.30.20.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 20:10:36 -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 , Cezary Rojewski , Richard Fitzgerald 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 , 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 v3 06/26] ASoC: codecs: tas5805m: Use guard() for mutex locks Date: Fri, 31 Jul 2026 10:06:28 +0700 Message-ID: <20260731030648.8706-7-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260731030648.8706-1-phucduc.bui@gmail.com> References: <20260731030648.8706-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