scsi: zalon: Stop using the SCSI pointer
authorBart Van Assche <bvanassche@acm.org>
Fri, 18 Feb 2022 19:51:16 +0000 (11:51 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 23 Feb 2022 02:11:07 +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-49-bvanassche@acm.org
Cc: Helge Deller <deller@gmx.de>
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/ncr53c8xx.c
drivers/scsi/ncr53c8xx.h
drivers/scsi/zalon.c

index fc8abe05fa8f3c99fd6659e5b7ebe53c3ea3e4d5..4458449c960bf1c08e94a7d6fbf0f2f934f1d50e 100644 (file)
@@ -514,30 +514,29 @@ static m_addr_t __vtobus(m_bush_t bush, void *m)
  *  Deal with DMA mapping/unmapping.
  */
 
-/* To keep track of the dma mapping (sg/single) that has been set */
-#define __data_mapped  SCp.phase
-#define __data_mapping SCp.have_data_in
-
 static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
 {
-       switch(cmd->__data_mapped) {
+       struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd);
+
+       switch(cmd_priv->data_mapped) {
        case 2:
                scsi_dma_unmap(cmd);
                break;
        }
-       cmd->__data_mapped = 0;
+       cmd_priv->data_mapped = 0;
 }
 
 static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
 {
+       struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd);
        int use_sg;
 
        use_sg = scsi_dma_map(cmd);
        if (!use_sg)
                return 0;
 
-       cmd->__data_mapped = 2;
-       cmd->__data_mapping = use_sg;
+       cmd_priv->data_mapped = 2;
+       cmd_priv->data_mapping = use_sg;
 
        return use_sg;
 }
@@ -7854,6 +7853,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device)
 
 static int ncr53c8xx_queue_command_lck(struct scsi_cmnd *cmd)
 {
+     struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd);
      void (*done)(struct scsi_cmnd *) = scsi_done;
      struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
      unsigned long flags;
@@ -7864,8 +7864,8 @@ printk("ncr53c8xx_queue_command\n");
 #endif
 
      cmd->host_scribble = NULL;
-     cmd->__data_mapped = 0;
-     cmd->__data_mapping = 0;
+     cmd_priv->data_mapped = 0;
+     cmd_priv->data_mapping = 0;
 
      spin_lock_irqsave(&np->smp_lock, flags);
 
@@ -8085,6 +8085,8 @@ struct Scsi_Host * __init ncr_attach(struct scsi_host_template *tpnt,
        u_long flags = 0;
        int i;
 
+       WARN_ON_ONCE(tpnt->cmd_size < sizeof(struct ncr_cmd_priv));
+
        if (!tpnt->name)
                tpnt->name      = SCSI_NCR_DRIVER_NAME;
        if (!tpnt->shost_groups)
index fa14b5ca87831f92f1196058f9d69c039bc61595..be38c902859e0218659545c87274ecf7e58c06c3 100644 (file)
@@ -1288,6 +1288,12 @@ struct ncr_device {
        u8 differential;
 };
 
+/* To keep track of the dma mapping (sg/single) that has been set */
+struct ncr_cmd_priv {
+       int     data_mapped;
+       int     data_mapping;
+};
+
 extern struct Scsi_Host *ncr_attach(struct scsi_host_template *tpnt, int unit, struct ncr_device *device);
 extern void ncr53c8xx_release(struct Scsi_Host *host);
 irqreturn_t ncr53c8xx_intr(int irq, void *dev_id);
index f1e5cf8a17d9ed0ade8c143f0c928c48eeb4e220..22d412cab91da8db138012e5cee615330a401987 100644 (file)
@@ -81,6 +81,7 @@ lasi_scsi_clock(void * hpa, int defaultclock)
 static struct scsi_host_template zalon7xx_template = {
        .module         = THIS_MODULE,
        .proc_name      = "zalon7xx",
+       .cmd_size       = sizeof(struct ncr_cmd_priv),
 };
 
 static int __init