The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: peter.ujfalusi@gmail.com, broonie@kernel.org
Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	jarkko.nikula@bitmer.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 6/7] ASoC: ti: omap-mcbsp-st: Use guard() for spin locks
Date: Fri,  8 May 2026 17:38:36 +0700	[thread overview]
Message-ID: <20260508103837.138142-7-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20260508103837.138142-1-phucduc.bui@gmail.com>

From: bui duc phuc <phucduc.bui@gmail.com>

Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/ti/omap-mcbsp-st.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
index 901578896ef3..b762d5d3e33b 100644
--- a/sound/soc/ti/omap-mcbsp-st.c
+++ b/sound/soc/ti/omap-mcbsp-st.c
@@ -156,7 +156,7 @@ static int omap_mcbsp_st_set_chgain(struct omap_mcbsp *mcbsp, int channel,
 	if (!st_data)
 		return -ENOENT;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	if (channel == 0)
 		st_data->ch0gain = chgain;
 	else if (channel == 1)
@@ -166,7 +166,6 @@ static int omap_mcbsp_st_set_chgain(struct omap_mcbsp *mcbsp, int channel,
 
 	if (st_data->enabled)
 		omap_mcbsp_st_chgain(mcbsp);
-	spin_unlock_irq(&mcbsp->lock);
 
 	return ret;
 }
@@ -180,14 +179,13 @@ static int omap_mcbsp_st_get_chgain(struct omap_mcbsp *mcbsp, int channel,
 	if (!st_data)
 		return -ENOENT;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	if (channel == 0)
 		*chgain = st_data->ch0gain;
 	else if (channel == 1)
 		*chgain = st_data->ch1gain;
 	else
 		ret = -EINVAL;
-	spin_unlock_irq(&mcbsp->lock);
 
 	return ret;
 }
@@ -199,10 +197,9 @@ static int omap_mcbsp_st_enable(struct omap_mcbsp *mcbsp)
 	if (!st_data)
 		return -ENODEV;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	st_data->enabled = 1;
 	omap_mcbsp_st_start(mcbsp);
-	spin_unlock_irq(&mcbsp->lock);
 
 	return 0;
 }
@@ -215,10 +212,9 @@ static int omap_mcbsp_st_disable(struct omap_mcbsp *mcbsp)
 	if (!st_data)
 		return -ENODEV;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	omap_mcbsp_st_stop(mcbsp);
 	st_data->enabled = 0;
-	spin_unlock_irq(&mcbsp->lock);
 
 	return ret;
 }
@@ -241,13 +237,12 @@ static ssize_t st_taps_show(struct device *dev,
 	ssize_t status = 0;
 	int i;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	for (i = 0; i < st_data->nr_taps; i++)
 		status += sysfs_emit_at(buf, status, (i ? ", %d" : "%d"),
 					st_data->taps[i]);
 	if (i)
 		status += sysfs_emit_at(buf, status, "\n");
-	spin_unlock_irq(&mcbsp->lock);
 
 	return status;
 }
@@ -260,19 +255,17 @@ static ssize_t st_taps_store(struct device *dev,
 	struct omap_mcbsp_st_data *st_data = mcbsp->st_data;
 	int val, tmp, status, i = 0;
 
-	spin_lock_irq(&mcbsp->lock);
+	guard(spinlock_irq)(&mcbsp->lock);
 	memset(st_data->taps, 0, sizeof(st_data->taps));
 	st_data->nr_taps = 0;
 
 	do {
 		status = sscanf(buf, "%d%n", &val, &tmp);
 		if (status < 0 || status == 0) {
-			size = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
 		if (val < -32768 || val > 32767) {
-			size = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
 		st_data->taps[i++] = val;
 		buf += tmp;
@@ -283,9 +276,6 @@ static ssize_t st_taps_store(struct device *dev,
 
 	st_data->nr_taps = i;
 
-out:
-	spin_unlock_irq(&mcbsp->lock);
-
 	return size;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-05-08 10:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 10:38 [PATCH 0/7] ASoC: ti: Cleanup locking code using guard() helpers phucduc.bui
2026-05-08 10:38 ` [PATCH 1/7] ASoC: ti: j721e-evm: Use guard() for mutex locks phucduc.bui
2026-05-08 10:38 ` [PATCH 2/7] ASoC: ti: omap-dmic: " phucduc.bui
2026-05-08 10:38 ` [PATCH 3/7] ASoC: ti: omap-hdmi: " phucduc.bui
2026-05-08 10:38 ` [PATCH 4/7] ASoC: ti: omap-mcpdm: " phucduc.bui
2026-05-08 10:38 ` [PATCH 5/7] ASoC: ti: ams-delta: Use guard() for spin locks phucduc.bui
2026-05-08 10:38 ` phucduc.bui [this message]
2026-05-09 12:26   ` [PATCH 6/7] ASoC: ti: omap-mcbsp-st: " Jarkko Nikula
2026-05-08 10:38 ` [PATCH 7/7] ASoC: ti: omap-mcbsp: Simplify lock and resource handling phucduc.bui
2026-05-10  1:35   ` Mark Brown
2026-05-11  4:44     ` Bui Duc Phuc
2026-05-09 12:28 ` [PATCH 0/7] ASoC: ti: Cleanup locking code using guard() helpers Jarkko Nikula
2026-05-11  0:58 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260508103837.138142-7-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jarkko.nikula@bitmer.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox