Skip to content

Commit 2ea259e

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: minor code cleanups
This contains code cleanups that were in the prior patch set. This allows better review of real changes later. minor code cleanups: fix indentation, punctuation, line length addition/reduction of whitespace remove unneeded parens, braces lpfc_debugfs_nodelist_data: print as u64 rather than byte by byte covert printk(KERN_ERR to pr_err small print string deltas use num_present_cpus() rather than count them comment updates rctl/type names moved to module variable, not on stack Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <james.smart@broadcom.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 45ffac1 commit 2ea259e

File tree

10 files changed

+98
-89
lines changed

10 files changed

+98
-89
lines changed

drivers/scsi/lpfc/lpfc_attr.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
#include "lpfc_vport.h"
5151
#include "lpfc_attr.h"
5252

53-
#define LPFC_DEF_DEVLOSS_TMO 30
54-
#define LPFC_MIN_DEVLOSS_TMO 1
55-
#define LPFC_MAX_DEVLOSS_TMO 255
53+
#define LPFC_DEF_DEVLOSS_TMO 30
54+
#define LPFC_MIN_DEVLOSS_TMO 1
55+
#define LPFC_MAX_DEVLOSS_TMO 255
5656

5757
/*
5858
* Write key size should be multiple of 4. If write key is changed
@@ -5769,10 +5769,12 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
57695769
lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel);
57705770
lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
57715771
lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
5772+
57725773
lpfc_EnableXLane_init(phba, lpfc_EnableXLane);
57735774
if (phba->sli_rev != LPFC_SLI_REV4)
57745775
phba->cfg_EnableXLane = 0;
57755776
lpfc_XLanePriority_init(phba, lpfc_XLanePriority);
5777+
57765778
memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t)));
57775779
memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t)));
57785780
phba->cfg_oas_lun_state = 0;

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
27032703
* lpfc_bsg_dma_page_alloc - allocate a bsg mbox page sized dma buffers
27042704
* @phba: Pointer to HBA context object
27052705
*
2706-
* This function allocates BSG_MBOX_SIZE (4KB) page size dma buffer and.
2706+
* This function allocates BSG_MBOX_SIZE (4KB) page size dma buffer and
27072707
* returns the pointer to the buffer.
27082708
**/
27092709
static struct lpfc_dmabuf *

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
531531
int cnt;
532532
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
533533
struct lpfc_nodelist *ndlp;
534-
unsigned char *statep, *name;
534+
unsigned char *statep;
535535

536536
cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
537537

@@ -574,45 +574,43 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
574574
default:
575575
statep = "UNKNOWN";
576576
}
577-
len += snprintf(buf+len, size-len, "%s DID:x%06x ",
578-
statep, ndlp->nlp_DID);
579-
name = (unsigned char *)&ndlp->nlp_portname;
580-
len += snprintf(buf+len, size-len,
581-
"WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
582-
*name, *(name+1), *(name+2), *(name+3),
583-
*(name+4), *(name+5), *(name+6), *(name+7));
584-
name = (unsigned char *)&ndlp->nlp_nodename;
585-
len += snprintf(buf+len, size-len,
586-
"WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
587-
*name, *(name+1), *(name+2), *(name+3),
588-
*(name+4), *(name+5), *(name+6), *(name+7));
577+
len += snprintf(buf+len, size-len, "%s DID:x%06x ",
578+
statep, ndlp->nlp_DID);
579+
len += snprintf(buf+len, size-len,
580+
"WWPN x%llx ",
581+
wwn_to_u64(ndlp->nlp_portname.u.wwn));
582+
len += snprintf(buf+len, size-len,
583+
"WWNN x%llx ",
584+
wwn_to_u64(ndlp->nlp_nodename.u.wwn));
589585
if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
590-
len += snprintf(buf+len, size-len, "RPI:%03d ",
591-
ndlp->nlp_rpi);
586+
len += snprintf(buf+len, size-len, "RPI:%03d ",
587+
ndlp->nlp_rpi);
592588
else
593-
len += snprintf(buf+len, size-len, "RPI:none ");
589+
len += snprintf(buf+len, size-len, "RPI:none ");
594590
len += snprintf(buf+len, size-len, "flag:x%08x ",
595591
ndlp->nlp_flag);
596592
if (!ndlp->nlp_type)
597-
len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
593+
len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
598594
if (ndlp->nlp_type & NLP_FC_NODE)
599-
len += snprintf(buf+len, size-len, "FC_NODE ");
595+
len += snprintf(buf+len, size-len, "FC_NODE ");
600596
if (ndlp->nlp_type & NLP_FABRIC)
601-
len += snprintf(buf+len, size-len, "FABRIC ");
597+
len += snprintf(buf+len, size-len, "FABRIC ");
602598
if (ndlp->nlp_type & NLP_FCP_TARGET)
603-
len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
599+
len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
604600
ndlp->nlp_sid);
605601
if (ndlp->nlp_type & NLP_FCP_INITIATOR)
606-
len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
602+
len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
607603
len += snprintf(buf+len, size-len, "usgmap:%x ",
608604
ndlp->nlp_usg_map);
609605
len += snprintf(buf+len, size-len, "refcnt:%x",
610606
kref_read(&ndlp->kref));
611607
len += snprintf(buf+len, size-len, "\n");
612608
}
613609
spin_unlock_irq(shost->host_lock);
610+
614611
return len;
615612
}
613+
616614
#endif
617615

