scsi: ncr5380: Expedite register polling
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)
Avoid the call to NCR5380_poll_politely2() when possible. The call is
easily short-circuited on the PIO fast path, using the inline wrapper.
This requires that the NCR5380_read macro be made available before
any #include "NCR5380.h" so a few declarations have to be moved too.

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>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/NCR5380.h
drivers/scsi/arm/cumana_1.c
drivers/scsi/atari_scsi.c

index 4682baab07ed1c278a6c7215a12bb66352c08c73..b2c560cb0218dd68ba2f44e7eed193fef90d0844 100644 (file)
@@ -310,6 +310,9 @@ static inline int NCR5380_poll_politely(struct NCR5380_hostdata *hostdata,
                                         unsigned int reg, u8 bit, u8 val,
                                         unsigned long wait)
 {
+       if ((NCR5380_read(reg) & bit) == val)
+               return 0;
+
        return NCR5380_poll_politely2(hostdata, reg, bit, val,
                                                reg, bit, val, wait);
 }
index ae1d4c6786de0fd350e750fb3f52cba31d5c6dd5..fb7600dec5beb4037c59730b218a39d052528dd8 100644 (file)
 #define NCR5380_implementation_fields  \
        unsigned ctrl
 
+struct NCR5380_hostdata;
+static u8 cumanascsi_read(struct NCR5380_hostdata *, unsigned int);
+static void cumanascsi_write(struct NCR5380_hostdata *, unsigned int, u8);
+
 #include "../NCR5380.h"
 
 #define CTRL   0x16fc
index aed69ac334eb3c0fd577d49af06ebd3b345030a4..f77c311ba5d0907034f286700724577bfdb91975 100644 (file)
@@ -57,6 +57,9 @@
 
 #define NCR5380_implementation_fields   /* none */
 
+static u8 (*atari_scsi_reg_read)(unsigned int);
+static void (*atari_scsi_reg_write)(unsigned int, u8);
+
 #define NCR5380_read(reg)               atari_scsi_reg_read(reg)
 #define NCR5380_write(reg, value)       atari_scsi_reg_write(reg, value)
 
@@ -126,9 +129,6 @@ static inline unsigned long SCSI_DMA_GETADR(void)
 
 static void atari_scsi_fetch_restbytes(void);
 
-static u8 (*atari_scsi_reg_read)(unsigned int);
-static void (*atari_scsi_reg_write)(unsigned int, u8);
-
 static unsigned long   atari_dma_residual, atari_dma_startaddr;
 static short           atari_dma_active;
 /* pointer to the dribble buffer */