Skip to contentSkip to conversation

staging: wilc1000: correct inconsistent indenting

PATCH Superseded Michael Straube 2 participants 3 messages Nov 28, 2018 – Nov 29, 2018 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wilc1000: correct inconsistent indenting

Correct inconsistent indenting reported by smatch.

---
 drivers/staging/wilc1000/wilc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_spi.c +1 -1
index 35ff432587fe..6d1eb82d1df8 100644
@@ -963,7 +963,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 			dev_err(&spi->dev,
 				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
 				j, tmp, unknown_mask);
-				happened = 1;
+			happened = 1;
 		}
 
 		j++;
Signature · 1 line
2.19.2
#1 lore raw
Quoted 1 line · Michael Straube

Correct inconsistent indenting reported by smatch.

[]

drivers/staging/wilc1000/wilc_spi.c

Quoted 1 line
drivers/staging/wilc1000/wilc_spi.c +0 -0

[]

drivers/staging/wilc1000/wilc_spi.c static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) · line 969

Quoted 9 lines
drivers/staging/wilc1000/wilc_spi.c +1 -1
@@ -963,7 +963,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 			dev_err(&spi->dev,
 				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
 				j, tmp, unknown_mask);
-				happened = 1;
+			happened = 1;s a
 		}
 
 		j++;

Perhaps a little refactoring instead

---
 drivers/staging/wilc1000/wilc_spi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +5 -7
index 35ff432587fe..a38ddb1f0a1f 100644
@@ -927,7 +927,8 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 	int ret;
 	u32 tmp;
 	u32 byte_cnt;
-	int happened, j;
+	bool unexpected_irq;
+	int j;
 	u32 unknown_mask;
 	u32 irq_flags;
 	int k = IRG_FLAGS_OFFSET + 5;
@@ -947,8 +948,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 
 	j = 0;
 	do {
-		happened = 0;
-
 		wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
 		tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
 
@@ -959,15 +958,14 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 
 		unknown_mask = ~((1ul << spi_priv->nint) - 1);
 
-		if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) {
+		unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask;
+		if (unexpected_irq)
 			dev_err(&spi->dev,
 				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
 				j, tmp, unknown_mask);
-				happened = 1;
-		}
 
 		j++;
-	} while (happened);
+	} while (unexpected_irq);
 
 	*int_status = tmp;
 
#2 lore raw
Quoted 53 lines · Joe Perches
Quoted 1 line · Michael Straube

Correct inconsistent indenting reported by smatch.

[]

drivers/staging/wilc1000/wilc_spi.c

Quoted 1 line
drivers/staging/wilc1000/wilc_spi.c +0 -0

[]

drivers/staging/wilc1000/wilc_spi.c static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) · line 969

Quoted 9 lines
drivers/staging/wilc1000/wilc_spi.c +1 -1
@@ -963,7 +963,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
  			dev_err(&spi->dev,
  				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",
  				j, tmp, unknown_mask);
-				happened = 1;
+			happened = 1;s a
  		}
 
  		j++;

Perhaps a little refactoring instead

---
  drivers/staging/wilc1000/wilc_spi.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +4 -4
index 35ff432587fe..a38ddb1f0a1f 100644
@@ -927,7 +927,8 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
  	int ret;
  	u32 tmp;
  	u32 byte_cnt;
-	int happened, j;
+	bool unexpected_irq;
+	int j;
  	u32 unknown_mask;
  	u32 irq_flags;
  	int k = IRG_FLAGS_OFFSET + 5;
@@ -947,8 +948,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 
  	j = 0;
  	do {
-		happened = 0;
-
  		wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
  		tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
 
@@ -959,15 +958,14 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 
  		unknown_mask = ~((1ul << spi_priv->nint) - 1);
 
-		if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) {
+		unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask;
+		if (unexpected_irq)
  			dev_err(&spi->dev,
  				"Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n",

drivers/staging/wilc1000/wilc_spi.c static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) · line 971

Quoted 10 lines
drivers/staging/wilc1000/wilc_spi.c +1 -3
  				j, tmp, unknown_mask);
-				happened = 1;
-		}
 
  		j++;
-	} while (happened);
+	} while (unexpected_irq);
 
  	*int_status = tmp;
 

Hi Joe,

that looks good to me.
Naming the loop condition unexpected_irq also improves readability.

I will send a new patch, thanks.
Michael