From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 4FAAF4028C9 for ; Wed, 10 Jun 2026 10:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781088361; cv=none; b=RSXaRp6bfsMW+8NPDx/STPAKWTA4ShwHHoQThPFPJuJypg5vzmjIRRzC3gwtgS+30PKRMQc2gtlLUvUh1Z3hb5zZDwUaW0E54o4V1TZqZe/yLYKYhfWFc5cxTGXXFXH1myMi+EAqW7TxGmed3xv9ljCxe5EPGI8z3quf7P74fRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781088361; c=relaxed/simple; bh=I78UecyAVuWvCj4V3klZ4e8YWCssj6DTz26oU7aJPD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C7IZ/wkAGn9S0Zt9jMPmLorU6VI44EOdXeUL17JQ7JsrLib3daBl4Fv1uOq7V3P+37Kns+WKHb2BgF3S1f2UPsbgUfd5YCcxeGbMuDO3oSU9e2xayrFUH8AzfEKXiJIZPgwx00ROsXmBUxTe0/D+1fMNxjKVLTeXtpTBDruvNAU= 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=rzR6QjXJ; arc=none smtp.client-ip=209.85.216.49 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="rzR6QjXJ" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-372b4330deeso2478181a91.0 for ; Wed, 10 Jun 2026 03:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781088359; x=1781693159; 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; bh=RE1W3bej/2sBCXuUve43v0t09ubiwO69rCSBYDSnzuE=; b=rzR6QjXJ3IKgPgHSmmXz1fI/ApZUNR7M78fWabFdWwVUwv3dC2akzWv/wPGULwl2Q9 mw+nhmxgZZ1xg/q/sSRN/BOOZVllk2wpw5wLYQzjj/icLeS2zK5v5g0c5xhzyAXOyVLd kd3Sk5vrr/cR7dwflEYVx0r15LkAww3YDXQaQNVHyiRnQIptfM3QITY8LF8HwYnJpSuq j6A8Q3tUwrQNQfjBYe9SMmnPax4jM38i/YDuq0R1tG5n+h2/lHUkNJ+EHA1CDvF7OH8d T95hquWwmJ4JRhAdYxq67ohSmgFuJl7p8/gYXhWzTkYbGS/9eeaEiqAXEIY+srxtivqp 24WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781088359; x=1781693159; 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=RE1W3bej/2sBCXuUve43v0t09ubiwO69rCSBYDSnzuE=; b=AAv6I2W7qU53MkNI5S4GN2YdJPp3Lta+bPWbUq0BKZITKS+saRkargeLtx9qk5h7sG lboYiIdHrgy3giCorou0+g84kS40v6VSMey7TpB77LtufGomRob0CdrrzaaEPTQ3I4su qpg37PE7GlHHT2/hkcRvp2TQRvvFZKp5RG7h3FwY4vt2GQ6DVh09OQsWu71aKjUiJ656 DN9CKk5obEw+1hN6plyRcehc6+jl/GSWmhk5RRR1eMlO1cVzJFzC5TN8GItMrOoFttNL +wAgGS3fp+MP6Qz2TuTEs6yzdrWfLkw2bqP5VfKEvFAbWhSdy/MB7oomiY4Hrdww+yPM dr1g== X-Forwarded-Encrypted: i=1; AFNElJ+UJAOXXDF/wgU+ERvUKWu+5pXFIVOfMMDDztEiMdScDhkzaQHzG+twAQ7OrpN/VKWPOJ4wmPZliOeIYMs=@vger.kernel.org X-Gm-Message-State: AOJu0YwAaLSxg2bE1Ll+jRTv9cjutFQnFpzXpgCVBA8V+kGVkYusFyPX tlQjQlpMcMTeRHW5v7xpGKLDmNF3u5DTy7LwBaix2kkZCoISfgas+Q3S X-Gm-Gg: Acq92OGLQLc/yYZ4ENbDmpsnpKPCdu6oTrdDnfbC8VQjyZmeuDCrvIhqQQSvO/X9Vt4 D748bBXmUBwxbiHzVhjQCDkHmtKmnHk4LcyGuZKO2enfMqXLCuX7YVLk09M/OOzWq7UzM6O+GE6 YfVRtYzgA8P+tRU271ZFHsKnlRL7gDC759C4LihQo+SF6vPD3mtKloLqbqy+NuDBz0G1AIWJGA0 IdclbyLIiExa8Y5JVG4MMboMG62IU6pl6mlaVIYZ1ZJPCaMlGMOohHtvF5T6dqEToiu73KeqCWi 0ilH7JWm1acRMX5wJTTUAKroVoOr3DGppXrdQQppnInhMnUO0OrJKrvOZmBUQTMgCoEZT+o0YAQ d5j4PInhfIdx4BPZ2WhZCjKRsDJ6RS5f/6IfHiaA+uuxJpQ3N9L0istSnpsXuMtcw0REOmG9DQq l+RzJb9SALDlIZ7LbrdEO8FqI/36b+eNetGRg6qiXUdf3Oq+gbBoFS2xxefCnHP0wtSiwE X-Received: by 2002:a17:90b:5787:b0:368:147f:bd27 with SMTP id 98e67ed59e1d1-370f0d52f5cmr26868149a91.23.1781088358614; Wed, 10 Jun 2026 03:45:58 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84282916b10sm24455965b3a.58.2026.06.10.03.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 03:45:58 -0700 (PDT) From: phucduc.bui@gmail.com To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 1/2] ASoC: img: img-spdif-in: Use guard() for spin locks Date: Wed, 10 Jun 2026 17:45:23 +0700 Message-ID: <20260610104524.87166-2-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260610104524.87166-1-phucduc.bui@gmail.com> References: <20260610104524.87166-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 spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- sound/soc/img/img-spdif-in.c | 70 +++++++++--------------------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/sound/soc/img/img-spdif-in.c b/sound/soc/img/img-spdif-in.c index 82295e2508fa..b630644f20cc 100644 --- a/sound/soc/img/img-spdif-in.c +++ b/sound/soc/img/img-spdif-in.c @@ -179,7 +179,7 @@ static int img_spdif_in_do_clkgen_single(struct img_spdif_in *spdif, unsigned int rate) { unsigned int nom, hld; - unsigned long flags, clk_rate; + unsigned long clk_rate; int ret = 0; u32 reg; @@ -196,19 +196,15 @@ static int img_spdif_in_do_clkgen_single(struct img_spdif_in *spdif, reg |= (hld << IMG_SPDIF_IN_CLKGEN_HLD_SHIFT) & IMG_SPDIF_IN_CLKGEN_HLD_MASK; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CLKGEN); spdif->single_freq = rate; - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -216,7 +212,7 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif, unsigned int multi_freqs[]) { unsigned int nom, hld, rate, max_rate = 0; - unsigned long flags, clk_rate; + unsigned long clk_rate; int i, ret = 0; u32 reg, trk_reg, temp_regs[IMG_SPDIF_IN_NUM_ACLKGEN]; @@ -242,12 +238,10 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif, temp_regs[i] = reg; } - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } trk_reg = spdif->trk << IMG_SPDIF_IN_ACLKGEN_TRK_SHIFT; @@ -262,8 +256,6 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif, spdif->multi_freqs[2] = multi_freqs[2]; spdif->multi_freqs[3] = multi_freqs[3]; - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -323,9 +315,8 @@ static int img_spdif_in_get_multi_freq(struct snd_kcontrol *kcontrol, { struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long flags; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); if (spdif->multi_freq) { ucontrol->value.integer.value[0] = spdif->multi_freqs[0]; ucontrol->value.integer.value[1] = spdif->multi_freqs[1]; @@ -337,7 +328,6 @@ static int img_spdif_in_get_multi_freq(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[2] = 0; ucontrol->value.integer.value[3] = 0; } - spin_unlock_irqrestore(&spdif->lock, flags); return 0; } @@ -349,7 +339,6 @@ static int img_spdif_in_set_multi_freq(struct snd_kcontrol *kcontrol, struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); unsigned int multi_freqs[IMG_SPDIF_IN_NUM_ACLKGEN]; bool multi_freq; - unsigned long flags; if ((ucontrol->value.integer.value[0] == 0) && (ucontrol->value.integer.value[1] == 0) && @@ -367,17 +356,13 @@ static int img_spdif_in_set_multi_freq(struct snd_kcontrol *kcontrol, if (multi_freq) return img_spdif_in_do_clkgen_multi(spdif, multi_freqs); - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } spdif->multi_freq = false; - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -399,9 +384,8 @@ static int img_spdif_in_get_lock_freq(struct snd_kcontrol *kcontrol, struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); u32 reg; int i; - unsigned long flags; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); reg = img_spdif_in_readl(spdif, IMG_SPDIF_IN_STATUS); if (reg & IMG_SPDIF_IN_STATUS_LOCK_MASK) { @@ -416,8 +400,6 @@ static int img_spdif_in_get_lock_freq(struct snd_kcontrol *kcontrol, uc->value.integer.value[0] = 0; } - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -448,16 +430,13 @@ static int img_spdif_in_set_trk(struct snd_kcontrol *kcontrol, { struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long flags; int i; u32 reg; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } spdif->trk = ucontrol->value.integer.value[0]; @@ -474,8 +453,6 @@ static int img_spdif_in_set_trk(struct snd_kcontrol *kcontrol, img_spdif_in_aclkgen_writel(spdif, i); } - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -506,15 +483,12 @@ static int img_spdif_in_set_lock_acquire(struct snd_kcontrol *kcontrol, { struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long flags; u32 reg; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } spdif->lock_acquire = ucontrol->value.integer.value[0]; @@ -524,8 +498,6 @@ static int img_spdif_in_set_lock_acquire(struct snd_kcontrol *kcontrol, IMG_SPDIF_IN_CTL_LOCKHI_MASK; img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CTL); - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -545,15 +517,12 @@ static int img_spdif_in_set_lock_release(struct snd_kcontrol *kcontrol, { struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long flags; u32 reg; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); - if (spdif->active) { - spin_unlock_irqrestore(&spdif->lock, flags); + if (spdif->active) return -EBUSY; - } spdif->lock_release = ucontrol->value.integer.value[0]; @@ -563,8 +532,6 @@ static int img_spdif_in_set_lock_release(struct snd_kcontrol *kcontrol, IMG_SPDIF_IN_CTL_LOCKLO_MASK; img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CTL); - spin_unlock_irqrestore(&spdif->lock, flags); - return 0; } @@ -625,12 +592,11 @@ static struct snd_kcontrol_new img_spdif_in_controls[] = { static int img_spdif_in_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - unsigned long flags; struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(dai); int ret = 0; u32 reg; - spin_lock_irqsave(&spdif->lock, flags); + guard(spinlock_irqsave)(&spdif->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -657,8 +623,6 @@ static int img_spdif_in_trigger(struct snd_pcm_substream *substream, int cmd, ret = -EINVAL; } - spin_unlock_irqrestore(&spdif->lock, flags); - return ret; } -- 2.43.0