staging: wilc1000: Improve code readability
v4 cover staging: wilc1000: Improve code readability
Improve code readability in wilc_spi_read_int function in wilc_spi.c file.
Tamara Diaconita (3):
staging: wilc1000: Declare variables to top of function
staging: wilc1000: Correct name of variables
staging: wilc1000: Remove unnecessary brackets
drivers/staging/wilc1000/wilc_spi.c | 51 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
--
I am going to wait to see these patches in the staging tree, then resend additional patches for this driver.
Changes since v2:
*Add driver name in the subject of the function.
Changes since v1:
*Change the patches order.
2.9.3
PATCH v4 1/3 staging: wilc1000: Declare variables to top of function
Move declaration of variables to top of function to make the code more readable.
---
Changes since v3:
*Removed the correction of 'unkmown_mask' from the patch.
Changes since v2:
*Correct error of expression: from 'at top of function' to 'to top of function'.
*Change tense to imperative: from 'moving declaration' to 'move declaration'.
drivers/staging/wilc1000/wilc_spi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +5 -9
@@ -935,14 +935,16 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) {struct spi_device *spi =to_spi_device (wilc->dev);int ret; +u32 tmp; +u32 byte_cnt; +int happended, j; +u32 unknown_mask; +u32 irq_flags;if (g_spi.has_thrpt_enh) { ret =spi_internal_read (wilc,0xe840 -WILC_SPI_REG_BASE , int_status); }else { -u32 tmp; -u32 byte_cnt; - ret =wilc_spi_read_reg (wilc,WILC_VMM_TO_HOST_SIZE , &byte_cnt);if (!ret) {
@@ -953,12 +955,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);
@@ -971,8 +969,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) } { -u32 unknown_mask; - unknown_mask = ~((1ul << g_spi.nint) -1 );if ((tmp >>IRG_FLAGS_OFFSET ) & unknown_mask) {
Signature · 1 line
2.9.3
PATCH v4 2/3 staging: wilc1000: Correct name of variables
In reply to Tamara DiaconitaCorrect misspelled variables: 'happended' to 'happened' to make the code grammatically correct.
--- drivers/staging/wilc1000/wilc_spi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +4 -4
@@ -937,7 +937,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)int ret;u32 tmp;u32 byte_cnt; -int happended, j; +int happened, j;u32 unknown_mask;u32 irq_flags;
@@ -957,7 +957,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) { j =0 ; do { - happended = 0; + happened = 0; wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
@@ -973,11 +973,11 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)if ((tmp >>IRG_FLAGS_OFFSET ) & unknown_mask) {dev_err (&spi->dev,"Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n" , j, tmp, unknown_mask); - happended =1 ; + happened =1 ; } } j++; - }while (happended); + }while (happened); } *int_status = tmp;
Signature · 1 line
2.9.3
PATCH v4 3/3 staging: wilc1000: Remove unnecessary brackets
In reply to Tamara DiaconitaRemove unnecessary brackets and correspondingly unindent code.
---
Changes since v2:
*Change the description of the patch.
drivers/staging/wilc1000/wilc_spi.c | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +18 -21
@@ -954,31 +954,28 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) } tmp = (byte_cnt >>2 ) &IRQ_DMA_WD_CNT_MASK ; - { - j =0 ; -do { - happened =0 ; + j =0 ; +do { + happened =0 ; -wilc_spi_read_reg (wilc,0x1a90 , &irq_flags); - tmp |= ((irq_flags >>27 ) <<IRG_FLAGS_OFFSET ); +wilc_spi_read_reg (wilc,0x1a90 , &irq_flags); + tmp |= ((irq_flags >>27 ) <<IRG_FLAGS_OFFSET ); -if (g_spi.nint >5 ) { -wilc_spi_read_reg (wilc,0x1a94 , - &irq_flags); - tmp |= (((irq_flags >>0 ) &0x7 ) << (IRG_FLAGS_OFFSET +5 )); - } +if (g_spi.nint >5 ) { +wilc_spi_read_reg (wilc,0x1a94 , + &irq_flags); + tmp |= (((irq_flags >>0 ) &0x7 ) << (IRG_FLAGS_OFFSET +5 )); + } - { - unknown_mask = ~((1ul << g_spi.nint) -1 ); + unknown_mask = ~((1ul << g_spi.nint) -1 ); -if ((tmp >>IRG_FLAGS_OFFSET ) & unknown_mask) { -dev_err (&spi->dev,"Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n" , j, tmp, unknown_mask); - happened =1 ; - } - } - j++; - }while (happened); - } +if ((tmp >>IRG_FLAGS_OFFSET ) & unknown_mask) { +dev_err (&spi->dev,"Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n" , j, tmp, unknown_mask); + happened =1 ; + } + + j++; + }while (happened); *int_status = tmp; }
Signature · 1 line
2.9.3