scsi: initio: Stop using the SCSI pointer
authorBart Van Assche <bvanassche@acm.org>
Fri, 18 Feb 2022 19:50:54 +0000 (11:50 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 23 Feb 2022 02:11:05 +0000 (21:11 -0500)
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>
drivers/scsi/initio.c
drivers/scsi/initio.h

index 5f96ac4..f585d6e 100644 (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,
index 9fd010c..7c97415 100644 (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);
+}