]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: ncr5380: Store IO ports and addresses in host private data
authorFinn Thain <fthain@telegraphics.com.au>
Mon, 10 Oct 2016 04:46:53 +0000 (00:46 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 8 Nov 2016 22:29:48 +0000 (17:29 -0500)
The various 5380 drivers inconsistently store register pointers
either in the Scsi_Host struct "legacy crap" area or in special,
board-specific members of the NCR5380_hostdata struct. Uniform
use of the latter struct makes for simpler and faster code (see
the following patches) and helps to reduce use of the
NCR5380_implementation_fields macro.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/NCR5380.c
drivers/scsi/NCR5380.h
drivers/scsi/arm/cumana_1.c
drivers/scsi/arm/oak.c
drivers/scsi/dmx3191d.c
drivers/scsi/g_NCR5380.c
drivers/scsi/g_NCR5380.h
drivers/scsi/mac_scsi.c
drivers/scsi/sun3_scsi.c

index c5c15573e23f35b50a601aed56db71ff70911484..1e6421ac1ed91f75ab516078e8786f30715131a8 100644 (file)
@@ -437,14 +437,14 @@ static void prepare_info(struct Scsi_Host *instance)
        struct NCR5380_hostdata *hostdata = shost_priv(instance);
 
        snprintf(hostdata->info, sizeof(hostdata->info),
-                "%s, io_port 0x%lx, n_io_port %d, "
-                "base 0x%lx, irq %d, "
+                "%s, irq %d, "
+                "io_port 0x%lx, base 0x%lx, "
                 "can_queue %d, cmd_per_lun %d, "
                 "sg_tablesize %d, this_id %d, "
                 "flags { %s%s%s}, "
                 "options { %s} ",
-                instance->hostt->name, instance->io_port, instance->n_io_port,
-                instance->base, instance->irq,
+                instance->hostt->name, instance->irq,
+                hostdata->io_port, hostdata->base,
                 instance->can_queue, instance->cmd_per_lun,
                 instance->sg_tablesize, instance->this_id,
                 hostdata->flags & FLAG_DMA_FIXUP     ? "DMA_FIXUP "     : "",
index ceafa0cd80bedfceb639ecfb82e935d7ec77ebe3..02f20ff757ae6094eb8a753bc51bfe855ddb9802 100644 (file)
 
 struct NCR5380_hostdata {
        NCR5380_implementation_fields;          /* Board-specific data */
+       u8 __iomem *io;                         /* Remapped 5380 address */
+       u8 __iomem *pdma_io;                    /* Remapped PDMA address */
        unsigned long poll_loops;               /* Register polling limit */
        spinlock_t lock;                        /* Protects this struct */
        struct scsi_cmnd *connected;            /* Currently connected cmnd */
@@ -230,6 +232,8 @@ struct NCR5380_hostdata {
        int flags;                              /* Board-specific quirks */
        int dma_len;                            /* Requested length of DMA */
        int read_overruns;      /* Transfer size reduction for DMA erratum */
+       unsigned long io_port;                  /* Device IO port */
+       unsigned long base;                     /* Device base address */
        struct list_head unissued;              /* Waiting to be issued */
        struct scsi_cmnd *selecting;            /* Cmnd to be connected */
        struct list_head autosense;             /* Priority cmnd queue */
@@ -239,6 +243,7 @@ struct NCR5380_hostdata {
        unsigned char id_mask;                  /* 1 << Host ID */
        unsigned char id_higher_mask;           /* All bits above id_mask */
        unsigned char last_message;             /* Last Message Out */
+       unsigned long region_size;              /* Size of address/port range */
        char info[256];
 };
 
index f616756feee5b229a68590679125bda5dbf14def..88db2816f97c8d23d20f4eacf6f4a9e4bda29746 100644 (file)
@@ -27,9 +27,7 @@
 #define NCR5380_info                   cumanascsi_info
 
 #define NCR5380_implementation_fields  \
-       unsigned ctrl;                  \
-       void __iomem *base;             \
-       void __iomem *dma
+       unsigned ctrl
 
 #include "../NCR5380.h"
 
@@ -42,17 +40,18 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
                                     unsigned char *addr, int len)
 {
   unsigned long *laddr;
-  void __iomem *dma = priv(host)->dma + 0x2000;
+  u8 __iomem *base = priv(host)->io;
+  u8 __iomem *dma = priv(host)->pdma_io + 0x2000;
 
   if(!len) return 0;
 
-  writeb(0x02, priv(host)->base + CTRL);
+  writeb(0x02, base + CTRL);
   laddr = (unsigned long *)addr;
   while(len >= 32)
   {
     unsigned int status;
     unsigned long v;
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(!(status & 0x40))
@@ -71,12 +70,12 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
   }
 
   addr = (unsigned char *)laddr;
-  writeb(0x12, priv(host)->base + CTRL);
+  writeb(0x12, base + CTRL);
 
   while(len > 0)
   {
     unsigned int status;
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(status & 0x40)
@@ -86,7 +85,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
         break;
     }
 
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(status & 0x40)
@@ -97,7 +96,7 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host,
     }
   }
 end:
-  writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
+  writeb(priv(host)->ctrl | 0x40, base + CTRL);
 
        if (len)
                return -1;
@@ -108,16 +107,17 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
                                    unsigned char *addr, int len)
 {
   unsigned long *laddr;
-  void __iomem *dma = priv(host)->dma + 0x2000;
+  u8 __iomem *base = priv(host)->io;
+  u8 __iomem *dma = priv(host)->pdma_io + 0x2000;
 
   if(!len) return 0;
 
-  writeb(0x00, priv(host)->base + CTRL);
+  writeb(0x00, base + CTRL);
   laddr = (unsigned long *)addr;
   while(len >= 32)
   {
     unsigned int status;
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(!(status & 0x40))
@@ -136,12 +136,12 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
   }
 
   addr = (unsigned char *)laddr;
-  writeb(0x10, priv(host)->base + CTRL);
+  writeb(0x10, base + CTRL);
 
   while(len > 0)
   {
     unsigned int status;
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(status & 0x40)
@@ -151,7 +151,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
         break;
     }
 
-    status = readb(priv(host)->base + STAT);
+    status = readb(base + STAT);
     if(status & 0x80)
       goto end;
     if(status & 0x40)
@@ -162,7 +162,7 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
     }
   }
 end:
