scsi: lpfc: Use the crc32c() function
Subsystems (2)
PATCH 1/1 scsi: lpfc: Use the crc32c() function
lpfc_cgn_calc_crc32(data, size, crc) is really just an open-coded version of ~crc32c(bitrev32(crc), data, size). However, all callers pass crc == ~0, so it can be simplified even further to just ~crc32c(~0, data, size). Remove the crc argument and implement it that way.
While we're at it, also use proper types in the function prototype.
--- drivers/scsi/Kconfig | 1 + drivers/scsi/lpfc/lpfc.h | 2 -- drivers/scsi/lpfc/lpfc_crtn.h | 2 +- drivers/scsi/lpfc/lpfc_els.c | 6 ++-- drivers/scsi/lpfc/lpfc_init.c | 58 +++++------------------------------ 5 files changed, 12 insertions(+), 57 deletions(-)
drivers/scsi/Kconfig +1 -0
@@ -1149,10 +1149,11 @@ config SCSI_LPFC depends on CPU_FREQ depends on SCSI_FC_ATTRS depends on NVME_TARGET_FC || NVME_TARGET_FC=n depends on NVME_FC || NVME_FC=n select CRC_T10DIF + select CRC32 select IRQ_POLL help This lpfc driver supports the Emulex LightPulse Family of Fibre Channel PCI host adapters.
drivers/scsi/lpfc/lpfc.h +0 -2
@@ -550,12 +550,10 @@ struct lpfc_cgn_info {struct lpfc_cgn_ts stat_lnk;/* Last link integrity FPIN */ struct lpfc_cgn_ts stat_delivery;/* Last delivery notification FPIN */ );__le32 cgn_info_crc; -#define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41 -#define LPFC_CGN_CRC32_SEED 0xFFFFFFFF };#define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \ sizeof(uint32_t))
drivers/scsi/lpfc/lpfc_crtn.h +1 -1
@@ -84,11 +84,11 @@ void lpfc_cmf_signal_init(struct lpfc_hba *phba);void lpfc_cmf_start (struct lpfc_hba *phba);void lpfc_cmf_stop (struct lpfc_hba *phba);void lpfc_init_congestion_stat (struct lpfc_hba *phba);void lpfc_init_congestion_buf (struct lpfc_hba *phba);int lpfc_sli4_cgn_params_read (struct lpfc_hba *phba); -uint32_t lpfc_cgn_calc_crc32 (void *bufp,uint32_t sz,uint32_t seed); +uint32_t lpfc_cgn_calc_crc32 (const void *data,size_t size);int lpfc_config_cgn_signal (struct lpfc_hba *phba);int lpfc_issue_cmf_sync_wqe (struct lpfc_hba *phba,u32 ms,u64 total);void lpfc_cgn_dump_rxmonitor (struct lpfc_hba *phba);void lpfc_cgn_update_stat (struct lpfc_hba *phba,uint32_t dtag);void lpfc_unblock_requests (struct lpfc_hba *phba);
drivers/scsi/lpfc/lpfc_els.c +2 -4
@@ -10289,14 +10289,12 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) phba->cgn_i->virt; cp->cgn_alarm_freq =cpu_to_le16 (value); cp->cgn_warn_freq =cpu_to_le16 (value); - crc =lpfc_cgn_calc_crc32 - (cp, -LPFC_CGN_INFO_SZ , -LPFC_CGN_CRC32_SEED ); + crc =lpfc_cgn_calc_crc32 ( + cp,LPFC_CGN_INFO_SZ ); cp->cgn_info_crc =cpu_to_le32 (crc); }/* Don't deliver to upper layer since * driver took action on this tlv.
drivers/scsi/lpfc/lpfc_init.c +8 -50
134 lines not on this page · raw message
base-commit: 2d1373e4246da3b58e1df058374ed6b101804e07
Signature · 1 line
2.53.0
Martin K. Petersen
AppliedEric,
Quoted 5 lines
lpfc_cgn_calc_crc32(data, size, crc)is really just an open-coded version of ~crc32c(bitrev32(crc), data, size). However, all callers pass crc == ~0, so it can be simplified even further to just ~crc32c(~0, data, size). Remove the crc argument and implement it that way.
Applied to 7.1/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Regards,
Justin