Improve code readability
v2 cover Improve code readability
Improve code readability in wilc_spi_read_int dunction in wilc_spi.c
Tamara Diaconita (3):
staging: wilc1000: Declare variables at top of function
staging: wilc1000: Correct name of variables
staging: wilc1000: Remove unnecessary brackets
drivers/staging/wilc1000/wilc_spi.c | 52 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 30 deletions(-)
Signature · 3 lines
Changes since v1: *Change the patches order. 2.9.3
PATCH v2 1/3 staging: wilc1000: Declare variables at top of function
Moving declaration of some variables at top of wilc_spi_read_int function to improve code readability.
--- drivers/staging/wilc1000/wilc_spi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +3 -6
@@ -937,6 +937,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,
@@ -955,12 +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; wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
@@ -973,8 +972,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
PATCH v2 2/3 staging: wilc1000: Correct name of variables
In reply to Tamara DiaconitaCorrect misspelled variables:
'unkmown_mask' to 'unknown_mask' and 'happended' to 'happened' to improve code readability.
--- drivers/staging/wilc1000/wilc_spi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +10 -11
@@ -937,17 +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; -int happended, j; +int happened, j;u32 irq_flags; -u32 unkmown_mask; +u32 unknown_mask; +u32 tmp; +u32 byte_cnt;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) {
@@ -960,7 +959,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);
@@ -972,15 +971,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 v2 3/3 staging: wilc1000: Remove unnecessary brackets
In reply to Tamara DiaconitaImproved code readability by removing unnecessary brackets and deleted tabs to indent.
--- drivers/staging/wilc1000/wilc_spi.c | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-)
drivers/staging/wilc1000/wilc_spi.c +17 -21
@@ -956,31 +956,27 @@ 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