ath9k: Fine-tuning for some function implementations
cover ath9k: Fine-tuning for some function implementations
From: Markus Elfring <[email protected]>
Date: Tue, 9 May 2017 09:19:09 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Reduce function calls for sequence output in read_file_dma() Replace four seq_printf() calls by seq_putc() Adjust a null pointer check in three functions
drivers/net/wireless/ath/ath9k/debug.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/3 ath9k: Reduce function calls for sequence output in read_file_dma()
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 21:55:09 +0200
Some data were put into a sequence by separate function calls. Print the same data with two function calls less.
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/ath/ath9k/debug.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +3 -6
@@ -427,9 +427,7 @@ static int read_file_dma(struct seq_file *file, void *data)seq_printf (file,"%d: %08x " , i, val[i]); } -seq_puts (file,"\n\n" ); -seq_puts (file,"Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n" ); - +seq_puts (file,"\n\nNum QCU: chain_st fsp_ok fsp_st DCU: chain_st\n" );for (i =0 ; i <ATH9K_NUM_QUEUES ; i++, qcuOffset +=4 , dcuOffset +=5 ) {if (i =8 ) { qcuOffset =0 ;
@@ -448,9 +446,8 @@ static int read_file_dma(struct seq_file *file, void *data) (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); } -seq_puts (file,"\n" ); - -seq_printf (file,"qcu_stitch state: %2x qcu_fetch state: %2x\n" , +seq_printf (file, +"\nqcu_stitch state: %2x qcu_fetch state: %2x\n" , (val[3 ] &0x003c0000 ) >>18 , (val[3 ] &0x03c00000 ) >>22 );seq_printf (file,"qcu_complete state: %2x dcu_complete state: %2x\n" , (val[3 ] &0x1c000000 ) >>26 , (val[6 ] &0x3 ));
Signature · 1 line
2.12.2
PATCH 2/3 ath9k: Replace four seq_printf() calls by seq_putc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 22:04:47 +0200
Four single characters (line breaks) should be put into a sequence. Thus use the corresponding function "seq_putc".
This issue was detected by using the Coccinelle software.
--- drivers/net/wireless/ath/ath9k/debug.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +4 -6
@@ -421,7 +421,7 @@ static int read_file_dma(struct seq_file *file, void *data)for (i =0 ; i <ATH9K_NUM_DMA_DEBUG_REGS ; i++) { if (i % 4 = 0) -seq_puts (file,"\n" ); +seq_putc (file,'\n' ); val[i] =REG_READ_D (ah,AR_DMADBG_0 + (i *sizeof (u32)));seq_printf (file,"%d: %08x " , i, val[i]);
@@ -702,8 +702,7 @@ static int read_file_misc(struct seq_file *file, void *data)if (rxfilter &ATH9K_RX_FILTER_CONTROL_WRAPPER )seq_puts (file," CONTROL_WRAPPER" ); -seq_puts (file,"\n" ); - +seq_putc (file,'\n' ); reg = sc->sc_ah->imask;seq_printf (file,"INTERRUPT-MASK: 0x%x" , reg);
@@ -723,8 +722,7 @@ static int read_file_misc(struct seq_file *file, void *data)if (reg &ATH9K_INT_BB_WATCHDOG )seq_puts (file," BB_WATCHDOG" ); -seq_puts (file,"\n" ); - +seq_putc (file,'\n' ); i =0 ;ath_for_each_chanctx (sc, ctx) {if (list_empty (&ctx->vifs))
@@ -981,7 +979,7 @@ static int read_file_dump_nfcal(struct seq_file *file, void *data)seq_printf (file," %d\t %d\t %d\t\t" , i, h[i].privNF, nread);for (j =0 ; j < nread; j++)seq_printf (file," %d" , h[i].nfCalBuffer[j]); -seq_puts (file,"\n" ); +seq_putc (file,'\n' ); }return 0 ;
Signature · 1 line
2.12.2
PATCH 3/3 ath9k: Adjust a null pointer check in three functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 22:17:13 +0200
The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!buf"
Thus adjust this expression.
--- drivers/net/wireless/ath/ath9k/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +3 -3
@@ -161,7 +161,7 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf, }; buf =kzalloc (size,GFP_KERNEL ); -if (buf =NULL ) +if (!buf)return -ENOMEM ; len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI",
@@ -315,7 +315,7 @@ static ssize_t read_file_antenna_diversity(struct file *file, }; buf =kzalloc (size,GFP_KERNEL ); -if (buf =NULL ) +if (!buf)return -ENOMEM ;if (!(pCap->hw_caps &ATH9K_HW_CAP_ANT_DIV_COMB )) {
@@ -1008,7 +1008,7 @@ static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,size_t retval; buf =kzalloc (size,GFP_KERNEL ); -if (buf =NULL ) +if (!buf)return -ENOMEM ;if (!sc->sc_ah->common.btcoex_enabled) {
Signature · 1 line
2.12.2