scsi: lpfc: Fix CPU to/from endian warnings introduced by ELS processing
The kernel test robot reported the following sparse warning:
".../lpfc_els.c:3984:25: sparse: sparse: cast from restricted __be16"
For the error being flagged, using be32_to_cpu() on a be16 data type, it
was simple enough. But a review of other elements and warnings were also
evaluated.
This patch corrected several items in the original patch:
- Using be32_to_cpu() on a be16 data type
- cpu_to_le32() used on a std uint32_t (CPU) data type.
Note: This is a byte array, but stored in LE layout by hardware at
32-bit boundaries. So it possibly needed conversion.
- Using cpu_to_le32() on a std uint16_t and assigned to a char typeA
- Using le32_to_cpu() on a le16 type
- Missing cpu_to_le16() on an assignment
Link: https://lore.kernel.org/r/20210830231243.6227-1-jsmart2021@gmail.com
Fixes: 9064aeb2df
("scsi: lpfc: Add EDC ELS support")
Reported-by: kernel test robot <lkp@intel.com>
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
96fafe7c65
commit
59936430e6
|
@ -4015,11 +4015,11 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|||
be32_to_cpu(pcgd->desc_tag),
|
||||
be32_to_cpu(pcgd->desc_len),
|
||||
be32_to_cpu(pcgd->xmt_signal_capability),
|
||||
be32_to_cpu(pcgd->xmt_signal_frequency.count),
|
||||
be32_to_cpu(pcgd->xmt_signal_frequency.units),
|
||||
be16_to_cpu(pcgd->xmt_signal_frequency.count),
|
||||
be16_to_cpu(pcgd->xmt_signal_frequency.units),
|
||||
be32_to_cpu(pcgd->rcv_signal_capability),
|
||||
be32_to_cpu(pcgd->rcv_signal_frequency.count),
|
||||
be32_to_cpu(pcgd->rcv_signal_frequency.units));
|
||||
be16_to_cpu(pcgd->rcv_signal_frequency.count),
|
||||
be16_to_cpu(pcgd->rcv_signal_frequency.units));
|
||||
|
||||
/* Compare driver and Fport capabilities and choose
|
||||
* least common.
|
||||
|
|
|
@ -1167,7 +1167,7 @@ struct lpfc_mbx_read_object { /* Version 0 */
|
|||
#define lpfc_mbx_rd_object_rlen_MASK 0x00FFFFFF
|
||||
#define lpfc_mbx_rd_object_rlen_WORD word0
|
||||
uint32_t rd_object_offset;
|
||||
uint32_t rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW];
|
||||
__le32 rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW];
|
||||
#define LPFC_OBJ_NAME_SZ 104 /* 26 x sizeof(uint32_t) is 104. */
|
||||
uint32_t rd_object_cnt;
|
||||
struct lpfc_mbx_host_buf rd_object_hbuf[4];
|
||||
|
|
|
@ -5518,7 +5518,7 @@ lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag)
|
|||
if (phba->cgn_fpin_frequency &&
|
||||
phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) {
|
||||
value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency;
|
||||
cp->cgn_stat_npm = cpu_to_le32(value);
|
||||
cp->cgn_stat_npm = value;
|
||||
}
|
||||
value = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
|
||||
LPFC_CGN_CRC32_SEED);
|
||||
|
@ -5547,9 +5547,9 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba)
|
|||
uint32_t mbps;
|
||||
uint32_t dvalue, wvalue, lvalue, avalue;
|
||||
uint64_t latsum;
|
||||
uint16_t *ptr;
|
||||
uint32_t *lptr;
|
||||
uint16_t *mptr;
|
||||
__le16 *ptr;
|
||||
__le32 *lptr;
|
||||
__le16 *mptr;
|
||||
|
||||
/* Make sure we have a congestion info buffer */
|
||||
if (!phba->cgn_i)
|
||||
|
@ -5570,7 +5570,7 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba)
|
|||
if (phba->cgn_fpin_frequency &&
|
||||
phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) {
|
||||
value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency;
|
||||
cp->cgn_stat_npm = cpu_to_le32(value);
|
||||
cp->cgn_stat_npm = value;
|
||||
}
|
||||
|
||||
/* Read and clear the latency counters for this minute */
|
||||
|
@ -5753,7 +5753,7 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba)
|
|||
dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]);
|
||||
wvalue += le32_to_cpu(cp->cgn_warn_hr[i]);
|
||||
lvalue += le32_to_cpu(cp->cgn_latency_hr[i]);
|
||||
mbps += le32_to_cpu(cp->cgn_bw_hr[i]);
|
||||
mbps += le16_to_cpu(cp->cgn_bw_hr[i]);
|
||||
avalue += le32_to_cpu(cp->cgn_alarm_hr[i]);
|
||||
}
|
||||
if (lvalue) /* Avg of latency averages */
|
||||
|
@ -13411,8 +13411,8 @@ lpfc_init_congestion_buf(struct lpfc_hba *phba)
|
|||
|
||||
/* last used Index initialized to 0xff already */
|
||||
|
||||
cp->cgn_warn_freq = LPFC_FPIN_INIT_FREQ;
|
||||
cp->cgn_alarm_freq = LPFC_FPIN_INIT_FREQ;
|
||||
cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ);
|
||||
cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED);
|
||||
cp->cgn_info_crc = cpu_to_le32(crc);
|
||||
|
||||
|
|
|
@ -22090,6 +22090,7 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
|
|||
uint32_t shdr_status, shdr_add_status;
|
||||
union lpfc_sli4_cfg_shdr *shdr;
|
||||
struct lpfc_dmabuf *pcmd;
|
||||
u32 rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW] = {0};
|
||||
|
||||
/* sanity check on queue memory */
|
||||
if (!datap)
|
||||
|
@ -22113,10 +22114,10 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
|
|||
|
||||
memset((void *)read_object->u.request.rd_object_name, 0,
|
||||
LPFC_OBJ_NAME_SZ);
|
||||
sprintf((uint8_t *)read_object->u.request.rd_object_name, rdobject);
|
||||
scnprintf((char *)rd_object_name, sizeof(rd_object_name), rdobject);
|
||||
for (j = 0; j < strlen(rdobject); j++)
|
||||
read_object->u.request.rd_object_name[j] =
|
||||
cpu_to_le32(read_object->u.request.rd_object_name[j]);
|
||||
cpu_to_le32(rd_object_name[j]);
|
||||
|
||||
pcmd = kmalloc(sizeof(*pcmd), GFP_KERNEL);
|
||||
if (pcmd)
|
||||
|
|
Loading…
Reference in New Issue