From 4a98f896bf2c66a69517fc5e10dc67288cb8da93 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Mon, 10 Oct 2016 00:46:53 -0400 Subject: scsi: ncr5380: Use correct types for DMA routines Apply prototypes to get consistent function signatures for the DMA functions implemented in the board-specific drivers. To avoid using macros to alter actual parameters, some of those functions are reworked slightly. This is a step toward the goal of passing the board-specific routines to the core driver using an ops struct (as in a platform driver or library module). This also helps fix some inconsistent types: where the core driver uses ints (cmd->SCp.this_residual and hostdata->dma_len) for keeping track of transfers, certain board-specific routines used unsigned long. While we are fixing these function signatures, pass the hostdata pointer to DMA routines instead of a Scsi_Host pointer, for shorter and faster code. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Ondrej Zary Tested-by: Michael Schmitz Acked-by: Russell King Signed-off-by: Martin K. Petersen --- drivers/scsi/NCR5380.c | 74 ++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 33 deletions(-) (limited to 'drivers/scsi/NCR5380.c') diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 85589922ef03..7d4e135a36cb 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -121,9 +121,10 @@ * * Either real DMA *or* pseudo DMA may be implemented * - * NCR5380_dma_write_setup(instance, src, count) - initialize - * NCR5380_dma_read_setup(instance, dst, count) - initialize - * NCR5380_dma_residual(instance); - residual count + * NCR5380_dma_xfer_len - determine size of DMA/PDMA transfer + * NCR5380_dma_send_setup - execute DMA/PDMA from memory to 5380 + * NCR5380_dma_recv_setup - execute DMA/PDMA from 5380 to memory + * NCR5380_dma_residual - residual byte count * * The generic driver is initialized by calling NCR5380_init(instance), * after setting the appropriate host specific fields and ID. If the @@ -871,7 +872,7 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_read(RESET_PARITY_INTERRUPT_REG); - transferred = hostdata->dma_len - NCR5380_dma_residual(instance); + transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); hostdata->dma_len = 0; data = (unsigned char **)&hostdata->connected->SCp.ptr; @@ -1578,9 +1579,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, * starting the NCR. This is also the cleaner way for the TT. */ if (p & SR_IO) - result = NCR5380_dma_recv_setup(instance, d, c); + result = NCR5380_dma_recv_setup(hostdata, d, c); else - result = NCR5380_dma_send_setup(instance, d, c); + result = NCR5380_dma_send_setup(hostdata, d, c); } /* @@ -1612,9 +1613,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, * NCR access, else the DMA setup gets trashed! */ if (p & SR_IO) - result = NCR5380_dma_recv_setup(instance, d, c); + result = NCR5380_dma_recv_setup(hostdata, d, c); else - result = NCR5380_dma_send_setup(instance, d, c); + result = NCR5380_dma_send_setup(hostdata, d, c); } /* On failure, NCR5380_dma_xxxx_setup() returns a negative int. */ @@ -1754,22 +1755,26 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); } #ifdef CONFIG_SUN3 - if (phase == PHASE_CMDOUT) { - void *d; - unsigned long count; + if (phase == PHASE_CMDOUT && + sun3_dma_setup_done != cmd) { + int count; if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - count = cmd->SCp.buffer->length; - d = sg_virt(cmd->SCp.buffer); - } else { - count = cmd->SCp.this_residual; - d = cmd->SCp.ptr; + ++cmd->SCp.buffer; + --cmd->SCp.buffers_residual; + cmd->SCp.this_residual = cmd->SCp.buffer->length; + cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); } - if (sun3_dma_setup_done != cmd && - sun3scsi_dma_xfer_len(count, cmd) > 0) { - sun3scsi_dma_setup(instance, d, count, - rq_data_dir(cmd->request)); + count = sun3scsi_dma_xfer_len(hostdata, cmd); + + if (count > 0) { + if (rq_data_dir(cmd->request)) + sun3scsi_dma_send_setup(hostdata, + cmd->SCp.ptr, count); + else + sun3scsi_dma_recv_setup(hostdata, + cmd->SCp.ptr, count); sun3_dma_setup_done = cmd; } #ifdef SUN3_SCSI_VME @@ -1830,7 +1835,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) transfersize = 0; if (!cmd->device->borken) - transfersize = NCR5380_dma_xfer_len(instance, cmd, phase); + transfersize = NCR5380_dma_xfer_len(hostdata, cmd); if (transfersize > 0) { len = transfersize; @@ -2207,22 +2212,25 @@ static void NCR5380_reselect(struct Scsi_Host *instance) } #ifdef CONFIG_SUN3 - { - void *d; - unsigned long count; + if (sun3_dma_setup_done != tmp) { + int count; if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { - count = tmp->SCp.buffer->length; - d = sg_virt(tmp->SCp.buffer); - } else { - count = tmp->SCp.this_residual; - d = tmp->SCp.ptr; + ++tmp->SCp.buffer; + --tmp->SCp.buffers_residual; + tmp->SCp.this_residual = tmp->SCp.buffer->length; + tmp->SCp.ptr = sg_virt(tmp->SCp.buffer); } - if (sun3_dma_setup_done != tmp && - sun3scsi_dma_xfer_len(count, tmp) > 0) { - sun3scsi_dma_setup(instance, d, count, - rq_data_dir(tmp->request)); + count = sun3scsi_dma_xfer_len(hostdata, tmp); + + if (count > 0) { + if (rq_data_dir(tmp->request)) + sun3scsi_dma_send_setup(hostdata, + tmp->SCp.ptr, count); + else + sun3scsi_dma_recv_setup(hostdata, + tmp->SCp.ptr, count); sun3_dma_setup_done = tmp; } } -- cgit v1.2.3