From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 96E01403E9A for ; Wed, 10 Jun 2026 12:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781096053; cv=none; b=aNxWMQOtB1VK+2Dg1pkAsrJqN/PZsOvvc3uEfgYB1Zfz0J73UEziM4iOLxzpH3ae4Z6Ujd1puSGirKwpZ4zqa6MDf3IVWjVOdw+UHeuu5C+70MJ8mre6364njbXJejJH5qhIxfv4Gz1pi6w+U0B+wt7Rhd5BEw8zkuJwfOH0sdg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781096053; c=relaxed/simple; bh=1tvo4XgBRSYrcTdKwD2gHBeJTIo6MRtVa5EWFdqM8VM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=T420Y7LTqcKn0fUC57nbQOlVSaH45MGuYfZNflrnLL7VwUCIloncHhhaPsBgsYnbivv+02aHcYdYgLKU516IZaBxazgnpl9bZ19buZY/admeg1qSFWn+6kjwuWr1XegJMQWxtGMfgkh0Phwj8F5kawzHJuBBKclVL1EtiiH7RSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=V7N0obFH; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="V7N0obFH" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490c1915793so47660055e9.2 for ; Wed, 10 Jun 2026 05:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1781096050; x=1781700850; darn=vger.kernel.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OdNmA7Q456iosyYRzPrqg00tebsLAHHTciT1QX6nIpA=; b=V7N0obFHR4lqk9o6kuaaL7qv11uJvP12zLMHnAWgAhTBsQsAAjjix+Tf1PcbXr4/1D 4e+iSx6+x/UVgUbkVBR0I9RurFdtPdYpA4HMQJjBJISi0gg1a5AmeNNJbFhL0mndD2RG wsCyraR2Ouh31TgbfOhe9QB6NbZcCJdun4VJJHAvdZZuyi0fpnd2Mnmet0cPHHnjSrKx 7vePx7nqb6h/J7QUh+HHHbq6uZEtcC2ZH119AWORuOH2iPZmjIqq4oxQ9u4TOFZhd59F lQ+lhOvM/R9mSmmQOTTfjJSp8cQQJFHq0uZj8y4JJRe1cGnU3HIrC7UiyTY0gHIDQktV aAdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781096050; x=1781700850; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=OdNmA7Q456iosyYRzPrqg00tebsLAHHTciT1QX6nIpA=; b=Gw/gbfn0IoL7UEvh1OHp1sTo0gN+YxDMCJbAyJLyA/QyypsseCzss+1IzvenEBzKEK EvfdWbSxlvQ7Fu9Qaq/YNyJjtaCJ7fCidsfXreehZomIADwbmt1jhsD5vf2HqKwpaWiD NxyWaQhl/Dgm1K3EXjuP9QExzV37uRWJq8KWkWRPEM2fvLvRzoh4aDwSslH+gTD6vv09 dCw35naikYNYovDE5JeIsirLjCh2G6olmY2JDOiTTGl5n08AVa5Du4vwaBAlb2Yb8Esp MQI90pgNmCmEYiblWcwpO7T7GixV6X6qo9sbNRpavNYBpJE/Rpe5AL6gDDFDipa/h2BS e7Xg== X-Forwarded-Encrypted: i=1; AFNElJ/2eCL8poGLF/5ob6E/cdR7U+G1qE9agM2kFjbTJ6QAEs26znEYyBThHeG0YxyJ3cO3iNJCQZYnm56Ur+A=@vger.kernel.org X-Gm-Message-State: AOJu0YwXQ1eIGKXnx538S8U/cR6d9hPJReCVpcE7wyryPgwRnOk1E3O/ EycoS3y25XeoJxZzLAAzZpXXVt9SsIQOKcmqA0l9YJp7qW2H18r5i+DYkg5/TN6i3jI= X-Gm-Gg: Acq92OE3w1jXsPmnLRyreLufvZzI9J/51iDqQCb7Q78+ePpGW3SNnEfV1ybXuhe1EWY uap55eE1aC7n+c33QdRMMHzHgLZLgxcwRbbdSh8IwETfbfs5D5sniDAT5b1l41hxyUdbUQwECgV 6shhLb71/bc6A15nqH7i2C0Isf5TUPr+pg4bp/6oG/GfMnZihAGHmQdRxNQr233OM1fRnCFgBut FRaDRA300tgHoZffcTiheWBLOMaeJtawwXZhqx1dBBFF9KbPXIe7HCRlNd++vRNiTDSzsKydtYY 0kCXzORN/hKNnt1MopD1kwLMW0JJuK80c2f9VY5opWO/SXNU7aFFDbMak6bl/J5FWMJjawUbah+ mQ/eue3fCSDsh7cTsf1yZ28B+xHZY3NfsCMKpHCNG7LptMDLxedn6Kw8sawRs2E57wP7IgfrTLM l63kW3MKE1bPuSTAl4C56awxl3KDMkyORr X-Received: by 2002:a05:600c:37c9:b0:490:adb6:7957 with SMTP id 5b1f17b1804b1-490c262dcb5mr391675255e9.33.1781096050039; Wed, 10 Jun 2026 05:54:10 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:c371:18ed:9599:7f5f]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-490bc3fd502sm562365245e9.11.2026.06.10.05.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 05:54:09 -0700 (PDT) From: Jerome Brunet To: phucduc.bui@gmail.com Cc: Mark Brown , Liam Girdwood , Neil Armstrong , Kevin Hilman , Martin Blumenstingl , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks In-Reply-To: <20260610102153.83367-1-phucduc.bui@gmail.com> (phucduc bui's message of "Wed, 10 Jun 2026 17:21:53 +0700") References: <20260610102153.83367-1-phucduc.bui@gmail.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Wed, 10 Jun 2026 14:54:08 +0200 Message-ID: <1j8q8mfte7.fsf@starbuckisacylon.baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On mer. 10 juin 2026 at 17:21, phucduc.bui@gmail.com wrote: > From: bui duc phuc > > Clean up the code using guard() for mutex locks. > Merely code refactoring, and no behavior change. I suppose it is OK but it does not seem to really clean anything and make the code easier to follow in that instance, from my perspective at least. If there is policy to systematically use guard() whenever possible then OK, otherwise it seems unnecessary. > > Signed-off-by: bui duc phuc > --- > sound/soc/meson/axg-tdm-formatter.c | 22 ++++++++-------------- > 1 file changed, 8 insertions(+), 14 deletions(-) > > diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c > index f451e4dce442..a6ba401104d5 100644 > --- a/sound/soc/meson/axg-tdm-formatter.c > +++ b/sound/soc/meson/axg-tdm-formatter.c > @@ -157,20 +157,19 @@ static int axg_tdm_formatter_attach(struct axg_tdm_formatter *formatter) > struct axg_tdm_stream *ts = formatter->stream; > int ret = 0; > > - mutex_lock(&ts->lock); > + guard(mutex)(&ts->lock); > > /* Catch up if the stream is already running when we attach */ > if (ts->ready) { > ret = axg_tdm_formatter_enable(formatter); > if (ret) { > pr_err("failed to enable formatter\n"); > - goto out; > + return ret; > } > } > > list_add_tail(&formatter->list, &ts->formatter_list); > -out: > - mutex_unlock(&ts->lock); > + > return ret; > } > > @@ -178,9 +177,8 @@ static void axg_tdm_formatter_dettach(struct axg_tdm_formatter *formatter) > { > struct axg_tdm_stream *ts = formatter->stream; > > - mutex_lock(&ts->lock); > - list_del(&formatter->list); > - mutex_unlock(&ts->lock); > + scoped_guard(mutex, &ts->lock) > + list_del(&formatter->list); > > axg_tdm_formatter_disable(formatter); > } > @@ -330,7 +328,7 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts) > struct axg_tdm_formatter *formatter; > int ret = 0; > > - mutex_lock(&ts->lock); > + guard(mutex)(&ts->lock); > ts->ready = true; > > /* Start all the formatters attached to the stream */ > @@ -338,12 +336,10 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts) > ret = axg_tdm_formatter_enable(formatter); > if (ret) { > pr_err("failed to start tdm stream\n"); > - goto out; > + return ret; > } > } > > -out: > - mutex_unlock(&ts->lock); > return ret; > } > EXPORT_SYMBOL_GPL(axg_tdm_stream_start); > @@ -352,15 +348,13 @@ void axg_tdm_stream_stop(struct axg_tdm_stream *ts) > { > struct axg_tdm_formatter *formatter; > > - mutex_lock(&ts->lock); > + guard(mutex)(&ts->lock); > ts->ready = false; > > /* Stop all the formatters attached to the stream */ > list_for_each_entry(formatter, &ts->formatter_list, list) { > axg_tdm_formatter_disable(formatter); > } > - > - mutex_unlock(&ts->lock); > } > EXPORT_SYMBOL_GPL(axg_tdm_stream_stop); -- Jerome