req->channel = scp->device->channel;
        req->target = scp->device->id;
        req->lun = scp->device->lun;
-       req->header.size = cpu_to_le32(
-                               sizeof(struct hpt_iop_request_scsi_command)
-                                + sg_count * sizeof(struct hpt_iopsg));
+       req->header.size = cpu_to_le32(struct_size(req, sg_list, sg_count));
 
        memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
        hba->ops->post_req(hba, _req);
        host->cmd_per_lun = le32_to_cpu(iop_config.max_requests);
        host->max_cmd_len = 16;
 
-       req_size = sizeof(struct hpt_iop_request_scsi_command)
-               + sizeof(struct hpt_iopsg) * hba->max_sg_descriptors;
+       req_size = struct_size((struct hpt_iop_request_scsi_command *)0,
+                              sg_list, hba->max_sg_descriptors);
        if ((req_size & 0x1f) != 0)
                req_size = (req_size + 0x1f) & ~0x1f;