Commit 52c3d8a6 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by James Bottomley

[SCSI] gvp11: Use shost_priv() and kill ugly HDATA() macro

Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 6d1d5d43
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base)) #define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base))
#define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
static irqreturn_t gvp11_intr(int irq, void *_instance) static irqreturn_t gvp11_intr(int irq, void *_instance)
{ {
...@@ -50,70 +49,66 @@ void gvp11_setup(char *str, int *ints) ...@@ -50,70 +49,66 @@ void gvp11_setup(char *str, int *ints)
static int dma_setup(struct scsi_cmnd *cmd, int dir_in) static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
{ {
struct Scsi_Host *instance = cmd->device->host;
struct WD33C93_hostdata *hdata = shost_priv(instance);
unsigned short cntr = GVP11_DMAC_INT_ENABLE; unsigned short cntr = GVP11_DMAC_INT_ENABLE;
unsigned long addr = virt_to_bus(cmd->SCp.ptr); unsigned long addr = virt_to_bus(cmd->SCp.ptr);
int bank_mask; int bank_mask;
static int scsi_alloc_out_of_range = 0; static int scsi_alloc_out_of_range = 0;
/* use bounce buffer if the physical address is bad */ /* use bounce buffer if the physical address is bad */
if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { if (addr & hdata->dma_xfer_mask) {
HDATA(cmd->device->host)->dma_bounce_len = hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff;
(cmd->SCp.this_residual + 511) & ~0x1ff;
if (!scsi_alloc_out_of_range) { if (!scsi_alloc_out_of_range) {
HDATA(cmd->device->host)->dma_bounce_buffer = hdata->dma_bounce_buffer =
kmalloc(HDATA(cmd->device->host)->dma_bounce_len, kmalloc(hdata->dma_bounce_len, GFP_KERNEL);
GFP_KERNEL); hdata->dma_buffer_pool = BUF_SCSI_ALLOCED;
HDATA(cmd->device->host)->dma_buffer_pool =
BUF_SCSI_ALLOCED;
} }
if (scsi_alloc_out_of_range || if (scsi_alloc_out_of_range ||
!HDATA(cmd->device->host)->dma_bounce_buffer) { !hdata->dma_bounce_buffer) {
HDATA(cmd->device->host)->dma_bounce_buffer = hdata->dma_bounce_buffer =
amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, amiga_chip_alloc(hdata->dma_bounce_len,
"GVP II SCSI Bounce Buffer"); "GVP II SCSI Bounce Buffer");
if (!HDATA(cmd->device->host)->dma_bounce_buffer) { if (!hdata->dma_bounce_buffer) {
HDATA(cmd->device->host)->dma_bounce_len = 0; hdata->dma_bounce_len = 0;
return 1; return 1;
} }
HDATA(cmd->device->host)->dma_buffer_pool = hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
BUF_CHIP_ALLOCED;
} }
/* check if the address of the bounce buffer is OK */ /* check if the address of the bounce buffer is OK */
addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); addr = virt_to_bus(hdata->dma_bounce_buffer);
if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { if (addr & hdata->dma_xfer_mask) {
/* fall back to Chip RAM if address out of range */ /* fall back to Chip RAM if address out of range */
if (HDATA(cmd->device->host)->dma_buffer_pool == if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) {
BUF_SCSI_ALLOCED) { kfree(hdata->dma_bounce_buffer);
kfree(HDATA(cmd->device->host)->dma_bounce_buffer);
scsi_alloc_out_of_range = 1; scsi_alloc_out_of_range = 1;
} else { } else {
amiga_chip_free(HDATA(cmd->device->host)->dma_bounce_buffer); amiga_chip_free(hdata->dma_bounce_buffer);
} }
HDATA(cmd->device->host)->dma_bounce_buffer = hdata->dma_bounce_buffer =
amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, amiga_chip_alloc(hdata->dma_bounce_len,
"GVP II SCSI Bounce Buffer"); "GVP II SCSI Bounce Buffer");
if (!HDATA(cmd->device->host)->dma_bounce_buffer) { if (!hdata->dma_bounce_buffer) {
HDATA(cmd->device->host)->dma_bounce_len = 0; hdata->dma_bounce_len = 0;
return 1; return 1;
} }
addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); addr = virt_to_bus(hdata->dma_bounce_buffer);
HDATA(cmd->device->host)->dma_buffer_pool = hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
BUF_CHIP_ALLOCED;
} }
if (!dir_in) { if (!dir_in) {
/* copy to bounce buffer for a write */ /* copy to bounce buffer for a write */
memcpy(HDATA(cmd->device->host)->dma_bounce_buffer, memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr,
cmd->SCp.ptr, cmd->SCp.this_residual); cmd->SCp.this_residual);
} }
} }
...@@ -121,7 +116,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) ...@@ -121,7 +116,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
if (!dir_in) if (!dir_in)
cntr |= GVP11_DMAC_DIR_WRITE; cntr |= GVP11_DMAC_DIR_WRITE;
HDATA(cmd->device->host)->dma_dir = dir_in; hdata->dma_dir = dir_in;
DMA(cmd->device->host)->CNTR = cntr; DMA(cmd->device->host)->CNTR = cntr;
/* setup DMA *physical* address */ /* setup DMA *physical* address */
...@@ -135,7 +130,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) ...@@ -135,7 +130,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
cache_push(addr, cmd->SCp.this_residual); cache_push(addr, cmd->SCp.this_residual);
} }
if ((bank_mask = (~HDATA(cmd->device->host)->dma_xfer_mask >> 18) & 0x01c0)) bank_mask = (~hdata->dma_xfer_mask >> 18) & 0x01c0;
if (bank_mask)
DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18); DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18);
/* start DMA */ /* start DMA */
...@@ -148,25 +144,26 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) ...@@ -148,25 +144,26 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
int status) int status)
{ {
struct WD33C93_hostdata *hdata = shost_priv(instance);
/* stop DMA */ /* stop DMA */
DMA(instance)->SP_DMA = 1; DMA(instance)->SP_DMA = 1;
/* remove write bit from CONTROL bits */ /* remove write bit from CONTROL bits */
DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
/* copy from a bounce buffer, if necessary */ /* copy from a bounce buffer, if necessary */
if (status && HDATA(instance)->dma_bounce_buffer) { if (status && hdata->dma_bounce_buffer) {
if (HDATA(instance)->dma_dir && SCpnt) if (hdata->dma_dir && SCpnt)
memcpy(SCpnt->SCp.ptr, memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer,
HDATA(instance)->dma_bounce_buffer,
SCpnt->SCp.this_residual); SCpnt->SCp.this_residual);
if (HDATA(instance)->dma_buffer_pool == BUF_SCSI_ALLOCED) if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED)
kfree(HDATA(instance)->dma_bounce_buffer); kfree(hdata->dma_bounce_buffer);
else else
amiga_chip_free(HDATA(instance)->dma_bounce_buffer); amiga_chip_free(hdata->dma_bounce_buffer);
HDATA(instance)->dma_bounce_buffer = NULL; hdata->dma_bounce_buffer = NULL;
HDATA(instance)->dma_bounce_len = 0; hdata->dma_bounce_len = 0;
} }
} }
...@@ -180,6 +177,7 @@ int __init gvp11_detect(struct scsi_host_template *tpnt) ...@@ -180,6 +177,7 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
unsigned int epc; unsigned int epc;
struct zorro_dev *z = NULL; struct zorro_dev *z = NULL;
unsigned int default_dma_xfer_mask; unsigned int default_dma_xfer_mask;
struct WD33C93_hostdata *hdata;
wd33c93_regs regs; wd33c93_regs regs;
int num_gvp11 = 0; int num_gvp11 = 0;
#ifdef CHECK_WD33C93 #ifdef CHECK_WD33C93
...@@ -306,10 +304,11 @@ int __init gvp11_detect(struct scsi_host_template *tpnt) ...@@ -306,10 +304,11 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
instance->irq = IRQ_AMIGA_PORTS; instance->irq = IRQ_AMIGA_PORTS;
instance->unique_id = z->slotaddr; instance->unique_id = z->slotaddr;
hdata = shost_priv(instance);
if (gvp11_xfer_mask) if (gvp11_xfer_mask)
HDATA(instance)->dma_xfer_mask = gvp11_xfer_mask; hdata->dma_xfer_mask = gvp11_xfer_mask;
else else
HDATA(instance)->dma_xfer_mask = default_dma_xfer_mask; hdata->dma_xfer_mask = default_dma_xfer_mask;
DMA(instance)->secret2 = 1; DMA(instance)->secret2 = 1;
DMA(instance)->secret1 = 0; DMA(instance)->secret1 = 0;
...@@ -327,9 +326,9 @@ int __init gvp11_detect(struct scsi_host_template *tpnt) ...@@ -327,9 +326,9 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
*/ */
regs.SASR = &(DMA(instance)->SASR); regs.SASR = &(DMA(instance)->SASR);
regs.SCMD = &(DMA(instance)->SCMD); regs.SCMD = &(DMA(instance)->SCMD);
HDATA(instance)->no_sync = 0xff; hdata->no_sync = 0xff;
HDATA(instance)->fast = 0; hdata->fast = 0;
HDATA(instance)->dma_mode = CTRL_DMA; hdata->dma_mode = CTRL_DMA;
wd33c93_init(instance, regs, dma_setup, dma_stop, wd33c93_init(instance, regs, dma_setup, dma_stop,
(epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
: WD33C93_FS_12_15); : WD33C93_FS_12_15);
......
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