Commit cd46140a authored by Finn Thain's avatar Finn Thain Committed by Martin K. Petersen

atari_scsi, sun3_scsi: Remove global Scsi_Host pointer

This refactoring removes two global Scsi_Host pointers. This
improves consistency with other ncr5380 drivers. Adopting the same
conventions as the other drivers makes them easier to read.
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent b746545f
...@@ -1920,7 +1920,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) ...@@ -1920,7 +1920,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
/* this command setup for dma yet? */ /* this command setup for dma yet? */
if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != cmd)) { if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != cmd)) {
if (cmd->request->cmd_type == REQ_TYPE_FS) { if (cmd->request->cmd_type == REQ_TYPE_FS) {
sun3scsi_dma_setup(d, count, sun3scsi_dma_setup(instance, d, count,
rq_data_dir(cmd->request)); rq_data_dir(cmd->request));
sun3_dma_setup_done = cmd; sun3_dma_setup_done = cmd;
} }
...@@ -2458,7 +2458,8 @@ static void NCR5380_reselect(struct Scsi_Host *instance) ...@@ -2458,7 +2458,8 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
} }
/* setup this command for dma if not already */ /* setup this command for dma if not already */
if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != tmp)) { if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != tmp)) {
sun3scsi_dma_setup(d, count, rq_data_dir(tmp->request)); sun3scsi_dma_setup(instance, d, count,
rq_data_dir(tmp->request));
sun3_dma_setup_done = tmp; sun3_dma_setup_done = tmp;
} }
} }
......
...@@ -159,14 +159,10 @@ static inline unsigned long SCSI_DMA_GETADR(void) ...@@ -159,14 +159,10 @@ static inline unsigned long SCSI_DMA_GETADR(void)
return adr; return adr;
} }
#define HOSTDATA_DMALEN (((struct NCR5380_hostdata *) \
(atari_scsi_host->hostdata))->dma_len)
#ifdef REAL_DMA #ifdef REAL_DMA
static void atari_scsi_fetch_restbytes(void); static void atari_scsi_fetch_restbytes(void);
#endif #endif
static struct Scsi_Host *atari_scsi_host;
static unsigned char (*atari_scsi_reg_read)(unsigned char reg); static unsigned char (*atari_scsi_reg_read)(unsigned char reg);
static void (*atari_scsi_reg_write)(unsigned char reg, unsigned char value); static void (*atari_scsi_reg_write)(unsigned char reg, unsigned char value);
...@@ -262,15 +258,17 @@ static void scsi_dma_buserr(int irq, void *dummy) ...@@ -262,15 +258,17 @@ static void scsi_dma_buserr(int irq, void *dummy)
#endif #endif
static irqreturn_t scsi_tt_intr(int irq, void *dummy) static irqreturn_t scsi_tt_intr(int irq, void *dev)
{ {
#ifdef REAL_DMA #ifdef REAL_DMA
struct Scsi_Host *instance = dev;
struct NCR5380_hostdata *hostdata = shost_priv(instance);
int dma_stat; int dma_stat;
dma_stat = tt_scsi_dma.dma_ctrl; dma_stat = tt_scsi_dma.dma_ctrl;
dprintk(NDEBUG_INTR, "scsi%d: NCR5380 interrupt, DMA status = %02x\n", dsprintk(NDEBUG_INTR, instance, "NCR5380 interrupt, DMA status = %02x\n",
atari_scsi_host->host_no, dma_stat & 0xff); dma_stat & 0xff);
/* Look if it was the DMA that has interrupted: First possibility /* Look if it was the DMA that has interrupted: First possibility
* is that a bus error occurred... * is that a bus error occurred...
...@@ -293,7 +291,8 @@ static irqreturn_t scsi_tt_intr(int irq, void *dummy) ...@@ -293,7 +291,8 @@ static irqreturn_t scsi_tt_intr(int irq, void *dummy)
* data reg! * data reg!
*/ */
if ((dma_stat & 0x02) && !(dma_stat & 0x40)) { if ((dma_stat & 0x02) && !(dma_stat & 0x40)) {
atari_dma_residual = HOSTDATA_DMALEN - (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr); atari_dma_residual = hostdata->dma_len -
(SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr);
dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n",
atari_dma_residual); atari_dma_residual);
...@@ -345,15 +344,17 @@ static irqreturn_t scsi_tt_intr(int irq, void *dummy) ...@@ -345,15 +344,17 @@ static irqreturn_t scsi_tt_intr(int irq, void *dummy)
#endif /* REAL_DMA */ #endif /* REAL_DMA */
NCR5380_intr(irq, dummy); NCR5380_intr(irq, dev);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t scsi_falcon_intr(int irq, void *dummy) static irqreturn_t scsi_falcon_intr(int irq, void *dev)
{ {
#ifdef REAL_DMA #ifdef REAL_DMA
struct Scsi_Host *instance = dev;
struct NCR5380_hostdata *hostdata = shost_priv(instance);
int dma_stat; int dma_stat;
/* Turn off DMA and select sector counter register before /* Turn off DMA and select sector counter register before
...@@ -388,7 +389,7 @@ static irqreturn_t scsi_falcon_intr(int irq, void *dummy) ...@@ -388,7 +389,7 @@ static irqreturn_t scsi_falcon_intr(int irq, void *dummy)
printk(KERN_ERR "SCSI DMA error: %ld bytes lost in " printk(KERN_ERR "SCSI DMA error: %ld bytes lost in "
"ST-DMA fifo\n", transferred & 15); "ST-DMA fifo\n", transferred & 15);
atari_dma_residual = HOSTDATA_DMALEN - transferred; atari_dma_residual = hostdata->dma_len - transferred;
dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n",
atari_dma_residual); atari_dma_residual);
} else } else
...@@ -400,13 +401,14 @@ static irqreturn_t scsi_falcon_intr(int irq, void *dummy) ...@@ -400,13 +401,14 @@ static irqreturn_t scsi_falcon_intr(int irq, void *dummy)
* data to the original destination address. * data to the original destination address.
*/ */
memcpy(atari_dma_orig_addr, phys_to_virt(atari_dma_startaddr), memcpy(atari_dma_orig_addr, phys_to_virt(atari_dma_startaddr),
HOSTDATA_DMALEN - atari_dma_residual); hostdata->dma_len - atari_dma_residual);
atari_dma_orig_addr = NULL; atari_dma_orig_addr = NULL;
} }
#endif /* REAL_DMA */ #endif /* REAL_DMA */
NCR5380_intr(irq, dummy); NCR5380_intr(irq, dev);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -873,7 +875,6 @@ static int __init atari_scsi_probe(struct platform_device *pdev) ...@@ -873,7 +875,6 @@ static int __init atari_scsi_probe(struct platform_device *pdev)
error = -ENOMEM; error = -ENOMEM;
goto fail_alloc; goto fail_alloc;
} }
atari_scsi_host = instance;
instance->irq = irq->start; instance->irq = irq->start;
......
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
#define NCR5380_info sun3scsi_info #define NCR5380_info sun3scsi_info
#define NCR5380_dma_read_setup(instance, data, count) \ #define NCR5380_dma_read_setup(instance, data, count) \
sun3scsi_dma_setup(data, count, 0) sun3scsi_dma_setup(instance, data, count, 0)
#define NCR5380_dma_write_setup(instance, data, count) \ #define NCR5380_dma_write_setup(instance, data, count) \
sun3scsi_dma_setup(data, count, 1) sun3scsi_dma_setup(instance, data, count, 1)
#define NCR5380_dma_residual(instance) \ #define NCR5380_dma_residual(instance) \
sun3scsi_dma_residual(instance) sun3scsi_dma_residual(instance)
#define NCR5380_dma_xfer_len(instance, cmd, phase) \ #define NCR5380_dma_xfer_len(instance, cmd, phase) \
...@@ -99,7 +99,6 @@ static unsigned char *sun3_dma_orig_addr; ...@@ -99,7 +99,6 @@ static unsigned char *sun3_dma_orig_addr;
static unsigned long sun3_dma_orig_count; static unsigned long sun3_dma_orig_count;
static int sun3_dma_active; static int sun3_dma_active;
static unsigned long last_residual; static unsigned long last_residual;
static struct Scsi_Host *default_instance;
/* /*
* NCR 5380 register access functions * NCR 5380 register access functions
...@@ -142,8 +141,9 @@ static inline void sun3_udc_write(unsigned short val, unsigned char reg) ...@@ -142,8 +141,9 @@ static inline void sun3_udc_write(unsigned short val, unsigned char reg)
// safe bits for the CSR // safe bits for the CSR
#define CSR_GOOD 0x060f #define CSR_GOOD 0x060f
static irqreturn_t scsi_sun3_intr(int irq, void *dummy) static irqreturn_t scsi_sun3_intr(int irq, void *dev)
{ {
struct Scsi_Host *instance = dev;
unsigned short csr = dregs->csr; unsigned short csr = dregs->csr;
int handled = 0; int handled = 0;
...@@ -152,46 +152,24 @@ static irqreturn_t scsi_sun3_intr(int irq, void *dummy) ...@@ -152,46 +152,24 @@ static irqreturn_t scsi_sun3_intr(int irq, void *dummy)
#endif #endif
if(csr & ~CSR_GOOD) { if(csr & ~CSR_GOOD) {
if(csr & CSR_DMA_BUSERR) { if (csr & CSR_DMA_BUSERR)
printk("scsi%d: bus error in dma\n", default_instance->host_no); shost_printk(KERN_ERR, instance, "bus error in DMA\n");
} if (csr & CSR_DMA_CONFLICT)
shost_printk(KERN_ERR, instance, "DMA conflict\n");
if(csr & CSR_DMA_CONFLICT) {
printk("scsi%d: dma conflict\n", default_instance->host_no);
}
handled = 1; handled = 1;
} }
if(csr & (CSR_SDB_INT | CSR_DMA_INT)) { if(csr & (CSR_SDB_INT | CSR_DMA_INT)) {
NCR5380_intr(irq, dummy); NCR5380_intr(irq, dev);
handled = 1; handled = 1;
} }
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
/*
* Debug stuff - to be called on NMI, or sysrq key. Use at your own risk;
* reentering NCR5380_print_status seems to have ugly side effects
*/
/* this doesn't seem to get used at all -- sam */
#if 0
void sun3_sun3_debug (void)
{
unsigned long flags;
if (default_instance) {
local_irq_save(flags);
NCR5380_print_status(default_instance);
local_irq_restore(flags);
}
}
#endif
/* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */ /* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */
static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int write_flag) static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance,
void *data, unsigned long count, int write_flag)
{ {
void *addr; void *addr;
...@@ -243,10 +221,9 @@ static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int wri ...@@ -243,10 +221,9 @@ static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int wri
dregs->csr |= CSR_FIFO; dregs->csr |= CSR_FIFO;
if(dregs->fifo_count != count) { if(dregs->fifo_count != count) {
printk("scsi%d: fifo_mismatch %04x not %04x\n", shost_printk(KERN_ERR, instance, "FIFO mismatch %04x not %04x\n",
default_instance->host_no, dregs->fifo_count, dregs->fifo_count, (unsigned int) count);
(unsigned int) count); NCR5380_dprint(NDEBUG_DMA, instance);
NCR5380_dprint(NDEBUG_DMA, default_instance);
} }
/* setup udc */ /* setup udc */
...@@ -281,21 +258,6 @@ static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int wri ...@@ -281,21 +258,6 @@ static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int wri
} }
#ifndef SUN3_SCSI_VME
static inline unsigned long sun3scsi_dma_count(struct Scsi_Host *instance)
{
unsigned short resid;
dregs->udc_addr = 0x32;
udelay(SUN3_DMA_DELAY);
resid = dregs->udc_data;
udelay(SUN3_DMA_DELAY);
resid *= 2;
return (unsigned long) resid;
}
#endif
static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance) static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
{ {
return last_residual; return last_residual;
...@@ -393,7 +355,10 @@ static int sun3scsi_dma_finish(int write_flag) ...@@ -393,7 +355,10 @@ static int sun3scsi_dma_finish(int write_flag)
} }
} }
count = sun3scsi_dma_count(default_instance); dregs->udc_addr = 0x32;
udelay(SUN3_DMA_DELAY);
count = 2 * dregs->udc_data;
udelay(SUN3_DMA_DELAY);
fifo = dregs->fifo_count; fifo = dregs->fifo_count;
last_residual = fifo; last_residual = fifo;
...@@ -547,7 +512,6 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -547,7 +512,6 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
error = -ENOMEM; error = -ENOMEM;
goto fail_alloc; goto fail_alloc;
} }
default_instance = instance;
instance->io_port = (unsigned long)ioaddr; instance->io_port = (unsigned long)ioaddr;
instance->irq = irq->start; instance->irq = irq->start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment