Merge branch '5.19/scsi-fixes' into 5.20/scsi-staging
[platform/kernel/linux-starfive.git] / drivers / scsi / mpt3sas / mpt3sas_base.c
index 8e7fa38..565339a 100644 (file)
@@ -5369,6 +5369,7 @@ static int _base_assign_fw_reported_qd(struct MPT3SAS_ADAPTER *ioc)
        Mpi2ConfigReply_t mpi_reply;
        Mpi2SasIOUnitPage1_t *sas_iounit_pg1 = NULL;
        Mpi26PCIeIOUnitPage1_t pcie_iounit_pg1;
+       u16 depth;
        int sz;
        int rc = 0;
 
@@ -5380,7 +5381,7 @@ static int _base_assign_fw_reported_qd(struct MPT3SAS_ADAPTER *ioc)
                goto out;
        /* sas iounit page 1 */
        sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData);
-       sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
+       sas_iounit_pg1 = kzalloc(sizeof(Mpi2SasIOUnitPage1_t), GFP_KERNEL);
        if (!sas_iounit_pg1) {
                pr_err("%s: failure at %s:%d/%s()!\n",
                    ioc->name, __FILE__, __LINE__, __func__);
@@ -5393,16 +5394,16 @@ static int _base_assign_fw_reported_qd(struct MPT3SAS_ADAPTER *ioc)
                    ioc->name, __FILE__, __LINE__, __func__);
                goto out;
        }
-       ioc->max_wideport_qd =
-           (le16_to_cpu(sas_iounit_pg1->SASWideMaxQueueDepth)) ?
-           le16_to_cpu(sas_iounit_pg1->SASWideMaxQueueDepth) :
-           MPT3SAS_SAS_QUEUE_DEPTH;
-       ioc->max_narrowport_qd =
-           (le16_to_cpu(sas_iounit_pg1->SASNarrowMaxQueueDepth)) ?
-           le16_to_cpu(sas_iounit_pg1->SASNarrowMaxQueueDepth) :
-           MPT3SAS_SAS_QUEUE_DEPTH;
-       ioc->max_sata_qd = (sas_iounit_pg1->SATAMaxQDepth) ?
-           sas_iounit_pg1->SATAMaxQDepth : MPT3SAS_SATA_QUEUE_DEPTH;
+
+       depth = le16_to_cpu(sas_iounit_pg1->SASWideMaxQueueDepth);
+       ioc->max_wideport_qd = (depth ? depth : MPT3SAS_SAS_QUEUE_DEPTH);
+
+       depth = le16_to_cpu(sas_iounit_pg1->SASNarrowMaxQueueDepth);
+       ioc->max_narrowport_qd = (depth ? depth : MPT3SAS_SAS_QUEUE_DEPTH);
+
+       depth = sas_iounit_pg1->SATAMaxQDepth;
+       ioc->max_sata_qd = (depth ? depth : MPT3SAS_SATA_QUEUE_DEPTH);
+
        /* pcie iounit page 1 */
        rc = mpt3sas_config_get_pcie_iounit_pg1(ioc, &mpi_reply,
            &pcie_iounit_pg1, sizeof(Mpi26PCIeIOUnitPage1_t));