From: Erick Karanja <karanja99erick@gmail.com>
To: ldewangan@nvidia.com, broonie@kernel.org,
thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: linux-spi@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, julia.lawall@inria.fr,
Erick Karanja <karanja99erick@gmail.com>
Subject: [PATCH] spi: Replace lock/unlock patterns to guard
Date: Thu, 11 Sep 2025 00:35:37 +0300 [thread overview]
Message-ID: <20250910213537.553673-1-karanja99erick@gmail.com> (raw)
Replace lock/unlock pattern with guard cleanup macro.
This simplifies the code flow path by replacing the conditional
jump with an early return.
Generated-by: Coccinelle SmPL
Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
drivers/spi/spi-tegra20-sflash.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index d5c8ee20b8e5..5367aee56545 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -359,7 +359,7 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_sflash_data *tsd)
{
struct spi_transfer *t = tsd->curr_xfer;
- spin_lock(&tsd->lock);
+ guard(spinlock)(&tsd->lock);
if (tsd->tx_status || tsd->rx_status || (tsd->status_reg & SPI_BSY)) {
dev_err(tsd->dev,
"CpuXfer ERROR bit set 0x%x\n", tsd->status_reg);
@@ -370,7 +370,7 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_sflash_data *tsd)
udelay(2);
reset_control_deassert(tsd->rst);
complete(&tsd->xfer_completion);
- goto exit;
+ return IRQ_HANDLED;
}
if (tsd->cur_direction & DATA_DIR_RX)
@@ -383,13 +383,11 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_sflash_data *tsd)
if (tsd->cur_pos == t->len) {
complete(&tsd->xfer_completion);
- goto exit;
+ return IRQ_HANDLED;
}
tegra_sflash_calculate_curr_xfer_param(tsd->cur_spi, tsd, t);
tegra_sflash_start_cpu_based_transfer(tsd, t);
-exit:
- spin_unlock(&tsd->lock);
return IRQ_HANDLED;
}
--
2.43.0
next reply other threads:[~2025-09-10 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 21:35 Erick Karanja [this message]
2025-09-10 21:59 ` 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=20250910213537.553673-1-karanja99erick@gmail.com \
--to=karanja99erick@gmail.com \
--cc=broonie@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=julia.lawall@inria.fr \
--cc=ldewangan@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.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
all inboxes | Powered by JetHome®