618616
/**
@@ -938,7 +936,7 @@ lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file)
938936
goto out;
939937

940938
/* Round to page boundary */
941-
printk(KERN_ERR "9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
939+
pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
942940
__func__, _dump_buf_data);
943941
debug->buffer = _dump_buf_data;
944942
if (!debug->buffer) {
@@ -968,8 +966,8 @@ lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file)
968966
goto out;
969967

970968
/* Round to page boundary */
971-
printk(KERN_ERR "9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
972-
__func__, _dump_buf_dif, file);
969+
pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
970+
__func__, _dump_buf_dif, file);
973971
debug->buffer = _dump_buf_dif;
974972
if (!debug->buffer) {
975973
kfree(debug);
@@ -3853,31 +3851,31 @@ lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
38533851
if ((mbox_tp == mbox_rd) && (dma_tp == dma_mbox)) {
38543852
if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) {
38553853
do_dump |= LPFC_BSG_DMP_MBX_RD_MBX;
3856-
printk(KERN_ERR "\nRead mbox command (x%x), "
3854+
pr_err("\nRead mbox command (x%x), "
38573855
"nemb:0x%x, extbuf_cnt:%d:\n",
38583856
sta_tp, nemb_tp, ext_buf);
38593857
}
38603858
}
38613859
if ((mbox_tp == mbox_rd) && (dma_tp == dma_ebuf)) {
38623860
if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) {
38633861
do_dump |= LPFC_BSG_DMP_MBX_RD_BUF;
3864-
printk(KERN_ERR "\nRead mbox buffer (x%x), "
3862+
pr_err("\nRead mbox buffer (x%x), "
38653863
"nemb:0x%x, extbuf_seq:%d:\n",
38663864
sta_tp, nemb_tp, ext_buf);
38673865
}
38683866
}
38693867
if ((mbox_tp == mbox_wr) && (dma_tp == dma_mbox)) {
38703868
if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) {
38713869
do_dump |= LPFC_BSG_DMP_MBX_WR_MBX;
3872-
printk(KERN_ERR "\nWrite mbox command (x%x), "
3870+
pr_err("\nWrite mbox command (x%x), "
38733871
"nemb:0x%x, extbuf_cnt:%d:\n",
38743872
sta_tp, nemb_tp, ext_buf);
38753873
}
38763874
}
38773875
if ((mbox_tp == mbox_wr) && (dma_tp == dma_ebuf)) {
38783876
if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) {
38793877
do_dump |= LPFC_BSG_DMP_MBX_WR_BUF;
3880-
printk(KERN_ERR "\nWrite mbox buffer (x%x), "
3878+
pr_err("\nWrite mbox buffer (x%x), "
38813879
"nemb:0x%x, extbuf_seq:%d:\n",
38823880
sta_tp, nemb_tp, ext_buf);
38833881
}
@@ -3889,7 +3887,7 @@ lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
38893887
for (i = 0; i < *mbx_word_cnt; i++) {
38903888
if (!(i % 8)) {
38913889
if (i != 0)
3892-
printk(KERN_ERR "%s\n", line_buf);
3890+
pr_err("%s\n", line_buf);
38933891
len = 0;
38943892
len += snprintf(line_buf+len,
38953893
LPFC_MBX_ACC_LBUF_SZ-len,
@@ -3900,7 +3898,7 @@ lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
39003898
pword++;
39013899
}
39023900
if ((i - 1) % 8)
3903-
printk(KERN_ERR "%s\n", line_buf);
3901+
pr_err("%s\n", line_buf);
39043902
(*mbx_dump_cnt)--;
39053903
}
39063904

@@ -3949,13 +3947,13 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
39493947

39503948
/* dump buffer content */
39513949
if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) {
3952-
printk(KERN_ERR "Mailbox command:0x%x dump by word:\n",
3950+
pr_err("Mailbox command:0x%x dump by word:\n",
39533951
pmbox->mbxCommand);
39543952
pword = (uint32_t *)pmbox;
39553953
for (i = 0; i < *mbx_word_cnt; i++) {
39563954
if (!(i % 8)) {
39573955
if (i != 0)
3958-
printk(KERN_ERR "%s\n", line_buf);
3956+
pr_err("%s\n", line_buf);
39593957
len = 0;
39603958
memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
39613959
len += snprintf(line_buf+len,
@@ -3968,17 +3966,17 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
39683966
pword++;
39693967
}
39703968
if ((i - 1) % 8)
3971-
printk(KERN_ERR "%s\n", line_buf);
3972-
printk(KERN_ERR "\n");
3969+
pr_err("%s\n", line_buf);
3970+
pr_err("\n");
39733971
}
39743972
if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) {
3975-
printk(KERN_ERR "Mailbox command:0x%x dump by byte:\n",
3973+
pr_err("Mailbox command:0x%x dump by byte:\n",
39763974
pmbox->mbxCommand);
39773975
pbyte = (uint8_t *)pmbox;
39783976
for (i = 0; i < *mbx_word_cnt; i++) {
39793977
if (!(i % 8)) {
39803978
if (i != 0)
3981-
printk(KERN_ERR "%s\n", line_buf);
3979+
pr_err("%s\n", line_buf);
39823980
len = 0;
39833981
memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
39843982
len += snprintf(line_buf+len,
@@ -3996,8 +3994,8 @@ lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
39963994
LPFC_MBX_ACC_LBUF_SZ-len, " ");
39973995
}
39983996
if ((i - 1) % 8)
3999-
printk(KERN_ERR "%s\n", line_buf);
4000-
printk(KERN_ERR "\n");
3997+
pr_err("%s\n", line_buf);
3998+
pr_err("\n");
40013999
}
40024000
(*mbx_dump_cnt)--;
40034001

@@ -4240,8 +4238,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42404238
i++;
42414239
}
42424240
lpfc_debugfs_max_slow_ring_trc = (1 << i);
4243-
printk(KERN_ERR
4244-
"lpfc_debugfs_max_disc_trc changed to "
4241+
pr_err("lpfc_debugfs_max_disc_trc changed to "
42454242
"%d\n", lpfc_debugfs_max_disc_trc);
42464243
}
42474244
}
@@ -4273,6 +4270,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42734270
(sizeof(struct lpfc_debugfs_trc) *
42744271
lpfc_debugfs_max_slow_ring_trc));
42754272
}
4273+
42764274
}
42774275

42784276
snprintf(name, sizeof(name), "vport%d", vport->vpi);
@@ -4298,8 +4296,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42984296
i++;
42994297
}
43004298
lpfc_debugfs_max_disc_trc = (1 << i);
4301-
printk(KERN_ERR
4302-
"lpfc_debugfs_max_disc_trc changed to %d\n",
4299+
pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
43034300
lpfc_debugfs_max_disc_trc);
43044301
}
43054302
}

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,12 +3972,13 @@ static void
39723972
lpfc_unregister_remote_port(struct lpfc_nodelist *ndlp)
39733973
{
39743974
struct fc_rport *rport = ndlp->rport;
3975+
struct lpfc_vport *vport = ndlp->vport;
39753976

3976-
lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_RPORT,
3977+
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
39773978
"rport delete: did:x%x flg:x%x type x%x",
39783979
ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type);
39793980

