* [PATCH] spi: Replace lock/unlock patterns to guard
@ 2025-09-10 21:35 Erick Karanja
2025-09-10 21:59 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Erick Karanja @ 2025-09-10 21:35 UTC (permalink / raw)
To: ldewangan, broonie, thierry.reding, jonathanh
Cc: linux-spi, linux-tegra, linux-kernel, julia.lawall, Erick Karanja
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] spi: Replace lock/unlock patterns to guard
2025-09-10 21:35 [PATCH] spi: Replace lock/unlock patterns to guard Erick Karanja
@ 2025-09-10 21:59 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2025-09-10 21:59 UTC (permalink / raw)
To: Erick Karanja
Cc: ldewangan, thierry.reding, jonathanh, linux-spi, linux-tegra,
linux-kernel, julia.lawall
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
On Thu, Sep 11, 2025 at 12:35:37AM +0300, Erick Karanja wrote:
> Replace lock/unlock pattern with guard cleanup macro.
> This simplifies the code flow path by replacing the conditional
> jump with an early return.
Seriously, please fix your subject lines to follow the style for the
subsystem and distinguish between the patches.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-10 21:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10 21:35 [PATCH] spi: Replace lock/unlock patterns to guard Erick Karanja
2025-09-10 21:59 ` Mark Brown
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®