-  writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
+  writeb(priv(host)->ctrl | 0x40, base + CTRL);
 
        if (len)
                return -1;
@@ -171,7 +171,7 @@ end:
 
 static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
 {
-       void __iomem *base = priv(host)->base;
+       u8 __iomem *base = priv(host)->io;
        unsigned char val;
 
        writeb(0, base + CTRL);
@@ -186,7 +186,7 @@ static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
 
 static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value)
 {
-       void __iomem *base = priv(host)->base;
+       u8 __iomem *base = priv(host)->io;
 
        writeb(0, base + CTRL);
 
@@ -231,11 +231,11 @@ static int cumanascsi1_probe(struct expansion_card *ec,
                goto out_release;
        }
 
-       priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
-                                  ecard_resource_len(ec, ECARD_RES_IOCSLOW));
-       priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
-                                 ecard_resource_len(ec, ECARD_RES_MEMC));
-       if (!priv(host)->base || !priv(host)->dma) {
+       priv(host)->io = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
+                                ecard_resource_len(ec, ECARD_RES_IOCSLOW));
+       priv(host)->pdma_io = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
+                                     ecard_resource_len(ec, ECARD_RES_MEMC));
+       if (!priv(host)->io || !priv(host)->pdma_io) {
                ret = -ENOMEM;
                goto out_unmap;
        }
