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 <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>
This commit is contained in:
Finn Thain
2016-10-10 00:46:53 -04:00
committed by Martin K. Petersen
parent 7c60663143
commit 4a98f896bf
10 changed files with 176 additions and 114 deletions

View File

@@ -51,12 +51,10 @@
#define NCR5380_abort sun3scsi_abort
#define NCR5380_info sun3scsi_info
#define NCR5380_dma_recv_setup(instance, data, count) (count)
#define NCR5380_dma_send_setup(instance, data, count) (count)
#define NCR5380_dma_residual(instance) \
sun3scsi_dma_residual(instance)
#define NCR5380_dma_xfer_len(instance, cmd, phase) \
sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd)
#define NCR5380_dma_xfer_len sun3scsi_dma_xfer_len
#define NCR5380_dma_recv_setup sun3scsi_dma_count
#define NCR5380_dma_send_setup sun3scsi_dma_count
#define NCR5380_dma_residual sun3scsi_dma_residual
#define NCR5380_acquire_dma_irq(instance) (1)
#define NCR5380_release_dma_irq(instance)
@@ -143,8 +141,8 @@ static irqreturn_t scsi_sun3_intr(int irq, void *dev)
}
/* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */
static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance,
void *data, unsigned long count, int write_flag)
static int sun3scsi_dma_setup(struct NCR5380_hostdata *hostdata,
unsigned char *data, int count, int write_flag)
{
void *addr;
@@ -196,9 +194,10 @@ static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance,
dregs->csr |= CSR_FIFO;
if(dregs->fifo_count != count) {
shost_printk(KERN_ERR, instance, "FIFO mismatch %04x not %04x\n",
shost_printk(KERN_ERR, hostdata->host,
"FIFO mismatch %04x not %04x\n",
dregs->fifo_count, (unsigned int) count);
NCR5380_dprint(NDEBUG_DMA, instance);
NCR5380_dprint(NDEBUG_DMA, hostdata->host);
}
/* setup udc */
@@ -233,14 +232,34 @@ static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance,
}
static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
static int sun3scsi_dma_count(struct NCR5380_hostdata *hostdata,
unsigned char *data, int count)
{
return count;
}
static inline int sun3scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata,
unsigned char *data, int count)
{
return sun3scsi_dma_setup(hostdata, data, count, 0);
}
static inline int sun3scsi_dma_send_setup(struct NCR5380_hostdata *hostdata,
unsigned char *data, int count)
{
return sun3scsi_dma_setup(hostdata, data, count, 1);
}
static int sun3scsi_dma_residual(struct NCR5380_hostdata *hostdata)
{
return last_residual;
}
static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted_len,
struct scsi_cmnd *cmd)
static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
struct scsi_cmnd *cmd)
{
int wanted_len = cmd->SCp.this_residual;
if (wanted_len < DMA_MIN_SIZE || cmd->request->cmd_type != REQ_TYPE_FS)
return 0;