From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91411C43458 for ; Tue, 30 Jun 2026 06:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1nOU0FRM/CVb4ITNAIwXG/xESH05yUYICHxJJfHCnxk=; b=N7ga96QOMBxznQIjlOVT3HQezu +V5axhGSnOKs+EKjil3cgFit2c1KN6DxDHHOTTxOdzQi+chRM3eni4CBfsuohVxr97vAvEtDX6+us Ajryff9H/16rb6ngGUvFYsXAZvI/sBaMAQw9oROi6aNYAtR7s6Rse39eyFOat58zkH/9B9fcxRvo0 Bu8hEnafqT2FXsgs4LcTEiLkDe5HIrRuVpaxYboNJEp2OfazL4wt9ETQLPDhhjox64o85fkdwIvYr SJujxMjqWokW1qX2Tgc7N8MJBGkbRj2EBA/j38H0e6w2zmb0H6y4JB77CaZRZeXBUqGzQNYI4t0aF /OpC1Ubg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1weS51-0000000FyVi-3nW4; Tue, 30 Jun 2026 06:36:23 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1weS4y-0000000FyT5-3TJ8 for linux-arm-kernel@lists.infradead.org; Tue, 30 Jun 2026 06:36:22 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-84592b55832so2065130b3a.3 for ; Mon, 29 Jun 2026 23:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782801380; x=1783406180; darn=lists.infradead.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; bh=1nOU0FRM/CVb4ITNAIwXG/xESH05yUYICHxJJfHCnxk=; b=F+yw5e4p2iVLW4u+oyW6YtC+XLVfIB5rFvz1rLM+RuzOhMAyniEqrZTx9/0MrdXnK/ RyfTcgoUBARMoIN/mPrJSYaSBuM7NjHHJJZ2G847GXzOA5zpzyf0se7d2sKSYpEX9jJO LoMDdGvHkYNeTqsrg44WrrsGozyINOEbp6+cwf3PWA06+qCjm8q3QD20ozxZWxwwqXmL DncNOgYSMuE7JxnETAcDRSLzv9MnNlYyhIDmnHPt6eV+t0QabT3htSGIJE4rB/RZO4ol IbKrUgn1O/j9Z82I+yKQ1rvv5c91uZvvBErBfNRcLz4yMqKQwhYcndERkT3AJGqcpXoE UUQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782801380; x=1783406180; 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; bh=1nOU0FRM/CVb4ITNAIwXG/xESH05yUYICHxJJfHCnxk=; b=lPj514FfJ6oXMTN2pkCDnPSyqNsLej/vl74iu0Mq2n/rO2fjkOgWHYBl9hSJnZqCvl BgNgcGllBevE/1ARfhjmUTjQzvkuXUE/Aq3KC4TD/jHZD1Zd++fPNLjT2YxKj6M8yJat 5R2BmnS5eLneiyvF2KHuoj+E8Vw+fz9xQX0c3RJ8/JBTmZkLuxIip3PKqH9hJRdNwnkK aQ+ocx5BPsT2PSQcu6q5+bN3c9pjp7ng3vemHnlm6bBfobXu8oiAc0UC5M14dX5N2JqH mydb2cHR6SFZRqxYNV6XUk9PYMyGRLfX3OpprEQk0iRH2pKYg6JaLulH+Ka9Sdo4nnD9 pqZw== X-Forwarded-Encrypted: i=1; AHgh+Rrvj1Xz2773uWnQ+nqy/Mmk6nvKl4imU3qeOG42yzrJq6on8AJI12RK7+q+t0HjUs7Msl1xLSbVZuedmpYpzI88@lists.infradead.org X-Gm-Message-State: AOJu0YwPRPi9ep4pkIwmmFmtUXwXTf8f2Zst8l4VRgyQyFtBxtScD00O lW+0qgKE8IC3TXuFtIQA6kQQcxTJTubqG1SBh4cM+bRlGd5iocPBKYjL X-Gm-Gg: AfdE7cmtXAULx0giz/0C+/KtMMj6F5ywJ8OajwzKwkXUfoXLGqfKgne466X8GP4Rh6r e2PXuIj+YFsCyLB3gJOvO0ac1D12Ona5L5Q+ninTfCJjRTTR/sirFF581blyIOACm8pSoWzaon/ 9quiyIF/38exjB6HS5GIHJpzKFtbj6mN28O/+HTfWs9edTgzTPqlcWEtwGKh3/P0rxsYDVzYdut Ce1S3hiCUD6KDu0ck8xfD+yPzK0+/jDHkhywDJEnNdXHbXpyeC/8p89i69WHHiooWtdpeThTz7i lV2rEsPtMDcZDm6EUqXGctkbY9ZGM2RboVXCYEaGiVj7aKBgu2i5osrUW+FV29HW03+wx2RBPCL J30lv1gXXe1sBuCJpmTHp53QEmVH7mzTIpqKDi6tuxU4oJUzFitDNSbs6Ol+JnxGCf0UBacvDap UAuVs2snopmEjkfrfbOIwroind0mrabY9nbDqFSzVl8SB55Bc= X-Received: by 2002:aa7:9066:0:b0:846:2f3c:3f66 with SMTP id d2e1a72fcca58-8479f2bf928mr1991151b3a.60.1782801379790; Mon, 29 Jun 2026 23:36:19 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847a02cd237sm1165061b3a.32.2026.06.29.23.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 23:36:19 -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 07/27] ASoC: codecs: hdac_hdmi: Use guard() for mutex locks Date: Tue, 30 Jun 2026 13:34:29 +0700 Message-ID: <20260630063449.503996-8-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260630063449.503996-1-phucduc.bui@gmail.com> References: <20260630063449.503996-1-phucduc.bui@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260629_233620_878418_FBF2416B X-CRM114-Status: GOOD ( 18.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/hdac_hdmi.c | 117 +++++++++++++++++------------------ 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 3220f9226e0b..387fa22438a0 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -10,6 +10,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include #include #include #include @@ -537,10 +538,11 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( continue; list_for_each_entry(port, &pcm->port_list, head) { - mutex_lock(&pcm->lock); - ret = hdac_hdmi_query_port_connlist(hdev, - port->pin, port); - mutex_unlock(&pcm->lock); + scoped_guard(mutex, &pcm->lock) { + ret = hdac_hdmi_query_port_connlist(hdev, + port->pin, + port); + } if (ret < 0) continue; @@ -640,11 +642,11 @@ static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); if (pcm) { - mutex_lock(&pcm->lock); - pcm->chmap_set = false; - memset(pcm->chmap, 0, sizeof(pcm->chmap)); - pcm->channels = 0; - mutex_unlock(&pcm->lock); + scoped_guard(mutex, &pcm->lock) { + pcm->chmap_set = false; + memset(pcm->chmap, 0, sizeof(pcm->chmap)); + pcm->channels = 0; + } } if (dai_map->port) @@ -922,7 +924,7 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, if (port == NULL) return -EINVAL; - mutex_lock(&hdmi->pin_mutex); + guard(mutex)(&hdmi->pin_mutex); list_for_each_entry(pcm, &hdmi->pcm_list, head) { if (list_empty(&pcm->port_list)) continue; @@ -945,12 +947,10 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, list_add_tail(&port->head, &pcm->port_list); if (port->eld.monitor_present && port->eld.eld_valid) { hdac_hdmi_jack_report_sync(pcm, port, true); - mutex_unlock(&hdmi->pin_mutex); return ret; } } } - mutex_unlock(&hdmi->pin_mutex); return ret; } @@ -1274,67 +1274,65 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, * In case of non MST pin, get_eld info API expectes port * to be -1. */ - mutex_lock(&hdmi->pin_mutex); - port->eld.monitor_present = false; + scoped_guard(mutex, &hdmi->pin_mutex) { + port->eld.monitor_present = false; - if (pin->mst_capable) - port_id = port->id; + if (pin->mst_capable) + port_id = port->id; - size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, - &port->eld.monitor_present, - port->eld.eld_buffer, - ELD_MAX_SIZE); + size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, + &port->eld.monitor_present, + port->eld.eld_buffer, + ELD_MAX_SIZE); - if (size > 0) { - size = min(size, ELD_MAX_SIZE); - if (hdac_hdmi_parse_eld(hdev, port) < 0) - size = -EINVAL; - } - - eld_valid = port->eld.eld_valid; + if (size > 0) { + size = min(size, ELD_MAX_SIZE); + if (hdac_hdmi_parse_eld(hdev, port) < 0) + size = -EINVAL; + } - if (size > 0) { - port->eld.eld_valid = true; - port->eld.eld_size = size; - } else { - port->eld.eld_valid = false; - port->eld.eld_size = 0; - } + eld_valid = port->eld.eld_valid; - eld_changed = (eld_valid != port->eld.eld_valid); + if (size > 0) { + port->eld.eld_valid = true; + port->eld.eld_size = size; + } else { + port->eld.eld_valid = false; + port->eld.eld_size = 0; + } - pcm = hdac_hdmi_get_pcm(hdev, port); + eld_changed = (eld_valid != port->eld.eld_valid); - if (!port->eld.monitor_present || !port->eld.eld_valid) { + pcm = hdac_hdmi_get_pcm(hdev, port); - dev_dbg(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", - __func__, pin->nid, port->id); + if (!port->eld.monitor_present || !port->eld.eld_valid) { - /* - * PCMs are not registered during device probe, so don't - * report jack here. It will be done in usermode mux - * control select. - */ - if (pcm) { - hdac_hdmi_jack_report(pcm, port, false); - schedule_work(&port->dapm_work); - } + dev_dbg(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", + __func__, pin->nid, port->id); - mutex_unlock(&hdmi->pin_mutex); - return; - } + /* + * PCMs are not registered during device probe, so don't + * report jack here. It will be done in usermode mux + * control select. + */ + if (pcm) { + hdac_hdmi_jack_report(pcm, port, false); + schedule_work(&port->dapm_work); + } - if (port->eld.monitor_present && port->eld.eld_valid) { - if (pcm) { - hdac_hdmi_jack_report(pcm, port, true); - schedule_work(&port->dapm_work); + return; } - print_hex_dump_debug("ELD: ", DUMP_PREFIX_OFFSET, 16, 1, - port->eld.eld_buffer, port->eld.eld_size, false); + if (port->eld.monitor_present && port->eld.eld_valid) { + if (pcm) { + hdac_hdmi_jack_report(pcm, port, true); + schedule_work(&port->dapm_work); + } + print_hex_dump_debug("ELD: ", DUMP_PREFIX_OFFSET, 16, 1, + port->eld.eld_buffer, port->eld.eld_size, false); + } } - mutex_unlock(&hdmi->pin_mutex); if (eld_changed && pcm) snd_ctl_notify(hdmi->card, @@ -1795,13 +1793,12 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx, if (list_empty(&pcm->port_list)) return; - mutex_lock(&pcm->lock); + guard(mutex)(&pcm->lock); pcm->chmap_set = true; memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); list_for_each_entry(port, &pcm->port_list, head) if (prepared) hdac_hdmi_setup_audio_infoframe(hdev, pcm, port); - mutex_unlock(&pcm->lock); } static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdev, int pcm_idx) -- 2.43.0