mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Erick Karanja <karanja99erick@gmail.com>
To: broonie@kernel.org
Cc: julia.lawall@inria.fr, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Erick Karanja <karanja99erick@gmail.com>
Subject: [PATCH] spi: Replace lock/unlock patterns to use guard
Date: Wed, 10 Sep 2025 22:59:49 +0300	[thread overview]
Message-ID: <20250910195949.273553-1-karanja99erick@gmail.com> (raw)

Replace lock/unlock patterns with scoped based cleanup
macro.This simplifies the code control flow.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/spi/spi-fsl-espi.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index f2f1d3298e6c..eae0fac911de 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -379,9 +379,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
 	fsl_espi_write_reg(espi, ESPI_SPIM, mask);
 
 	/* Prevent filling the fifo from getting interrupted */
-	spin_lock_irq(&espi->lock);
-	fsl_espi_fill_tx_fifo(espi, 0);
-	spin_unlock_irq(&espi->lock);
+	scoped_guard (spinlock_irq, &espi->lock)
+		fsl_espi_fill_tx_fifo(espi, 0);
 
 	/* Won't hang up forever, SPI bus sometimes got lost interrupts... */
 	ret = wait_for_completion_timeout(&espi->done, 2 * HZ);
@@ -558,15 +557,13 @@ static irqreturn_t fsl_espi_irq(s32 irq, void *context_data)
 	struct fsl_espi *espi = context_data;
 	u32 events, mask;
 
-	spin_lock(&espi->lock);
+	guard(spinlock)(&espi->lock);
 
 	/* Get interrupt events(tx/rx) */
 	events = fsl_espi_read_reg(espi, ESPI_SPIE);
 	mask = fsl_espi_read_reg(espi, ESPI_SPIM);
-	if (!(events & mask)) {
-		spin_unlock(&espi->lock);
+	if (!(events & mask))
 		return IRQ_NONE;
-	}
 
 	dev_vdbg(espi->dev, "%s: events %x\n", __func__, events);
 
@@ -575,8 +572,6 @@ static irqreturn_t fsl_espi_irq(s32 irq, void *context_data)
 	/* Clear the events */
 	fsl_espi_write_reg(espi, ESPI_SPIE, events);
 
-	spin_unlock(&espi->lock);
-
 	return IRQ_HANDLED;
 }
 
-- 
2.43.0


                 reply	other threads:[~2025-09-10 19:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250910195949.273553-1-karanja99erick@gmail.com \
    --to=karanja99erick@gmail.com \
    --cc=broonie@kernel.org \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®