[PATCH 08/12] scsi/ncr5380: Use correct types for device register accessors

2016-10-03 Thread Finn Thain
For timeout values adopt unsigned long, which is the type of jiffies etc.

For chip register values and bit masks pass u8, which is the return type
of readb, inb etc.

For device register offsets adopt unsigned int, as it is suitable for
adding to base addresses.

Pass the NCR5380_hostdata pointer to the board-specific routines instead
of the Scsi_Host pointer. The board-specific code is concerned with
hardware and not with SCSI protocol or the mid-layer.

Signed-off-by: Finn Thain 
---
 drivers/scsi/NCR5380.c  | 10 --
 drivers/scsi/NCR5380.h  |  7 +--
 drivers/scsi/arm/cumana_1.c | 20 +++-
 drivers/scsi/arm/oak.c  |  6 ++
 drivers/scsi/atari_scsi.c   | 16 
 drivers/scsi/dmx3191d.c |  6 ++
 drivers/scsi/g_NCR5380.h|  8 ++--
 drivers/scsi/mac_scsi.c | 22 ++
 drivers/scsi/sun3_scsi.c| 32 +---
 9 files changed, 49 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 68092f7..8e11ab7 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -196,8 +196,9 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
  */
 
 static int NCR5380_poll_politely2(struct Scsi_Host *instance,
-  int reg1, int bit1, int val1,
-  int reg2, int bit2, int val2, int wait)
+  unsigned int reg1, u8 bit1, u8 val1,
+  unsigned int reg2, u8 bit2, u8 val2,
+  unsigned long wait)
 {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned long n = hostdata->poll_loops;
@@ -284,6 +285,7 @@ mrs[] = {
 
 static void NCR5380_print(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status, data, basr, mr, icr, i;
 
data = NCR5380_read(CURRENT_SCSI_DATA_REG);
@@ -333,6 +335,7 @@ static struct {
 
 static void NCR5380_print_phase(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status;
int i;
 
@@ -1316,6 +1319,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host 
*instance,
unsigned char *phase, int *count,
unsigned char **data)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char p = *phase, tmp;
int c = *count;
unsigned char *d = *data;
@@ -1438,6 +1442,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host 
*instance,
 
 static void do_reset(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata __maybe_unused *hostdata = shost_priv(instance);
unsigned long flags;
 
local_irq_save(flags);
@@ -1460,6 +1465,7 @@ static void do_reset(struct Scsi_Host *instance)
 
 static int do_abort(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char *msgptr, phase, tmp;
int len;
int rc;
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 5441970..79f8add 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -302,10 +302,13 @@ static void NCR5380_reselect(struct Scsi_Host *instance);
 static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *, struct scsi_cmnd 
*);
 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char 
*phase, int *count, unsigned char **data);
 static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char 
*phase, int *count, unsigned char **data);
-static int NCR5380_poll_politely2(struct Scsi_Host *, int, int, int, int, int, 
int, int);
+static int NCR5380_poll_politely2(struct Scsi_Host *,
+  unsigned int, u8, u8,
+  unsigned int, u8, u8, unsigned long);
 
 static inline int NCR5380_poll_politely(struct Scsi_Host *instance,
-int reg, int bit, int val, int wait)
+unsigned int reg, u8 bit, u8 val,
+unsigned long wait)
 {
return NCR5380_poll_politely2(instance, reg, bit, val,
reg, bit, val, wait);
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c
index 88db281..ae1d4c6 100644
--- a/drivers/scsi/arm/cumana_1.c
+++ b/drivers/scsi/arm/cumana_1.c
@@ -14,8 +14,8 @@
 #include 
 
 #define priv(host) ((struct NCR5380_hostdata 
*)(host)->hostdata)
-#define NCR5380_read(reg)  cumanascsi_read(instance, reg)
-#define NCR5380_write(reg, value)  cumanascsi_write(instance, reg, value)
+#define NCR5380_read(reg)  cumanascsi_read(hostdata, reg)
+#define NCR5380_write(reg, value)  cumanascsi_write(hostdata, reg, value)
 

[PATCH 08/12] scsi/ncr5380: Use correct types for device register accessors

2016-10-03 Thread Finn Thain
For timeout values adopt unsigned long, which is the type of jiffies etc.

For chip register values and bit masks pass u8, which is the return type
of readb, inb etc.

For device register offsets adopt unsigned int, as it is suitable for
adding to base addresses.

Pass the NCR5380_hostdata pointer to the board-specific routines instead
of the Scsi_Host pointer. The board-specific code is concerned with
hardware and not with SCSI protocol or the mid-layer.

Signed-off-by: Finn Thain 
---
 drivers/scsi/NCR5380.c  | 10 --
 drivers/scsi/NCR5380.h  |  7 +--
 drivers/scsi/arm/cumana_1.c | 20 +++-
 drivers/scsi/arm/oak.c  |  6 ++
 drivers/scsi/atari_scsi.c   | 16 
 drivers/scsi/dmx3191d.c |  6 ++
 drivers/scsi/g_NCR5380.h|  8 ++--
 drivers/scsi/mac_scsi.c | 22 ++
 drivers/scsi/sun3_scsi.c| 32 +---
 9 files changed, 49 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 68092f7..8e11ab7 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -196,8 +196,9 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
  */
 
 static int NCR5380_poll_politely2(struct Scsi_Host *instance,
-  int reg1, int bit1, int val1,
-  int reg2, int bit2, int val2, int wait)
+  unsigned int reg1, u8 bit1, u8 val1,
+  unsigned int reg2, u8 bit2, u8 val2,
+  unsigned long wait)
 {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned long n = hostdata->poll_loops;
@@ -284,6 +285,7 @@ mrs[] = {
 
 static void NCR5380_print(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status, data, basr, mr, icr, i;
 
data = NCR5380_read(CURRENT_SCSI_DATA_REG);
@@ -333,6 +335,7 @@ static struct {
 
 static void NCR5380_print_phase(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status;
int i;
 
@@ -1316,6 +1319,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host 
*instance,
unsigned char *phase, int *count,
unsigned char **data)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char p = *phase, tmp;
int c = *count;
unsigned char *d = *data;
@@ -1438,6 +1442,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host 
*instance,
 
 static void do_reset(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata __maybe_unused *hostdata = shost_priv(instance);
unsigned long flags;
 
local_irq_save(flags);
@@ -1460,6 +1465,7 @@ static void do_reset(struct Scsi_Host *instance)
 
 static int do_abort(struct Scsi_Host *instance)
 {
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char *msgptr, phase, tmp;
int len;
int rc;
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 5441970..79f8add 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -302,10 +302,13 @@ static void NCR5380_reselect(struct Scsi_Host *instance);
 static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *, struct scsi_cmnd 
*);
 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char 
*phase, int *count, unsigned char **data);
 static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char 
*phase, int *count, unsigned char **data);
-static int NCR5380_poll_politely2(struct Scsi_Host *, int, int, int, int, int, 
int, int);
+static int NCR5380_poll_politely2(struct Scsi_Host *,
+  unsigned int, u8, u8,
+  unsigned int, u8, u8, unsigned long);
 
 static inline int NCR5380_poll_politely(struct Scsi_Host *instance,
-int reg, int bit, int val, int wait)
+unsigned int reg, u8 bit, u8 val,
+unsigned long wait)
 {
return NCR5380_poll_politely2(instance, reg, bit, val,
reg, bit, val, wait);
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c
index 88db281..ae1d4c6 100644
--- a/drivers/scsi/arm/cumana_1.c
+++ b/drivers/scsi/arm/cumana_1.c
@@ -14,8 +14,8 @@
 #include 
 
 #define priv(host) ((struct NCR5380_hostdata 
*)(host)->hostdata)
-#define NCR5380_read(reg)  cumanascsi_read(instance, reg)
-#define NCR5380_write(reg, value)  cumanascsi_write(instance, reg, value)
+#define NCR5380_read(reg)  cumanascsi_read(hostdata, reg)
+#define NCR5380_write(reg, value)  cumanascsi_write(hostdata, reg, value)
 
 #define