staging: wilc1000: Improve code readability
v2 cover staging: wilc1000: 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 · 5 lines
I am going to wait to see these patches in the staging tree, then resend additional patches for this driver. 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
Re: [Outreachy kernel] [PATCH v2 1/3] staging: wilc1000: Declare variables at top of function
Quoted 2 lines · Tamara Diaconita
Moving declaration of some variables at top of
wilc_spi_read_intfunction to improve code readability.
Imperative: "Move declaration..."
and "to top of ..."
Quoted 51 lines
Signed-off-by Tamara Diaconita <[email protected]>--- 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 · 8 lines
2.9.3 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-2-diaconita.tamara%40gmail.com. For more options, visit https://groups.google.com/d/optout.
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
Re: [Outreachy kernel] [PATCH v2 2/3] staging: wilc1000: Correct name of variables
Quoted 14 lines · Tamara Diaconita
Correct misspelled variables:
'unkmown_mask' to 'unknown_mask' and 'happended' to 'happened' to improve code readability.Signed-off-by Tamara Diaconita <[email protected]>--- drivers/staging/wilc1000/wilc_spi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)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 944
Quoted 10 lines
drivers/staging/wilc1000/wilc_spi.c +4
-2@@ -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;
This is doing things other than fixing the spelling mistakes.
julia
Quoted 51 lines
drivers/staging/wilc1000/wilc_spi.c +6
-10if (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; --2.9.3
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-3-diaconita.tamara%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
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
Re: [Outreachy kernel] [PATCH v2 3/3] staging: wilc1000: Remove unnecessary brackets
Quoted 2 lines · Tamara Diaconita
Improved code readability by removing unnecessary brackets and deleted tabs to indent.
Tamara, I'm not so sure about the 'deleted tabs to indent' phrase.
Remove unnecessary brackets to properly indent code. The code is now more readable.
Quoted 68 lines
Signed-off-by Tamara Diaconita <[email protected]>--- 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 · 8 lines
2.9.3 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-4-diaconita.tamara%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] [PATCH v2 3/3] staging: wilc1000: Remove unnecessary brackets
Quoted 8 lines · Alison Schofield
Quoted 2 lines · Tamara Diaconita
Improved code readability by removing unnecessary brackets and deleted tabs to indent.
Tamara, I'm not so sure about the 'deleted tabs to indent' phrase.
Remove unnecessary brackets to properly indent code. The code is now more readable.
Actually, "Remove unnecessary brackets to properly indent code." doesn't work for me, since the removing doesn't itself affect the indentation. Remove unnecessary brackets and correspondingly unindent code might be clearer.
julia
Quoted 77 lines
Quoted 63 lines
Signed-off-by Tamara Diaconita <[email protected]>--- drivers/staging/wilc1000/wilc_spi.c | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-)drivers/staging/wilc1000/wilc_spi.c +17
-22@@ -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; } --2.9.3
Quoted 6 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-4-diaconita.tamara%40gmail.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312235113.GC14759%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.
Quoted 1 line · Tamara Diaconita
Improve code readability in
wilc_spi_read_intdunction inwilc_spi.c
spelling dunction ->function, or write it wilc_spi_read_int()
You don't need to say file name. Reviewer sees it a few lines later in the diffstat.
Quoted 22 lines
Tamara Diaconita (3):
staging: wilc1000: Declare variables at top of function
staging: wilc1000: Correct name of variables
staging: wilc1000: Remove unnecessary bracketsdrivers/staging/wilc1000/wilc_spi.c | 52 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 30 deletions(-)Signature · 12 lines
I am going to wait to see these patches in the staging tree, then resend additional patches for this driver. Changes since v1: *Change the patches order. 2.9.3 -- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-1-diaconita.tamara%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Quoted 7 lines · Alison Schofield
Quoted 1 line · Tamara Diaconita
Improve code readability in
wilc_spi_read_intdunction inwilc_spi.cspelling dunction ->function, or write it
wilc_spi_read_int()You don't need to say file name. Reviewer sees it a few lines later in the diffstat.
Probably even the function name is not necessary.
julia
Quoted 31 lines
Quoted 17 lines
Tamara Diaconita (3):
staging: wilc1000: Declare variables at top of function
staging: wilc1000: Correct name of variables
staging: wilc1000: Remove unnecessary bracketsdrivers/staging/wilc1000/wilc_spi.c | 52 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 30 deletions(-)--
I am going to wait to see these patches in the staging tree, then resend additional patches for this driver.Changes since v1:
*Change the patches order.
2.9.3Quoted 6 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312211518.3172-1-diaconita.tamara%40gmail.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170312234135.GA14759%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.