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

scsi: ncr5380: Use correct types for device register accessors

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: default avatarFinn Thain <fthain@telegraphics.com.au>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Tested-by: default avatarOndrej Zary <linux@rainbow-software.org>
Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
Acked-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 820682b1
...@@ -196,8 +196,9 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd) ...@@ -196,8 +196,9 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
*/ */
static int NCR5380_poll_politely2(struct Scsi_Host *instance, static int NCR5380_poll_politely2(struct Scsi_Host *instance,
int reg1, int bit1, int val1, unsigned int reg1, u8 bit1, u8 val1,
int reg2, int bit2, int val2, int wait) unsigned int reg2, u8 bit2, u8 val2,
unsigned long wait)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance); struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned long n = hostdata->poll_loops; unsigned long n = hostdata->poll_loops;
...@@ -284,6 +285,7 @@ mrs[] = { ...@@ -284,6 +285,7 @@ mrs[] = {
static void NCR5380_print(struct Scsi_Host *instance) static void NCR5380_print(struct Scsi_Host *instance)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status, data, basr, mr, icr, i; unsigned char status, data, basr, mr, icr, i;
data = NCR5380_read(CURRENT_SCSI_DATA_REG); data = NCR5380_read(CURRENT_SCSI_DATA_REG);
...@@ -333,6 +335,7 @@ static struct { ...@@ -333,6 +335,7 @@ static struct {
static void NCR5380_print_phase(struct Scsi_Host *instance) static void NCR5380_print_phase(struct Scsi_Host *instance)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char status; unsigned char status;
int i; int i;
...@@ -1316,6 +1319,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance, ...@@ -1316,6 +1319,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance,
unsigned char *phase, int *count, unsigned char *phase, int *count,
unsigned char **data) unsigned char **data)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char p = *phase, tmp; unsigned char p = *phase, tmp;
int c = *count; int c = *count;
unsigned char *d = *data; unsigned char *d = *data;
...@@ -1438,6 +1442,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance, ...@@ -1438,6 +1442,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance,
static void do_reset(struct Scsi_Host *instance) static void do_reset(struct Scsi_Host *instance)
{ {
struct NCR5380_hostdata __maybe_unused *hostdata = shost_priv(instance);
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
...@@ -1460,6 +1465,7 @@ static void do_reset(struct Scsi_Host *instance) ...@@ -1460,6 +1465,7 @@ static void do_reset(struct Scsi_Host *instance)
static int do_abort(struct Scsi_Host *instance) static int do_abort(struct Scsi_Host *instance)
{ {
struct NCR5380_hostdata *hostdata = shost_priv(instance);
unsigned char *msgptr, phase, tmp; unsigned char *msgptr, phase, tmp;
int len; int len;
int rc; int rc;
......
...@@ -302,10 +302,13 @@ static void NCR5380_reselect(struct Scsi_Host *instance); ...@@ -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 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_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_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, 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, return NCR5380_poll_politely2(instance, reg, bit, val,
reg, bit, val, wait); reg, bit, val, wait);
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
#define NCR5380_read(reg) cumanascsi_read(instance, reg) #define NCR5380_read(reg) cumanascsi_read(hostdata, reg)
#define NCR5380_write(reg, value) cumanascsi_write(instance, reg, value) #define NCR5380_write(reg, value) cumanascsi_write(hostdata, reg, value)
#define NCR5380_dma_xfer_len(instance, cmd, phase) (cmd->transfersize) #define NCR5380_dma_xfer_len(instance, cmd, phase) (cmd->transfersize)
#define NCR5380_dma_recv_setup cumanascsi_pread #define NCR5380_dma_recv_setup cumanascsi_pread
...@@ -169,30 +169,32 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, ...@@ -169,30 +169,32 @@ static inline int cumanascsi_pread(struct Scsi_Host *host,
return 0; return 0;
} }
static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg) static u8 cumanascsi_read(struct NCR5380_hostdata *hostdata,
unsigned int reg)
{ {
u8 __iomem *base = priv(host)->io; u8 __iomem *base = hostdata->io;
unsigned char val; u8 val;
writeb(0, base + CTRL); writeb(0, base + CTRL);
val = readb(base + 0x2100 + (reg << 2)); val = readb(base + 0x2100 + (reg << 2));
priv(host)->ctrl = 0x40; hostdata->ctrl = 0x40;
writeb(0x40, base + CTRL); writeb(0x40, base + CTRL);
return val; return val;
} }
static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value) static void cumanascsi_write(struct NCR5380_hostdata *hostdata,
unsigned int reg, u8 value)
{ {
u8 __iomem *base = priv(host)->io; u8 __iomem *base = hostdata->io;
writeb(0, base + CTRL); writeb(0, base + CTRL);
writeb(value, base + 0x2100 + (reg << 2)); writeb(value, base + 0x2100 + (reg << 2));
priv(host)->ctrl = 0x40; hostdata->ctrl = 0x40;
writeb(0x40, base + CTRL); writeb(0x40, base + CTRL);
} }
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
#define NCR5380_read(reg) \ #define NCR5380_read(reg) readb(hostdata->io + ((reg) << 2))
readb(priv(instance)->io + ((reg) << 2)) #define NCR5380_write(reg, value) writeb(value, hostdata->io + ((reg) << 2))
#define NCR5380_write(reg, value) \
writeb(value, priv(instance)->io + ((reg) << 2))
#define NCR5380_dma_xfer_len(instance, cmd, phase) (0) #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
#define NCR5380_dma_recv_setup oakscsi_pread #define NCR5380_dma_recv_setup oakscsi_pread
......
...@@ -126,8 +126,8 @@ static inline unsigned long SCSI_DMA_GETADR(void) ...@@ -126,8 +126,8 @@ static inline unsigned long SCSI_DMA_GETADR(void)
static void atari_scsi_fetch_restbytes(void); static void atari_scsi_fetch_restbytes(void);
static unsigned char (*atari_scsi_reg_read)(unsigned char reg); static u8 (*atari_scsi_reg_read)(unsigned int);
static void (*atari_scsi_reg_write)(unsigned char reg, unsigned char value); static void (*atari_scsi_reg_write)(unsigned int, u8);
static unsigned long atari_dma_residual, atari_dma_startaddr; static unsigned long atari_dma_residual, atari_dma_startaddr;
static short atari_dma_active; static short atari_dma_active;
...@@ -658,30 +658,30 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len, ...@@ -658,30 +658,30 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
* NCR5380_write call these functions via function pointers. * NCR5380_write call these functions via function pointers.
*/ */
static unsigned char atari_scsi_tt_reg_read(unsigned char reg) static u8 atari_scsi_tt_reg_read(unsigned int reg)
{ {
return tt_scsi_regp[reg * 2]; return tt_scsi_regp[reg * 2];
} }
static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value) static void atari_scsi_tt_reg_write(unsigned int reg, u8 value)
{ {
tt_scsi_regp[reg * 2] = value; tt_scsi_regp[reg * 2] = value;
} }
static unsigned char atari_scsi_falcon_reg_read(unsigned char reg) static u8 atari_scsi_falcon_reg_read(unsigned int reg)
{ {
unsigned long flags; unsigned long flags;
unsigned char result; u8 result;
reg += 0x88; reg += 0x88;
local_irq_save(flags); local_irq_save(flags);
dma_wd.dma_mode_status = (u_short)reg; dma_wd.dma_mode_status = (u_short)reg;
result = (u_char)dma_wd.fdc_acces_seccount; result = (u8)dma_wd.fdc_acces_seccount;
local_irq_restore(flags); local_irq_restore(flags);
return result; return result;
} }
static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value) static void atari_scsi_falcon_reg_write(unsigned int reg, u8 value)
{ {
unsigned long flags; unsigned long flags;
......
...@@ -34,10 +34,8 @@ ...@@ -34,10 +34,8 @@
* Definitions for the generic 5380 driver. * Definitions for the generic 5380 driver.
*/ */
#define priv(instance) ((struct NCR5380_hostdata *)shost_priv(instance)) #define NCR5380_read(reg) inb(hostdata->base + (reg))
#define NCR5380_write(reg, value) outb(value, hostdata->base + (reg))
#define NCR5380_read(reg) inb(priv(instance)->base + (reg))
#define NCR5380_write(reg, value) outb(value, priv(instance)->base + (reg))
#define NCR5380_dma_xfer_len(instance, cmd, phase) (0) #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
#define NCR5380_dma_recv_setup(instance, dst, len) (0) #define NCR5380_dma_recv_setup(instance, dst, len) (0)
......
...@@ -17,13 +17,9 @@ ...@@ -17,13 +17,9 @@
#define DRV_MODULE_NAME "g_NCR5380" #define DRV_MODULE_NAME "g_NCR5380"
#define NCR5380_read(reg) \ #define NCR5380_read(reg) \
ioread8(((struct NCR5380_hostdata *)shost_priv(instance))->io + \ ioread8(hostdata->io + hostdata->offset + (reg))
((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
(reg))
#define NCR5380_write(reg, value) \ #define NCR5380_write(reg, value) \
iowrite8(value, ((struct NCR5380_hostdata *)shost_priv(instance))->io + \ iowrite8(value, hostdata->io + hostdata->offset + (reg))
((struct NCR5380_hostdata *)shost_priv(instance))->offset + \
(reg))
#define NCR5380_implementation_fields \ #define NCR5380_implementation_fields \
int offset; \ int offset; \
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#define NCR5380_implementation_fields int pdma_residual #define NCR5380_implementation_fields int pdma_residual
#define NCR5380_read(reg) macscsi_read(instance, reg) #define NCR5380_read(reg) in_8(hostdata->io + ((reg) << 4))
#define NCR5380_write(reg, value) macscsi_write(instance, reg, value) #define NCR5380_write(reg, value) out_8(hostdata->io + ((reg) << 4), value)
#define NCR5380_dma_xfer_len(instance, cmd, phase) \ #define NCR5380_dma_xfer_len(instance, cmd, phase) \
macscsi_dma_xfer_len(instance, cmd) macscsi_dma_xfer_len(instance, cmd)
...@@ -60,24 +60,6 @@ module_param(setup_hostid, int, 0); ...@@ -60,24 +60,6 @@ module_param(setup_hostid, int, 0);
static int setup_toshiba_delay = -1; static int setup_toshiba_delay = -1;
module_param(setup_toshiba_delay, int, 0); module_param(setup_toshiba_delay, int, 0);
/*
* NCR 5380 register access functions
*/
static inline char macscsi_read(struct Scsi_Host *instance, int reg)
{
struct NCR5380_hostdata *hostdata = shost_priv(instance);
return in_8(hostdata->io + (reg << 4));
}
static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value)
{
struct NCR5380_hostdata *hostdata = shost_priv(instance);
out_8(hostdata->io + (reg << 4), value);
}
#ifndef MODULE #ifndef MODULE
static int __init mac_scsi_setup(char *str) static int __init mac_scsi_setup(char *str)
{ {
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#define NCR5380_implementation_fields /* none */ #define NCR5380_implementation_fields /* none */
#define NCR5380_read(reg) sun3scsi_read(reg) #define NCR5380_read(reg) in_8(hostdata->io + (reg))
#define NCR5380_write(reg, value) sun3scsi_write(reg, value) #define NCR5380_write(reg, value) out_8(hostdata->io + (reg), value)
#define NCR5380_queue_command sun3scsi_queue_command #define NCR5380_queue_command sun3scsi_queue_command
#define NCR5380_bus_reset sun3scsi_bus_reset #define NCR5380_bus_reset sun3scsi_bus_reset
...@@ -82,7 +82,6 @@ module_param(setup_hostid, int, 0); ...@@ -82,7 +82,6 @@ module_param(setup_hostid, int, 0);
#define SUN3_DVMA_BUFSIZE 0xe000 #define SUN3_DVMA_BUFSIZE 0xe000
static struct scsi_cmnd *sun3_dma_setup_done; static struct scsi_cmnd *sun3_dma_setup_done;
static unsigned char *sun3_scsi_regp;
static volatile struct sun3_dma_regs *dregs; static volatile struct sun3_dma_regs *dregs;
static struct sun3_udc_regs *udc_regs; static struct sun3_udc_regs *udc_regs;
static unsigned char *sun3_dma_orig_addr; static unsigned char *sun3_dma_orig_addr;
...@@ -90,20 +89,6 @@ static unsigned long sun3_dma_orig_count; ...@@ -90,20 +89,6 @@ 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;
/*
* NCR 5380 register access functions
*/
static inline unsigned char sun3scsi_read(int reg)
{
return in_8(sun3_scsi_regp + reg);
}
static inline void sun3scsi_write(int reg, int value)
{
out_8(sun3_scsi_regp + reg, value);
}
#ifndef SUN3_SCSI_VME #ifndef SUN3_SCSI_VME
/* dma controller register access functions */ /* dma controller register access functions */
...@@ -431,7 +416,7 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -431,7 +416,7 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
struct NCR5380_hostdata *hostdata; struct NCR5380_hostdata *hostdata;
int error; int error;
struct resource *irq, *mem; struct resource *irq, *mem;
unsigned char *ioaddr; void __iomem *ioaddr;
int host_flags = 0; int host_flags = 0;
#ifdef SUN3_SCSI_VME #ifdef SUN3_SCSI_VME
int i; int i;
...@@ -494,8 +479,6 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -494,8 +479,6 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
} }
#endif #endif
sun3_scsi_regp = ioaddr;
instance = scsi_host_alloc(&sun3_scsi_template, instance = scsi_host_alloc(&sun3_scsi_template,
sizeof(struct NCR5380_hostdata)); sizeof(struct NCR5380_hostdata));
if (!instance) { if (!instance) {
...@@ -506,7 +489,8 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -506,7 +489,8 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
instance->irq = irq->start; instance->irq = irq->start;
hostdata = shost_priv(instance); hostdata = shost_priv(instance);
hostdata->base = (unsigned long)ioaddr; hostdata->base = mem->start;
hostdata->io = ioaddr;
error = NCR5380_init(instance, host_flags); error = NCR5380_init(instance, host_flags);
if (error) if (error)
...@@ -555,13 +539,15 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) ...@@ -555,13 +539,15 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)
fail_alloc: fail_alloc:
if (udc_regs) if (udc_regs)
dvma_free(udc_regs); dvma_free(udc_regs);
iounmap(sun3_scsi_regp); iounmap(ioaddr);
return error; return error;
} }
static int __exit sun3_scsi_remove(struct platform_device *pdev) static int __exit sun3_scsi_remove(struct platform_device *pdev)
{ {
struct Scsi_Host *instance = platform_get_drvdata(pdev); struct Scsi_Host *instance = platform_get_drvdata(pdev);
struct NCR5380_hostdata *hostdata = shost_priv(instance);
void __iomem *ioaddr = hostdata->io;
scsi_remove_host(instance); scsi_remove_host(instance);
free_irq(instance->irq, instance); free_irq(instance->irq, instance);
...@@ -569,7 +555,7 @@ static int __exit sun3_scsi_remove(struct platform_device *pdev) ...@@ -569,7 +555,7 @@ static int __exit sun3_scsi_remove(struct platform_device *pdev)
scsi_host_put(instance); scsi_host_put(instance);
if (udc_regs) if (udc_regs)
dvma_free(udc_regs); dvma_free(udc_regs);
iounmap(sun3_scsi_regp); iounmap(ioaddr);
return 0; return 0;
} }
......
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