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

scsi: bnx2fc: Stop using the SCSI pointer

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. Remove the CMD_SCSI_STATUS() assignment because the
assigned value is not used.

This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-29-bvanassche@acm.org
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
f4b4216f 5d21aa36

+19 -14
+7 -2
drivers/scsi/bnx2fc/bnx2fc.h
··· 137 137 #define BNX2FC_FW_TIMEOUT (3 * HZ) 138 138 #define PORT_MAX 2 139 139 140 - #define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) 141 - 142 140 /* FC FCP Status */ 143 141 #define FC_GOOD 0 144 142 ··· 491 493 struct work_struct unsol_els_work; 492 494 }; 493 495 496 + struct bnx2fc_priv { 497 + struct bnx2fc_cmd *io_req; 498 + }; 494 499 500 + static inline struct bnx2fc_priv *bnx2fc_priv(struct scsi_cmnd *cmd) 501 + { 502 + return scsi_cmd_priv(cmd); 503 + } 495 504 496 505 struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt); 497 506 struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type);
+1
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 2974 2974 .track_queue_depth = 1, 2975 2975 .slave_configure = bnx2fc_slave_configure, 2976 2976 .shost_groups = bnx2fc_host_groups, 2977 + .cmd_size = sizeof(struct bnx2fc_priv), 2977 2978 }; 2978 2979 2979 2980 static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
+11 -12
drivers/scsi/bnx2fc/bnx2fc_io.c
··· 204 204 sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries, 205 205 sc_cmd->allowed); 206 206 scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd)); 207 - sc_cmd->SCp.ptr = NULL; 207 + bnx2fc_priv(sc_cmd)->io_req = NULL; 208 208 scsi_done(sc_cmd); 209 209 } 210 210 ··· 765 765 task = &(task_page[index]); 766 766 bnx2fc_init_mp_task(io_req, task); 767 767 768 - sc_cmd->SCp.ptr = (char *)io_req; 768 + bnx2fc_priv(sc_cmd)->io_req = io_req; 769 769 770 770 /* Obtain free SQ entry */ 771 771 spin_lock_bh(&tgt->tgt_lock); ··· 1147 1147 BNX2FC_TGT_DBG(tgt, "Entered bnx2fc_eh_abort\n"); 1148 1148 1149 1149 spin_lock_bh(&tgt->tgt_lock); 1150 - io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; 1150 + io_req = bnx2fc_priv(sc_cmd)->io_req; 1151 1151 if (!io_req) { 1152 1152 /* Command might have just completed */ 1153 1153 printk(KERN_ERR PFX "eh_abort: io_req is NULL\n"); ··· 1572 1572 printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n", 1573 1573 fc_hdr->fh_r_ctl); 1574 1574 } 1575 - if (!sc_cmd->SCp.ptr) { 1576 - printk(KERN_ERR PFX "tm_compl: SCp.ptr is NULL\n"); 1575 + if (!bnx2fc_priv(sc_cmd)->io_req) { 1576 + printk(KERN_ERR PFX "tm_compl: io_req is NULL\n"); 1577 1577 return; 1578 1578 } 1579 1579 switch (io_req->fcp_status) { ··· 1609 1609 return; 1610 1610 } 1611 1611 1612 - sc_cmd->SCp.ptr = NULL; 1612 + bnx2fc_priv(sc_cmd)->io_req = NULL; 1613 1613 scsi_done(sc_cmd); 1614 1614 1615 1615 kref_put(&io_req->refcount, bnx2fc_cmd_release); ··· 1773 1773 io_req->fcp_resid = fcp_rsp->fcp_resid; 1774 1774 1775 1775 io_req->scsi_comp_flags = rsp_flags; 1776 - CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = 1777 - fcp_rsp->scsi_status_code; 1776 + io_req->cdb_status = fcp_rsp->scsi_status_code; 1778 1777 1779 1778 /* Fetch fcp_rsp_info and fcp_sns_info if available */ 1780 1779 if (num_rq) { ··· 1945 1946 /* parse fcp_rsp and obtain sense data from RQ if available */ 1946 1947 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data); 1947 1948 1948 - if (!sc_cmd->SCp.ptr) { 1949 - printk(KERN_ERR PFX "SCp.ptr is NULL\n"); 1949 + if (!bnx2fc_priv(sc_cmd)->io_req) { 1950 + printk(KERN_ERR PFX "io_req is NULL\n"); 1950 1951 return; 1951 1952 } 1952 1953 ··· 2017 2018 io_req->fcp_status); 2018 2019 break; 2019 2020 } 2020 - sc_cmd->SCp.ptr = NULL; 2021 + bnx2fc_priv(sc_cmd)->io_req = NULL; 2021 2022 scsi_done(sc_cmd); 2022 2023 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2023 2024 } ··· 2043 2044 io_req->port = port; 2044 2045 io_req->tgt = tgt; 2045 2046 io_req->data_xfer_len = scsi_bufflen(sc_cmd); 2046 - sc_cmd->SCp.ptr = (char *)io_req; 2047 + bnx2fc_priv(sc_cmd)->io_req = io_req; 2047 2048 2048 2049 stats = per_cpu_ptr(lport->stats, get_cpu()); 2049 2050 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {