Skip to contentSkip to conversation

staging: wilc1000: Declare variables at top of function

PATCH Superseded Tamara Diaconita 1 participant 1 message Mar 10, 2017 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/7 staging: wilc1000: Declare variables at top of function

Moving declaration of some variables at top of wilc_spi_read_int function to imrpove code readability.

---
 drivers/staging/wilc1000/wilc_spi.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +8 -11
index b3c0594..887f45f 100644
@@ -929,6 +929,9 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 {
 	struct spi_device *spi = to_spi_device(wilc->dev);
 	int ret;
+	int happended, j;
+	u32 irq_flags;
+	u32 unkmown_mask;
 
 	if (g_spi.has_thrpt_enh) {
 		ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
@@ -946,12 +949,8 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 		}
 		tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
 
-		int happended, j;
-
 		j = 0;
 		do {
-			u32 irq_flags;
-
 			happended = 0;
 
 			wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
@@ -963,14 +962,12 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 				tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5));
 			}
 
-				u32 unkmown_mask;
-
-				unkmown_mask = ~((1ul << g_spi.nint) - 1);
+			unkmown_mask = ~((1ul << g_spi.nint) - 1);
 
-				if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) {
-					dev_err(&spi->dev, "Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask);
-					happended = 1;
-				}
+			if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) {
+				dev_err(&spi->dev, "Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask);
+				happended = 1;
+			}
 			j++;
 		} while (happended);
 
Signature · 1 line
2.9.3