@@ -249,7 +249,7 @@ static int cumanascsi1_probe(struct expansion_card *ec,
        NCR5380_maybe_reset_bus(host);
 
         priv(host)->ctrl = 0;
-        writeb(0, priv(host)->base + CTRL);
+        writeb(0, priv(host)->io + CTRL);
 
        ret = request_irq(host->irq, cumanascsi_intr, 0,
                          "CumanaSCSI-1", host);
@@ -271,8 +271,8 @@ static int cumanascsi1_probe(struct expansion_card *ec,
  out_exit:
        NCR5380_exit(host);
  out_unmap:
-       iounmap(priv(host)->base);
-       iounmap(priv(host)->dma);
+       iounmap(priv(host)->io);
+       iounmap(priv(host)->pdma_io);
        scsi_host_put(host);
  out_release:
        ecard_release_resources(ec);
@@ -283,15 +283,17 @@ static int cumanascsi1_probe(struct expansion_card *ec,
 static void cumanascsi1_remove(struct expansion_card *ec)
 {
        struct Scsi_Host *host = ecard_get_drvdata(ec);
+       void __iomem *base = priv(host)->io;
+       void __iomem *dma = priv(host)->pdma_io;
 
        ecard_set_drvdata(ec, NULL);
 
        scsi_remove_host(host);
        free_irq(host->irq, host);
        NCR5380_exit(host);
-       iounmap(priv(host)->base);
-       iounmap(priv(host)->dma);
        scsi_host_put(host);
+       iounmap(base);
+       iounmap(dma);
        ecard_release_resources(ec);
 }
 
index a396024a3caeca5d8850c68cc188048167549138..1c4a44a1e62d83abe0771ae287af0c806da6ba1a 100644 (file)
@@ -17,9 +17,9 @@
 #define priv(host)                     ((struct NCR5380_hostdata *)(host)->hostdata)
 
 #define NCR5380_read(reg) \
-       readb(priv(instance)->base + ((reg) << 2))
+       readb(priv(instance)->io + ((reg) << 2))
 #define NCR5380_write(reg, value) \
-       writeb(value, priv(instance)->base + ((reg) << 2))
+       writeb(value, priv(instance)->io + ((reg) << 2))
 
 #define NCR5380_dma_xfer_len(instance, cmd, phase)     (0)
 #define NCR5380_dma_recv_setup         oakscsi_pread
@@ -29,8 +29,7 @@
 #define NCR5380_queue_command          oakscsi_queue_command
 #define NCR5380_info                   oakscsi_info
 
-#define NCR5380_implementation_fields  \
-       void __iomem *base
+#define NCR5380_implementation_fields  /* none */
 
 #include "../NCR5380.h"
 
@@ -43,7 +42,7 @@
 static inline int oakscsi_pwrite(struct Scsi_Host *instance,
                                  unsigned char *addr, int len)
 {
-  void __iomem *base = priv(instance)->base;
+  u8 __iomem *base = priv(instance)->io;
 
 printk("writing %p len %d\n",addr, len);
 
@@ -58,7 +57,7 @@ printk("writing %p len %d\n",addr, len);
 static inline int oakscsi_pread(struct Scsi_Host *instance,
                                 unsigned char *addr, int len)
 {
-  void __iomem *base = priv(instance)->base;
+  u8 __iomem *base = priv(instance)->io;
 printk("reading %p len %d\n", addr, len);
   while(len > 0)
   {
@@ -133,15 +132,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
                goto release;
        }
 
-       priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
-                                  ecard_resource_len(ec, ECARD_RES_MEMC));
-       if (!priv(host)->base) {
+       priv(host)->io = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
+                                ecard_resource_len(ec, ECARD_RES_MEMC));
+       if (!priv(host)->io) {
                ret = -ENOMEM;
                goto unreg;
        }
 
        host->irq = NO_IRQ;
-       host->n_io_port = 255;
 
        ret = NCR5380_init(host, FLAG_DMA_FIXUP | FLAG_LATE_DMA_SETUP);
        if (ret)
@@ -159,7 +157,7 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
  out_exit:
        NCR5380_exit(host);
  out_unmap:
-       iounmap(priv(host)->base);
+       iounmap(priv(host)->io);
  unreg:
        scsi_host_put(host);
  release:
@@ -171,13 +169,14 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
 static void oakscsi_remove(struct expansion_card *ec)
 {
        struct Scsi_Host *host = ecard_get_drvdata(ec);
+       void __iomem *base = priv(host)->io;
 
        ecard_set_drvdata(ec, NULL);
        scsi_remove_host(host);
 
        NCR5380_exit(host);
-       iounmap(priv(host)->base);
        scsi_host_put(host);
+       iounmap(base);
        ecard_release_resources(ec);
 }
 
index 9b5a457d4bca4371a147af0cf786dc08a7c97f9d..3b6df905a81cdc0154db7b34b194a74aad837b27 100644 (file)
  * Definitions for the generic 5380 driver.
  */
 
-#define NCR5380_read(reg)              inb(instance->io_port + reg)
-#define NCR5380_write(reg, value)      outb(value, instance->io_port + reg)
+#define priv(instance) ((struct NCR5380_hostdata *)shost_priv(instance))
+
+#define NCR5380_read(reg)              inb(priv(instance)->base + (reg))
+#define NCR5380_write(reg, value)      outb(value, priv(instance)->base + (reg))
 
 #define NCR5380_dma_xfer_len(instance, cmd, phase)     (0)
 #define NCR5380_dma_recv_setup(instance, dst, len)     (0)
@@ -71,6 +73,7 @@ static int dmx3191d_probe_one(struct pci_dev *pdev,
                              const struct pci_device_id *id)
 {
        struct Scsi_Host *shost;
+       struct NCR5380_hostdata *hostdata;
        unsigned long io;
        int error = -ENODEV;
 
@@ -88,7 +91,9 @@ static int dmx3191d_probe_one(struct pci_dev *pdev,
                        sizeof(struct NCR5380_hostdata));
        if (!shost)
                goto out_release_region;       
-       shost->io_port = io;
+
+       hostdata = shost_priv(shost);
+       hostdata->base = io;
 
        /* This card does not seem to raise an interrupt on pdev->irq.
         * Steam-powered SCSI controllers run without an IRQ anyway.
@@ -125,7 +130,8 @@ out_host_put:
 static void dmx3191d_remove_one(struct pci_dev *pdev)
 {
        struct Scsi_Host *shost = pci_get_drvdata(pdev);
-       unsigned long io = shost->io_port;
+       struct NCR5380_hostdata *hostdata = shost_priv(shost);
+       unsigned long io = hostdata->base;
 
        scsi_remove_host(shost);
 
index 4d7a9de01645efdeb5683064f8a2e1d439f24c44..98aef0eb8b5908092f04f73ceae9090b73a77368 100644 (file)
@@ -115,7 +115,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
        unsigned long region_size;
        struct Scsi_Host *instance;
        struct NCR5380_hostdata *hostdata;
-       void __iomem *iomem;
+       u8 __iomem *iomem;
 
        switch (board) {
        case BOARD_NCR5380:
@@ -201,11 +201,11 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
        }
        hostdata = shost_priv(instance);
 
-       hostdata->iomem = iomem;
+       hostdata->io = iomem;
+       hostdata->region_size = region_size;
 
        if (is_pmio) {
-               instance->io_port = base;
-               instance->n_io_port = region_size;
+               hostdata->io_port = base;
                hostdata->io_width = 1; /* 8-bit PDMA by default */
                hostdata->offset = 0;
 
@@ -215,7 +215,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
                 */
                switch (board) {
                case BOARD_NCR53C400:
-                       instance->io_port += 8;
+                       hostdata->io_port += 8;
                        hostdata->c400_ctl_status = 0;
                        hostdata->c400_blk_cnt = 1;
                        hostdata->c400_host_buf = 4;
@@ -231,8 +231,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
                        break;
                }
        } else {
-               instance->base = base;
-               hostdata->iomem_size = region_size;
+               hostdata->base = base;
                hostdata->offset = NCR53C400_mem_base;
                switch (board) {
                case BOARD_NCR53C400:
@@ -314,17 +313,21 @@ out_release:
 static void generic_NCR5380_release_resources(struct Scsi_Host *instance)
 {
        struct NCR5380_hostdata *hostdata = shost_priv(instance);
+       void __iomem *iomem = hostdata->io;
+       unsigned long io_port = hostdata->io_port;
+       unsigned long base = hostdata->base;
+       unsigned long region_size = hostdata->region_size;
 
        scsi_remove_host(instance);
        if (instance->irq != NO_IRQ)
                free_irq(instance->irq, instance);
        NCR5380_exit(instance);
-       iounmap(hostdata->iomem);
-       if (instance->io_port)
-               release_region(instance->io_port, instance->n_io_port);
-       else
-               release_mem_region(instance->base, hostdata->iomem_size);
        scsi_host_put(instance);
+       iounmap(iomem);
+       if (io_port)
+               release_region(io_port, region_size);
+       else
+               release_mem_region(base, region_size);
 }
 
 /**
@@ -356,15 +359,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance,
                while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
                        ; /* FIXME - no timeout */
 
-               if (instance->io_port && hostdata->io_width == 2)
-                       insw(instance->io_port + hostdata->c400_host_buf,
+               if (hostdata->io_port && hostdata->io_width == 2)
+                       insw(hostdata->io_port + hostdata->c400_host_buf,
                                                        dst + start, 64);
-               else if (instance->io_port)
-                       insb(instance->io_port + hostdata->c400_host_buf,
+               else if (hostdata->io_port)
+                       insb(hostdata->io_port + hostdata->c400_host_buf,
                                                        dst + start, 128);
                else
                        memcpy_fromio(dst + start,
-                               hostdata->iomem + NCR53C400_host_buffer, 128);
+                               hostdata->io + NCR53C400_host_buffer, 128);
 
                start += 128;
                blocks--;
@@ -374,15 +377,15 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance,
                while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
                        ; /* FIXME - no timeout */
 
-               if (instance->io_port && hostdata->io_width == 2)
-                       insw(instance->io_port + hostdata->c400_host_buf,
+               if (hostdata->io_port && hostdata->io_width == 2)
+                       insw(hostdata->io_port + hostdata->c400_host_buf,
                                                        dst + start, 64);
-               else if (instance->io_port)
-                       insb(instance->io_port + hostdata->c400_host_buf,
+               else if (hostdata->io_port)
+                       insb(hostdata->io_port + hostdata->c400_host_buf,
                                                        dst + start, 128);
                else
                        memcpy_fromio(dst + start,
-                               hostdata->iomem + NCR53C400_host_buffer, 128);
+                               hostdata->io + NCR53C400_host_buffer, 128);
 
                start += 128;
                blocks--;
@@ -431,14 +434,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance,
                while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
                        ; // FIXME - timeout
 
-               if (instance->io_port && hostdata->io_width == 2)
-                       outsw(instance->io_port + hostdata->c400_host_buf,
+               if (hostdata->io_port && hostdata->io_width == 2)
+                       outsw(hostdata->io_port + hostdata->c400_host_buf,
                                                        src + start, 64);
-               else if (instance->io_port)
-                       outsb(instance->io_port + hostdata->c400_host_buf,
+               else if (hostdata->io_port)
+                       outsb(hostdata->io_port + hostdata->c400_host_buf,
                                                        src + start, 128);
                else
-                       memcpy_toio(hostdata->iomem + NCR53C400_host_buffer,
+                       memcpy_toio(hostdata->io + NCR53C400_host_buffer,
                                    src + start, 128);
 
                start += 128;
@@ -448,14 +451,14 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance,
                while (NCR5380_read(hostdata->c400_ctl_status) & CSR_HOST_BUF_NOT_RDY)
                        ; // FIXME - no timeout
 
-               if (instance->io_port && hostdata->io_width == 2)
-                       outsw(instance->io_port + hostdata->c400_host_buf,
+               if (hostdata->io_port && hostdata->io_width == 2)
+                       outsw(hostdata->io_port + hostdata->c400_host_buf,
                                                        src + start, 64);
-               else if (instance->io_port)
-                       outsb(instance->io_port + hostdata->c400_host_buf,
+               else if (hostdata->io_port)
+                       outsb(hostdata->io_port + hostdata->c400_host_buf,
                                                        src + start, 128);
                else
-                       memcpy_toio(hostdata->iomem + NCR53C400_host_buffer,
+                       memcpy_toio(hostdata->io + NCR53C400_host_buffer,
                                    src + start, 128);
 
                start += 128;
index 2b77782439f13957a47288e84075707a1a0e3904..ec4d70bef5e5e0c51d2b2d4e00ea3146fdfbe251 100644 (file)
 #define DRV_MODULE_NAME "g_NCR5380"
 
 #define NCR5380_read(reg) \
-       ioread8(((struct NCR5380_hostdata *)shost_priv(instance))->iomem + \
+       ioread8(((struct NCR5380_hostdata *)shost_priv(instance))->io + \
                ((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
                (reg))
 #define NCR5380_write(reg, value) \
-       iowrite8(value, ((struct NCR5380_hostdata *)shost_priv(instance))->iomem + \
+       iowrite8(value, ((struct NCR5380_hostdata *)shost_priv(instance))->io + \
                ((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
                (reg))
 
 #define NCR5380_implementation_fields \
        int offset; \
-       void __iomem *iomem; \
-       resource_size_t iomem_size; \
        int c400_ctl_status; \
        int c400_blk_cnt; \
        int c400_host_buf; \
index a590089b9397b3fedc619dd83f7bc91285e03065..80e10d9f2067ae654106adcc73cf344275bbdaae 100644 (file)
@@ -28,8 +28,7 @@
 
 /* Definitions for the core NCR5380 driver. */
 
-#define NCR5380_implementation_fields   unsigned char *pdma_base; \
-                                        int pdma_residual
+#define NCR5380_implementation_fields   int pdma_residual
 
 #define NCR5380_read(reg)               macscsi_read(instance, reg)
 #define NCR5380_write(reg, value)       macscsi_write(instance, reg, value)
@@ -67,12 +66,16 @@ module_param(setup_toshiba_delay, int, 0);
 
 static inline char macscsi_read(struct Scsi_Host *instance, int reg)
 {
-       return in_8(instance->base + (reg << 4));
+       struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+       return in_8(hostdata->io + (reg << 4));
 }
 
 static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value)
 {
-       out_8(instance->base + (reg << 4), value);
+       struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+       out_8(hostdata->io + (reg << 4), value);
 }
 
 #ifndef MODULE
@@ -171,7 +174,7 @@ static int macscsi_pread(struct Scsi_Host *instance,
                          unsigned char *dst, int len)
 {
        struct NCR5380_hostdata *hostdata = shost_priv(instance);
-       unsigned char *s = hostdata->pdma_base + (INPUT_DATA_REG << 4);
+       unsigned char *s = hostdata->pdma_io + (INPUT_DATA_REG << 4);
        unsigned char *d = dst;
        int n = len;
        int transferred;
@@ -275,7 +278,7 @@ static int macscsi_pwrite(struct Scsi_Host *instance,
 {
        struct NCR5380_hostdata *hostdata = shost_priv(instance);
        unsigned char *s = src;
-       unsigned char *d = hostdata->pdma_base + (OUTPUT_DATA_REG << 4);
+       unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4);
        int n = len;
        int transferred;
 
@@ -356,6 +359,7 @@ static struct scsi_host_template mac_scsi_template = {
 static int __init mac_scsi_probe(struct platform_device *pdev)
 {
        struct Scsi_Host *instance;
+       struct NCR5380_hostdata *hostdata;
        int error;
        int host_flags = 0;
        struct resource *irq, *pio_mem, *pdma_mem = NULL;
@@ -388,17 +392,18 @@ static int __init mac_scsi_probe(struct platform_device *pdev)
        if (!instance)
                return -ENOMEM;
 
-       instance->base = pio_mem->start;
        if (irq)
                instance->irq = irq->start;
        else
                instance->irq = NO_IRQ;
 
-       if (pdma_mem && setup_use_pdma) {
-               struct NCR5380_hostdata *hostdata = shost_priv(instance);
+       hostdata = shost_priv(instance);
+       hostdata->base = pio_mem->start;
+       hostdata->io = (void *)pio_mem->start;
 
-               hostdata->pdma_base = (unsigned char *)pdma_mem->start;
-       } else
+       if (pdma_mem && setup_use_pdma)
+               hostdata->pdma_io = (void *)pdma_mem->start;
+       else
                host_flags |= FLAG_NO_PSEUDO_DMA;
 
        host_flags |= setup_toshiba_delay > 0 ? FLAG_TOSHIBA_DELAY : 0;
index 3c4c07038948d5cef306f500630d4f3d48ca36b5..efee144c60562ed2807ad71a682b14858aad384f 100644 (file)
@@ -428,6 +428,7 @@ static struct scsi_host_template sun3_scsi_template = {
 static int __init sun3_scsi_probe(struct platform_device *pdev)
 {
        struct Scsi_Host *instance;
+       struct NCR5380_hostdata *hostdata;
        int error;
        struct resource *irq, *mem;
        unsigned char *ioaddr;
@@ -502,9 +503,11 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
                goto fail_alloc;
        }
 
-       instance->io_port = (unsigned long)ioaddr;
        instance->irq = irq->start;
 
+       hostdata = shost_priv(instance);
+       hostdata->base = (unsigned long)ioaddr;
+
        error = NCR5380_init(instance, host_flags);
        if (error)
                goto fail_init;