2023-05-25 23:47:14

by Min-Hua Chen

[permalink] [raw]
Subject: [PATCH] scsi: megaraid: use correct types for __le32 and __le16

This patch fixes several sparse warnings.
No functional changes.

drivers/scsi/megaraid/megaraid_sas_base.c:294:31: sparse: warning: restricted __le16 degrades to integer
drivers/scsi/megaraid/megaraid_sas_base.c:7579:44: sparse: warning: restricted __le32 degrades to integer
drivers/scsi/megaraid/megaraid_sas_base.c:8805:46: sparse: warning: restricted __le32 degrades to integer
drivers/scsi/megaraid/megaraid_sas_fp.c:1188:28: sparse: warning: restricted __le16 degrades to integer

Signed-off-by: Min-Hua Chen <[email protected]>
---
drivers/scsi/megaraid/megaraid_sas_base.c | 6 +++---
drivers/scsi/megaraid/megaraid_sas_fp.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 317c944c68e3..70ac7d1da2ad 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -291,7 +291,7 @@ void megasas_set_dma_settings(struct megasas_instance *instance,
if (instance->consistent_mask_64bit) {
dcmd->sgl.sge64[0].phys_addr = cpu_to_le64(dma_addr);
dcmd->sgl.sge64[0].length = cpu_to_le32(dma_len);
- dcmd->flags = cpu_to_le16(dcmd->flags | MFI_FRAME_SGL64);
+ dcmd->flags = cpu_to_le16(le16_to_cpu(dcmd->flags) | MFI_FRAME_SGL64);

} else {
dcmd->sgl.sge32[0].phys_addr =
@@ -7576,7 +7576,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
* Trigger SCSI to scan our drives
*/
if (!instance->enable_fw_dev_list ||
- (instance->host_device_list_buf->count > 0))
+ (le32_to_cpu(instance->host_device_list_buf->count) > 0))
scsi_scan_host(host);

/*
@@ -8802,7 +8802,7 @@ void megasas_add_remove_devices(struct megasas_instance *instance,

if (instance->enable_fw_dev_list) {
targetid_list = instance->host_device_list_buf;
- for (i = 0; i < targetid_list->count; i++) {
+ for (i = 0; i < le32_to_cpu(targetid_list->count); i++) {
targetid_entry = &targetid_list->host_device_list[i];
if (targetid_entry->flags.u.bits.is_sys_pd) {
channel = le16_to_cpu(targetid_entry->target_id) /
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 4463a538102a..11d16fd128c6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -1185,7 +1185,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
ref_in_start_stripe, io_info,
pRAID_Context, map);
/* If IO on an invalid Pd, then FP is not possible.*/
- if (io_info->devHandle == MR_DEVHANDLE_INVALID)
+ if (io_info->devHandle == cpu_to_le16(MR_DEVHANDLE_INVALID))
io_info->fpOkForIo = false;
return retval;
} else if (isRead) {
--
2.34.1