[PATCH] spi: pl022: Reduce scope for the variable “previous” in pump_transfers()

Markus Elfring Markus.Elfring at web.de
Thu Dec 10 10:40:20 EST 2020


From: Markus Elfring <elfring at users.sourceforge.net>
Date: Thu, 10 Dec 2020 16:31:00 +0100

A local variable was used only within an if branch.
Thus move the definition for the variable “previous” into
the corresponding code block.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
 drivers/spi/spi-pl022.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index d1776fea287e..469d8e8b286c 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1381,7 +1381,6 @@ static void pump_transfers(unsigned long data)
 	struct pl022 *pl022 = (struct pl022 *) data;
 	struct spi_message *message = NULL;
 	struct spi_transfer *transfer = NULL;
-	struct spi_transfer *previous = NULL;

 	/* Get current state information */
 	message = pl022->cur_msg;
@@ -1403,9 +1402,9 @@ static void pump_transfers(unsigned long data)

 	/* Delay if requested at end of transfer before CS change */
 	if (message->state == STATE_RUNNING) {
-		previous = list_entry(transfer->transfer_list.prev,
-					struct spi_transfer,
-					transfer_list);
+		struct spi_transfer *previous = list_entry(transfer->transfer_list.prev,
+							   struct spi_transfer,
+							   transfer_list);
 		/*
 		 * FIXME: This runs in interrupt context.
 		 * Is this really smart?
--
2.29.2




More information about the linux-arm-kernel mailing list