Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: qla2xxx: Let the compiler check the type of the SCSI command context pointer

Split srb_cmd.ctx into two pointers such that the compiler can check the
type of that pointer.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
5ec9f904 88263208

+20 -30
+2 -2
drivers/scsi/qla2xxx/qla_def.h
··· 317 317 uint32_t request_sense_length; 318 318 uint32_t fw_sense_length; 319 319 uint8_t *request_sense_ptr; 320 - void *ctx; 320 + struct ct6_dsd *ct6_ctx; 321 + struct crc_context *crc_ctx; 321 322 }; 322 323 323 324 /* ··· 631 630 } srb_t; 632 631 633 632 #define GET_CMD_SP(sp) (sp->u.scmd.cmd) 634 - #define GET_CMD_CTX_SP(sp) (sp->u.scmd.ctx) 635 633 636 634 #define GET_CMD_SENSE_LEN(sp) \ 637 635 (sp->u.scmd.request_sense_length)
+9 -11
drivers/scsi/qla2xxx/qla_iocb.c
··· 621 621 } 622 622 623 623 cur_seg = scsi_sglist(cmd); 624 - ctx = GET_CMD_CTX_SP(sp); 624 + ctx = sp->u.scmd.ct6_ctx; 625 625 626 626 while (tot_dsds) { 627 627 avail_dsds = (tot_dsds > QLA_DSDS_PER_IOCB) ? ··· 954 954 955 955 if (sp) { 956 956 list_add_tail(&dsd_ptr->list, 957 - &((struct crc_context *) 958 - sp->u.scmd.ctx)->dsd_list); 957 + &sp->u.scmd.crc_ctx->dsd_list); 959 958 960 959 sp->flags |= SRB_CRC_CTX_DSD_VALID; 961 960 } else { ··· 1051 1052 1052 1053 if (sp) { 1053 1054 list_add_tail(&dsd_ptr->list, 1054 - &((struct crc_context *) 1055 - sp->u.scmd.ctx)->dsd_list); 1055 + &sp->u.scmd.crc_ctx->dsd_list); 1056 1056 1057 1057 sp->flags |= SRB_CRC_CTX_DSD_VALID; 1058 1058 } else { ··· 1097 1099 1098 1100 sgl = scsi_prot_sglist(cmd); 1099 1101 vha = sp->vha; 1100 - difctx = sp->u.scmd.ctx; 1102 + difctx = sp->u.scmd.crc_ctx; 1101 1103 direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE; 1102 1104 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021, 1103 1105 "%s: scsi_cmnd: %p, crc_ctx: %p, sp: %p\n", ··· 1437 1439 bundling = 0; 1438 1440 1439 1441 /* Allocate CRC context from global pool */ 1440 - crc_ctx_pkt = sp->u.scmd.ctx = 1442 + crc_ctx_pkt = sp->u.scmd.crc_ctx = 1441 1443 dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma); 1442 1444 1443 1445 if (!crc_ctx_pkt) ··· 3186 3188 goto queuing_error; 3187 3189 } 3188 3190 3189 - ctx = sp->u.scmd.ctx = 3191 + ctx = sp->u.scmd.ct6_ctx = 3190 3192 mempool_alloc(ha->ctx_mempool, GFP_ATOMIC); 3191 3193 if (!ctx) { 3192 3194 ql_log(ql_log_fatal, vha, 0x3010, ··· 3382 3384 if (tot_dsds) 3383 3385 scsi_dma_unmap(cmd); 3384 3386 3385 - if (sp->u.scmd.ctx) { 3386 - mempool_free(sp->u.scmd.ctx, ha->ctx_mempool); 3387 - sp->u.scmd.ctx = NULL; 3387 + if (sp->u.scmd.crc_ctx) { 3388 + mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool); 3389 + sp->u.scmd.crc_ctx = NULL; 3388 3390 } 3389 3391 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3390 3392
+1 -1
drivers/scsi/qla2xxx/qla_nx.c
··· 3686 3686 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { 3687 3687 sp = req->outstanding_cmds[cnt]; 3688 3688 if (sp) { 3689 - if ((!sp->u.scmd.ctx || 3689 + if ((!sp->u.scmd.crc_ctx || 3690 3690 (sp->flags & 3691 3691 SRB_FCP_CMND_DMA_VALID)) && 3692 3692 !ha->flags.isp82xx_fw_hung) {
+8 -16
drivers/scsi/qla2xxx/qla_os.c
··· 656 656 { 657 657 struct qla_hw_data *ha = sp->vha->hw; 658 658 struct scsi_cmnd *cmd = GET_CMD_SP(sp); 659 - void *ctx = GET_CMD_CTX_SP(sp); 660 659 661 660 if (sp->flags & SRB_DMA_VALID) { 662 661 scsi_dma_unmap(cmd); ··· 668 669 sp->flags &= ~SRB_CRC_PROT_DMA_VALID; 669 670 } 670 671 671 - if (!ctx) 672 - return; 673 - 674 672 if (sp->flags & SRB_CRC_CTX_DSD_VALID) { 675 673 /* List assured to be having elements */ 676 - qla2x00_clean_dsd_pool(ha, ctx); 674 + qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx); 677 675 sp->flags &= ~SRB_CRC_CTX_DSD_VALID; 678 676 } 679 677 680 678 if (sp->flags & SRB_CRC_CTX_DMA_VALID) { 681 - struct crc_context *ctx0 = ctx; 679 + struct crc_context *ctx0 = sp->u.scmd.crc_ctx; 682 680 683 681 dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); 684 682 sp->flags &= ~SRB_CRC_CTX_DMA_VALID; 685 683 } 686 684 687 685 if (sp->flags & SRB_FCP_CMND_DMA_VALID) { 688 - struct ct6_dsd *ctx1 = ctx; 686 + struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx; 689 687 690 688 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, 691 689 ctx1->fcp_cmnd_dma); ··· 715 719 { 716 720 struct scsi_cmnd *cmd = GET_CMD_SP(sp); 717 721 struct qla_hw_data *ha = sp->fcport->vha->hw; 718 - void *ctx = GET_CMD_CTX_SP(sp); 719 722 720 723 if (sp->flags & SRB_DMA_VALID) { 721 724 scsi_dma_unmap(cmd); ··· 727 732 sp->flags &= ~SRB_CRC_PROT_DMA_VALID; 728 733 } 729 734 730 - if (!ctx) 731 - return; 732 - 733 735 if (sp->flags & SRB_CRC_CTX_DSD_VALID) { 734 736 /* List assured to be having elements */ 735 - qla2x00_clean_dsd_pool(ha, ctx); 737 + qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx); 736 738 sp->flags &= ~SRB_CRC_CTX_DSD_VALID; 737 739 } 738 740 739 741 if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) { 740 - struct crc_context *difctx = ctx; 742 + struct crc_context *difctx = sp->u.scmd.crc_ctx; 741 743 struct dsd_dma *dif_dsd, *nxt_dsd; 742 744 743 745 list_for_each_entry_safe(dif_dsd, nxt_dsd, ··· 770 778 } 771 779 772 780 if (sp->flags & SRB_FCP_CMND_DMA_VALID) { 773 - struct ct6_dsd *ctx1 = ctx; 781 + struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx; 774 782 775 783 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, 776 784 ctx1->fcp_cmnd_dma); ··· 782 790 } 783 791 784 792 if (sp->flags & SRB_CRC_CTX_DMA_VALID) { 785 - struct crc_context *ctx0 = ctx; 793 + struct crc_context *ctx0 = sp->u.scmd.crc_ctx; 786 794 787 - dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); 795 + dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); 788 796 sp->flags &= ~SRB_CRC_CTX_DMA_VALID; 789 797 } 790 798 }