staging: wilc1000: Improve code readability
v3 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 | 50 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 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 cover letter.
Changes since v1:
**Change the patches order.
2.9.3
PATCH v3 1/3 staging: wilc1000: Declare variables to top of
Move declaration of variables to top of function to improve code readability.
---
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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +5 -7
@@ -937,13 +937,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 irq_flags; +u32 unkmown_mask;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);
@@ -955,11 +958,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;
@@ -973,8 +973,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) } { -u32 unkmown_mask; - unkmown_mask = ~((1ul << g_spi.nint) -1 );if ((tmp >>IRG_FLAGS_OFFSET ) & unkmown_mask) {
Signature · 1 line
2.9.3
Greg KH
maintainerRe: [PATCH v3 1/3] staging: wilc1000: Declare variables to top of
Quoted 11 lines · Tamara Diaconita
Move declaration of variables to top of function to improve code readability.
Signed-off-by Tamara Diaconita <[email protected]>---
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'.
Quoted 2 lines
drivers/staging/wilc1000/wilc_spi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
This patch does not apply to my staging-testing branch at all. Can you please rebase all of these and resend them?
thanks,
greg k-h
PATCH v3 2/3 staging: wilc1000: Correct name of variables
In reply to Tamara DiaconitaCorrect misspelled variables:
'unkmown_mask' to 'unknown_mask' and
'happended' to happened.
--- drivers/staging/wilc1000/wilc_spi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +8 -8
@@ -939,9 +939,9 @@ 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 irq_flags; -u32 unkmown_mask; +u32 unknown_mask;if (g_spi.has_thrpt_enh) { ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
@@ -961,7 +961,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,15 +973,15 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) } { - unkmown_mask = ~((1ul << g_spi.nint) -1 ); + unknown_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 ) & unknown_mask) { +dev_err (&spi->dev,"Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n" , j, tmp, unknown_mask); + happened =1 ; } } j++; - }while (happended); + }while (happened); } *int_status = tmp;
Signature · 1 line
2.9.3
PATCH v3 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 | 40 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +18 -22
@@ -957,32 +957,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 ; - -wilc_spi_read_reg (wilc,0x1a90 , &irq_flags); - tmp |= ((irq_flags >>27 ) <<IRG_FLAGS_OFFSET ); + j =0 ; +do { + happened =0 ; + +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 , +if (g_spi.nint >5 ) { +wilc_spi_read_reg (wilc,0x1a94 , &irq_flags); - tmp |= (((irq_flags >>0 ) &0x7 ) << (IRG_FLAGS_OFFSET +5 )); - } + 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