cxgb4: Fine-tuning for some function implementations
Subsystems (5)
cover cxgb4: Fine-tuning for some function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 22:23:45 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (6):
Use seq_putc() in mboxlog_show()
Combine substrings for 24 messages
Adjust five checks for null pointers
Replace seven seq_puts() calls by seq_putc()
Use seq_puts() in cim_qcfg_show()
Combine substrings for two messages
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 42 +++---- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 125 ++++++++++++--------- 2 files changed, 86 insertions(+), 81 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/6 cxgb4vf: Use seq_putc() in mboxlog_show()
From: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 20:02:04 +0200
A single character (line break) should be put into a sequence. Thus use the corresponding function "seq_putc".
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +1 -1
@@ -1818,7 +1818,7 @@ static int mboxlog_show(struct seq_file *seq, void *v)seq_printf (seq," %08x %08x" , hi, lo); } -seq_puts (seq,"\n" ); +seq_putc (seq,'\n' );return 0 ; }
Signature · 1 line
2.12.2
PATCH 2/6 cxgb4vf: Combine substrings for 24 messages
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 21:00:20 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: quoted string split across lines
Thus fix the affected source code places.
--- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 113 ++++++++++++--------- 1 file changed, 64 insertions(+), 49 deletions(-)
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +64 -49
@@ -226,17 +226,20 @@ void t4vf_os_portmod_changed(struct adapter *adapter, int pidx)dev_info (adapter->pdev_dev,"%s: %s port module inserted\n" , dev->name, mod_str[pi->mod_type]); else if (pi->mod_type = FW_PORT_MOD_TYPE_NOTSUPPORTED) - dev_info(adapter->pdev_dev, "%s: unsupported optical port " - "module inserted\n", dev->name); + dev_info(adapter->pdev_dev, +"%s: unsupported optical port module inserted\n" , + dev->name); else if (pi->mod_type = FW_PORT_MOD_TYPE_UNKNOWN) - dev_info(adapter->pdev_dev, "%s: unknown port module inserted," - "forcing TWINAX\n", dev->name); + dev_info(adapter->pdev_dev, +"%s: unknown port module inserted,forcing TWINAX\n" , + dev->name); else if (pi->mod_type = FW_PORT_MOD_TYPE_ERROR) dev_info(adapter->pdev_dev, "%s: transceiver module error\n", dev->name); else - dev_info(adapter->pdev_dev, "%s: unknown module type %d " - "inserted\n", dev->name, pi->mod_type); + dev_info(adapter->pdev_dev, +"%s: unknown module type %d inserted\n" , + dev->name, pi->mod_type); }/*
@@ -2357,8 +2360,9 @@ static void size_nports_qsets(struct adapter *adapter)*/ adapter->params.nports = vfres->nvi;if (adapter->params.nports >MAX_NPORTS ) { -dev_warn (adapter->pdev_dev,"only using %d of %d maximum" -" allowed virtual interfaces\n" ,MAX_NPORTS , +dev_warn (adapter->pdev_dev, +"only using %d of %d maximum allowed virtual interfaces\n" , +MAX_NPORTS , adapter->params.nports); adapter->params.nports =MAX_NPORTS ; }
@@ -2370,9 +2374,9 @@ static void size_nports_qsets(struct adapter *adapter)*/ pmask_nports =hweight32 (adapter->params.vfres.pmask);if (pmask_nports < adapter->params.nports) { -dev_warn (adapter->pdev_dev,"only using %d of %d provisioned" -" virtual interfaces; limited by Port Access Rights" -" mask %#x\n" , pmask_nports, adapter->params.nports, +dev_warn (adapter->pdev_dev, +"only using %d of %d provisioned virtual interfaces; limited by Port Access Rights mask %#x\n" , + pmask_nports, adapter->params.nports, adapter->params.vfres.pmask); adapter->params.nports = pmask_nports; }
@@ -2403,8 +2407,8 @@ static void size_nports_qsets(struct adapter *adapter) adapter->sge.max_ethqsets = ethqsets;if (adapter->sge.max_ethqsets < adapter->params.nports) { -dev_warn (adapter->pdev_dev,"only using %d of %d available" -" virtual interfaces (too few Queue Sets)\n" , +dev_warn (adapter->pdev_dev, +"only using %d of %d available virtual interfaces (too few Queue Sets)\n" , adapter->sge.max_ethqsets, adapter->params.nports); adapter->params.nports = adapter->sge.max_ethqsets; }
@@ -2448,38 +2452,44 @@ static int adap_init0(struct adapter *adapter)*/ err =t4vf_get_dev_params (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to retrieve adapter" -" device parameters: err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to retrieve adapter device parameters: err=%d\n" , + err);return err; } err =t4vf_get_vpd_params (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to retrieve adapter" -" VPD parameters: err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to retrieve adapter VPD parameters: err=%d\n" , + err);return err; } err =t4vf_get_sge_params (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to retrieve adapter" -" SGE parameters: err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to retrieve adapter SGE parameters: err=%d\n" , + err);return err; } err =t4vf_get_rss_glb_config (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to retrieve adapter" -" RSS parameters: err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to retrieve adapter RSS parameters: err=%d\n" , + err);return err; } if (adapter->params.rss.mode ! FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL) { -dev_err (adapter->pdev_dev,"unable to operate with global RSS" -" mode %d\n" , adapter->params.rss.mode); +dev_err (adapter->pdev_dev, +"unable to operate with global RSS mode %d\n" , + adapter->params.rss.mode);return -EINVAL ; } err =t4vf_sge_init (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to use adapter parameters:" -" err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to use adapter parameters: err=%d\n" , + err);return err; }
@@ -2522,20 +2532,21 @@ static int adap_init0(struct adapter *adapter)*/ err =t4vf_get_vfres (adapter);if (err) { -dev_err (adapter->pdev_dev,"unable to get virtual interface" -" resources: err=%d\n" , err); +dev_err (adapter->pdev_dev, +"unable to get virtual interface resources: err=%d\n" , + err);return err; }/* Check for various parameter sanity issues */ if (adapter->params.vfres.pmask =0 ) { -dev_err (adapter->pdev_dev,"no port access configured\n" -"usable!\n" ); +dev_err (adapter->pdev_dev, +"no port access configured/usable!\n" );return -EINVAL ; }if (adapter->params.vfres.nvi =0 ) { -dev_err (adapter->pdev_dev,"no virtual interfaces configured/" -"usable!\n" ); +dev_err (adapter->pdev_dev, +"no virtual interfaces configured/usable!\n" );return -EINVAL ; }
@@ -2726,8 +2737,9 @@ static int enable_msix(struct adapter *adapter) nqsets = want -MSIX_EXTRAS ;if (nqsets < s->max_ethqsets) { -dev_warn (adapter->pdev_dev,"only enough MSI-X vectors" -" for %d Queue Sets\n" , nqsets); +dev_warn (adapter->pdev_dev, +"only enough MSI-X vectors for %d Queue Sets\n" , + nqsets); s->max_ethqsets = nqsets;if (nqsets < s->ethqsets)reduce_ethqs (adapter, nqsets);
@@ -2804,8 +2816,8 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,if (err =0 ) { err =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (64 ));if (err) { -dev_err (&pdev->dev,"unable to obtain 64-bit DMA for" -" coherent allocations\n" ); +dev_err (&pdev->dev, +"unable to obtain 64-bit DMA for coherent allocations\n" ); goto err_release_regions; } pci_using_dac =1 ;
@@ -2866,8 +2878,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,*/ err =t4vf_prep_adapter (adapter);if (err) { -dev_err (adapter->pdev_dev,"device didn't become ready:" -" err=%d\n" , err); +dev_err (adapter->pdev_dev, +"device didn't become ready: err=%d\n" , + err); goto err_unmap_bar0; }
@@ -2914,8 +2927,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, pmask &= ~(1 << port_id); viid =t4vf_alloc_vi (adapter, port_id);if (viid <0 ) { -dev_err (&pdev->dev,"cannot allocate VI for port %d:" -" err=%d\n" , port_id, viid); +dev_err (&pdev->dev, +"cannot allocate VI for port %d: err=%d\n" , + port_id, viid); err = viid; goto err_free_dev; }
@@ -2978,8 +2992,8 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, err =t4vf_get_vf_mac_acl (adapter, pf, &naddr, mac);if (err) {dev_err (&pdev->dev, -"unable to determine MAC ACL address, " -"continuing anyway.. (status %d)\n" , err); +"unable to determine MAC ACL address, continuing anyway.. (status %d)\n" , + err); }else if (naddr && adapter->params.vfres.nvi =1 ) {struct sockaddr addr;
@@ -3006,8 +3020,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,else {if (msi =MSI_MSIX ) {dev_info (adapter->pdev_dev, -"Unable to use MSI-X Interrupts; falling " -"back to MSI Interrupts\n" ); +"Unable to use MSI-X Interrupts; falling back to MSI Interrupts\n" );/* We're going to need a Forwarded Interrupt Queue so * that may cut into how many Queue Sets we can
@@ -3018,8 +3031,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, } err =pci_enable_msi (pdev);if (err) { -dev_err (&pdev->dev,"Unable to allocate MSI Interrupts;" -" err=%d\n" , err); +dev_err (&pdev->dev, +"Unable to allocate MSI Interrupts; err=%d\n" , + err); goto err_free_dev; } adapter->flags |=USING_MSI ;
@@ -3047,8 +3061,9 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, err =register_netdev (netdev);if (err) { -dev_warn (&pdev->dev,"cannot register net device %s," -" skipping\n" , netdev->name); +dev_warn (&pdev->dev, +"cannot register net device %s, skipping\n" , + netdev->name);continue ; }
@@ -3067,8 +3082,8 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,debugfs_create_dir (pci_name (pdev), cxgb4vf_debugfs_root);if (IS_ERR_OR_NULL (adapter->debugfs_root)) -dev_warn (&pdev->dev,"could not create debugfs" -" directory" ); +dev_warn (&pdev->dev, +"could not create debugfs directory" );else setup_debugfs (adapter); }
Signature · 1 line
2.12.2
PATCH 3/6 cxgb4vf: Adjust five checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 21:20:25 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +5 -5
@@ -491,7 +491,7 @@ static int fwevtq_handler(struct sge_rspq *rspq, const __be64 *rsp,break ; } tq = s->egr_map[eq_idx]; -if (unlikely (tq =NULL )) { +if (unlikely (!tq)) {dev_err (adapter->pdev_dev,"Egress Update QID %d TXQ=NULL\n" , qid);break ;
@@ -2939,7 +2939,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,*/ netdev =alloc_etherdev_mq (sizeof (struct port_info ),MAX_PORT_QSETS ); -if (netdev =NULL ) { +if (!netdev) {t4vf_free_vi (adapter, viid); err = -ENOMEM ; goto err_free_dev;
@@ -3053,7 +3053,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,for_each_port (adapter, pidx) {struct port_info *pi =netdev_priv (adapter->port[pidx]); netdev = adapter->port[pidx]; -if (netdev =NULL ) +if (!netdev)continue ;netif_set_real_num_tx_queues (netdev, pi->nqsets);
@@ -3120,7 +3120,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, err_free_dev:for_each_port (adapter, pidx) { netdev = adapter->port[pidx]; -if (netdev =NULL ) +if (!netdev)continue ; pi =netdev_priv (netdev);t4vf_free_vi (adapter, pi->viid);
@@ -3197,7 +3197,7 @@ static void cxgb4vf_pci_remove(struct pci_dev *pdev)struct net_device *netdev = adapter->port[pidx];struct port_info *pi; -if (netdev =NULL ) +if (!netdev)continue ; pi =netdev_priv (netdev);
Signature · 1 line
2.12.2
PATCH 4/6 cxgb4: Replace seven seq_puts() calls by seq_putc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 21:40:54 +0200
Seven 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/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 24 +++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +7 -17
@@ -278,7 +278,7 @@ static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)const u32 *p = v;if (v =SEQ_START_TOKEN ) { -seq_puts (seq,"\n" ); +seq_putc (seq,'\n' ); }else if (idx <CIM_MALA_SIZE ) {seq_printf (seq,"%02x%08x%08x%08x%08x\n" , p[4 ], p[3 ], p[2 ], p[1 ], p[0 ]);
@@ -1196,7 +1196,7 @@ static int mboxlog_show(struct seq_file *seq, void *v)seq_printf (seq," %08x %08x" , hi, lo); } -seq_puts (seq,"\n" ); +seq_putc (seq,'\n' );return 0 ; }
@@ -2112,9 +2112,7 @@ static int rss_config_show(struct seq_file *seq, void *v) HASHTOEPLITZ_F));seq_printf (seq," Udp4En: %3s\n" ,yesno (rssconf &UDPENABLE_F ));seq_printf (seq," Disable: %3s\n" ,yesno (rssconf &DISABLE_F )); - -seq_puts (seq,"\n" ); - +seq_putc (seq,'\n' ); rssconf =t4_read_reg (adapter,TP_RSS_CONFIG_TNL_A );seq_printf (seq,"TP_RSS_CONFIG_TNL: %#x\n" , rssconf);seq_printf (seq," MaskSize: %3d\n" ,MASKSIZE_G (rssconf));
@@ -2126,25 +2124,19 @@ static int rss_config_show(struct seq_file *seq, void *v) yesno(rssconf & HASHETH_F)); }seq_printf (seq," UseWireCh: %3s\n" ,yesno (rssconf &USEWIRECH_F )); - -seq_puts (seq,"\n" ); - +seq_putc (seq,'\n' ); rssconf =t4_read_reg (adapter,TP_RSS_CONFIG_OFD_A );seq_printf (seq,"TP_RSS_CONFIG_OFD: %#x\n" , rssconf);seq_printf (seq," MaskSize: %3d\n" ,MASKSIZE_G (rssconf));seq_printf (seq," RRCplMapEn: %3s\n" ,yesno (rssconf &RRCPLMAPEN_F ));seq_printf (seq," RRCplQueWidth: %3d\n" ,RRCPLQUEWIDTH_G (rssconf)); - -seq_puts (seq,"\n" ); - +seq_putc (seq,'\n' ); rssconf =t4_read_reg (adapter,TP_RSS_CONFIG_SYN_A );seq_printf (seq,"TP_RSS_CONFIG_SYN: %#x\n" , rssconf);seq_printf (seq," MaskSize: %3d\n" ,MASKSIZE_G (rssconf));seq_printf (seq," UseWireCh: %3s\n" ,yesno (rssconf &USEWIRECH_F )); - -seq_puts (seq,"\n" ); - +seq_putc (seq,'\n' ); rssconf =t4_read_reg (adapter,TP_RSS_CONFIG_VRT_A );seq_printf (seq,"TP_RSS_CONFIG_VRT: %#x\n" , rssconf);if (CHELSIO_CHIP_VERSION (adapter->params.chip) >CHELSIO_T5 ) {
@@ -2170,9 +2162,7 @@ static int rss_config_show(struct seq_file *seq, void *v)seq_printf (seq," VfWrEn: %3s\n" ,yesno (rssconf &VFWREN_F ));seq_printf (seq," KeyWrEn: %3s\n" ,yesno (rssconf &KEYWREN_F ));seq_printf (seq," KeyWrAddr: %3d\n" ,KEYWRADDR_G (rssconf)); - -seq_puts (seq,"\n" ); - +seq_putc (seq,'\n' ); rssconf =t4_read_reg (adapter,TP_RSS_CONFIG_CNG_A );seq_printf (seq,"TP_RSS_CONFIG_CNG: %#x\n" , rssconf);seq_printf (seq," ChnCount3: %3s\n" ,yesno (rssconf &CHNCOUNT3_F ));
Signature · 1 line
2.12.2
PATCH 5/6 cxgb4: Use seq_puts() in cim_qcfg_show()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 21:52:32 +0200
A string which did not contain a data format specification should be put into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +2 -3
@@ -357,9 +357,8 @@ static int cim_qcfg_show(struct seq_file *seq, void *v)return i;t4_read_cimq_cfg (adap, base, size, thres); - -seq_printf (seq, -" Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n" ); +seq_puts (seq, +" Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n" );for (i =0 ; i <CIM_NUM_IBQ ; i++, p +=4 ) seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n", qname[i], base[i], size[i], thres[i],
Signature · 1 line
2.12.2
PATCH 6/6 cxgb4: Combine substrings for two messages
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 22:16:57 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: quoted string split across lines
Thus fix two source code places.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +7 -6
@@ -1353,8 +1353,9 @@ static int mps_trc_show(struct seq_file *seq, void *v)if (tp.port <8 ) { i = adap->chan_map[tp.port &3 ];if (i >=MAX_NPORTS ) { -dev_err (adap->pdev_dev,"tracer %u is assigned " -"to non-existing port\n" , trcidx); +dev_err (adap->pdev_dev, +"tracer %u is assigned to non-existing port\n" , + trcidx);return -EINVAL ; } seq_printf(seq, "tracer is capturing %s %s, ",
@@ -1798,11 +1799,11 @@ static int mps_tcam_show(struct seq_file *seq, void *v) FW_LDST_CMD_IDX_V(idx)); ret =t4_wr_mbox (adap, adap->mbox, &ldst_cmd,sizeof (ldst_cmd), &ldst_cmd); -if (ret) -dev_warn (adap->pdev_dev,"Can't read MPS " -"replication map for idx %d: %d\n" , +if (ret) { +dev_warn (adap->pdev_dev, +"Can't read MPS replication map for idx %d: %d\n" , idx, -ret); -else { + }else { mps_rplc = ldst_cmd.u.mps.rplc; rplc[0 ] =ntohl (mps_rplc.rplc31_0); rplc[1 ] =ntohl (mps_rplc.rplc63_32);
Signature · 1 line
2.12.2
From: SF Markus Elfring <[email protected]>
Sent: Friday, May 5, 2017 2:00 AM
To: [email protected]; Casey Leedom; Ganesh GR
Cc: LKML; [email protected]
Subject: [PATCH 0/6] cxgb4: Fine-tuning for some function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 4 May 2017 22:23:45 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (6):
Use seq_putc() in mboxlog_show()
Combine substrings for 24 messages
Adjust five checks for null pointers
Replace seven seq_puts() calls by seq_putc()
Use seq_puts() in cim_qcfg_show()
Combine substrings for two messages
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 42 +++---- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 125 ++++++++++++---------
2 files changed, 86 insertions(+), 81 deletions(-)
Signature · 6 lines
2.12.2
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html