scsi: initio: Stop using the SCSI pointer

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-27-bvanassche@acm.org
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Bart Van Assche 2022-02-18 11:50:54 -08:00 committed by Martin K. Petersen
parent db22de3eb0
commit 09cc102bb4
2 changed files with 17 additions and 6 deletions

View File

@ -2553,7 +2553,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c
SENSE_SIZE, DMA_FROM_DEVICE);
cblk->senseptr = (u32)dma_addr;
cblk->senselen = SENSE_SIZE;
cmnd->SCp.ptr = (char *)(unsigned long)dma_addr;
initio_priv(cmnd)->sense_dma_addr = dma_addr;
cblk->cdblen = cmnd->cmd_len;
/* Clear the returned status */
@ -2577,7 +2577,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c
sizeof(struct sg_entry) * TOTAL_SG_ENTRY,
DMA_BIDIRECTIONAL);
cblk->bufptr = (u32)dma_addr;
cmnd->SCp.dma_handle = dma_addr;
initio_priv(cmnd)->sglist_dma_addr = dma_addr;
cblk->sglen = nseg;
@ -2704,16 +2704,17 @@ static int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev,
static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
{
/* auto sense buffer */
if (cmnd->SCp.ptr) {
if (initio_priv(cmnd)->sense_dma_addr) {
dma_unmap_single(&pci_dev->dev,
(dma_addr_t)((unsigned long)cmnd->SCp.ptr),
initio_priv(cmnd)->sense_dma_addr,
SENSE_SIZE, DMA_FROM_DEVICE);
cmnd->SCp.ptr = NULL;
initio_priv(cmnd)->sense_dma_addr = 0;
}
/* request buffer */
if (scsi_sg_count(cmnd)) {
dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
dma_unmap_single(&pci_dev->dev,
initio_priv(cmnd)->sglist_dma_addr,
sizeof(struct sg_entry) * TOTAL_SG_ENTRY,
DMA_BIDIRECTIONAL);
@ -2796,6 +2797,7 @@ static struct scsi_host_template initio_template = {
.can_queue = MAX_TARGETS * i91u_MAXQUEUE,
.this_id = 1,
.sg_tablesize = SG_ALL,
.cmd_size = sizeof(struct initio_cmd_priv),
};
static int initio_probe_one(struct pci_dev *pdev,

View File

@ -640,3 +640,12 @@ typedef struct _NVRAM {
#define SCSI_RESET_HOST_RESET 0x200
#define SCSI_RESET_ACTION 0xff
struct initio_cmd_priv {
dma_addr_t sense_dma_addr;
dma_addr_t sglist_dma_addr;
};
static inline struct initio_cmd_priv *initio_priv(struct scsi_cmnd *cmd)
{
return scsi_cmd_priv(cmd);
}