3980-
lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
3981+
lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
39813982
"3184 rport unregister x%06x, rport %p\n",
39823983
ndlp->nlp_DID, rport);
39833984

@@ -4424,8 +4425,6 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba,
44244425
if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi) {
44254426
return 1;
44264427
}
4427-
} else if (pring->ringno == psli->next_ring) {
4428-
44294428
}
44304429
return 0;
44314430
}

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4272,13 +4272,13 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli)
42724272
sprintf(message, "Unqualified optics - Replace with "
42734273
"Avago optics for Warranty and Technical "
42744274
"Support - Link is%s operational",
4275-
(operational) ? "" : " not");
4275+
(operational) ? " not" : "");
42764276
break;
42774277
case LPFC_SLI_EVENT_STATUS_UNCERTIFIED:
42784278
sprintf(message, "Uncertified optics - Replace with "
42794279
"Avago-certified optics to enable link "
42804280
"operation - Link is%s operational",
4281-
(operational) ? "" : " not");
4281+
(operational) ? " not" : "");
42824282
break;
42834283
default:
42844284
/* firmware is reporting a status we don't know about */
@@ -6207,6 +6207,7 @@ lpfc_create_shost(struct lpfc_hba *phba)
62076207

62086208
shost = lpfc_shost_from_vport(vport);
62096209
phba->pport = vport;
6210+
62106211
lpfc_debugfs_initialize(vport);
62116212
/* Put reference to SCSI host to driver's device private data */
62126213
pci_set_drvdata(phba->pcidev, shost);
@@ -6993,7 +6994,7 @@ lpfc_sli4_read_config(struct lpfc_hba *phba)
69936994
"VPI(B:%d M:%d) "
69946995
"VFI(B:%d M:%d) "
69956996
"RPI(B:%d M:%d) "
6996-
"FCFI(Count:%d)\n",
6997+
"FCFI:%d EQ:%d CQ:%d WQ:%d RQ:%d\n",
69976998
phba->sli4_hba.extents_in_use,
69986999
phba->sli4_hba.max_cfg_param.xri_base,
69997000
phba->sli4_hba.max_cfg_param.max_xri,
@@ -7003,7 +7004,12 @@ lpfc_sli4_read_config(struct lpfc_hba *phba)
70037004
phba->sli4_hba.max_cfg_param.max_vfi,
70047005
phba->sli4_hba.max_cfg_param.rpi_base,
70057006
phba->sli4_hba.max_cfg_param.max_rpi,
7006-
phba->sli4_hba.max_cfg_param.max_fcfi);
7007+
phba->sli4_hba.max_cfg_param.max_fcfi,
7008+
phba->sli4_hba.max_cfg_param.max_eq,
7009+
phba->sli4_hba.max_cfg_param.max_cq,
7010+
phba->sli4_hba.max_cfg_param.max_wq,
7011+
phba->sli4_hba.max_cfg_param.max_rq);
7012+
70077013
}
70087014

70097015
if (rc)
@@ -11344,7 +11350,6 @@ static struct miscdevice lpfc_mgmt_dev = {
1134411350
static int __init
1134511351
lpfc_init(void)
1134611352
{
11347-
int cpu;
1134811353
int error = 0;
1134911354

1135011355
printk(LPFC_MODULE_DESC "\n");
@@ -11370,9 +11375,7 @@ lpfc_init(void)
1137011375

1137111376
/* Initialize in case vector mapping is needed */
1137211377
lpfc_used_cpu = NULL;
11373-
lpfc_present_cpu = 0;
11374-
for_each_present_cpu(cpu)
11375-
lpfc_present_cpu++;
11378+
lpfc_present_cpu = num_present_cpus();
1137611379

1137711380
error = pci_register_driver(&lpfc_driver);
1137811381
if (error) {

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3894,7 +3894,7 @@ int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
38943894
}
38953895
}
38963896
chann = atomic_add_return(1, &phba->fcp_qidx);
3897-
chann = (chann % phba->cfg_fcp_io_channel);
3897+
chann = chann % phba->cfg_fcp_io_channel;
38983898
return chann;
38993899
}
39003900

@@ -3967,6 +3967,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
39673967
lpfc_cmd->prot_data_segment = NULL;
39683968
}
39693969
#endif
3970+
39703971
if (pnode && NLP_CHK_NODE_ACT(pnode))
39713972
atomic_dec(&pnode->cmd_pending);
39723973

drivers/scsi/lpfc/lpfc_scsi.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ struct lpfc_scsi_buf {
178178
#endif
179179
};
180180

181-
#define LPFC_SCSI_DMA_EXT_SIZE 264
182-
#define LPFC_BPL_SIZE 1024
183-
#define MDAC_DIRECT_CMD 0x22
181+
#define LPFC_SCSI_DMA_EXT_SIZE 264
182+
#define LPFC_BPL_SIZE 1024
183+
#define MDAC_DIRECT_CMD 0x22
184184

185-
#define FIND_FIRST_OAS_LUN 0
186-
#define NO_MORE_OAS_LUN -1
187-
#define NOT_OAS_ENABLED_LUN NO_MORE_OAS_LUN
185+
#define FIND_FIRST_OAS_LUN 0
186+
#define NO_MORE_OAS_LUN -1
187+
#define NOT_OAS_ENABLED_LUN NO_MORE_OAS_LUN
188188

189189
int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
190190
struct lpfc_scsi_buf *lpfc_cmd);

0 commit comments

Comments
 (0)