lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250910213537.553673-1-karanja99erick@gmail.com>
Date: Thu, 11 Sep 2025 00:35:37 +0300
From: Erick Karanja <karanja99erick@...il.com>
To: ldewangan@...dia.com,
	broonie@...nel.org,
	thierry.reding@...il.com,
	jonathanh@...dia.com
Cc: linux-spi@...r.kernel.org,
	linux-tegra@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	julia.lawall@...ia.fr,
	Erick Karanja <karanja99erick@...il.com>
Subject: [PATCH] spi: Replace lock/unlock patterns to guard

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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