Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195689
b: refs/heads/master
c: afdbbc1
h: refs/heads/master
i:
  195687: e2becc7
v: v3
  • Loading branch information
Geert Uytterhoeven authored and James Bottomley committed May 2, 2010
1 parent 735e6f2 commit 80aff36
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ce195662bbc063c29294c11a57aa2db182a837ea
refs/heads/master: afdbbc16134ae2eea612b51cab7545938d266dce
53 changes: 28 additions & 25 deletions trunk/drivers/scsi/a3000.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


#define DMA(ptr) ((a3000_scsiregs *)((ptr)->base))
#define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))

static struct Scsi_Host *a3000_host = NULL;

Expand All @@ -48,6 +47,7 @@ static irqreturn_t a3000_intr(int irq, void *dummy)

static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
{
struct WD33C93_hostdata *hdata = shost_priv(a3000_host);
unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
unsigned long addr = virt_to_bus(cmd->SCp.ptr);

Expand All @@ -58,32 +58,31 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
* buffer
*/
if (addr & A3000_XFER_MASK) {
HDATA(a3000_host)->dma_bounce_len =
(cmd->SCp.this_residual + 511) & ~0x1ff;
HDATA(a3000_host)->dma_bounce_buffer =
kmalloc(HDATA(a3000_host)->dma_bounce_len, GFP_KERNEL);
hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff;
hdata->dma_bounce_buffer = kmalloc(hdata->dma_bounce_len,
GFP_KERNEL);

/* can't allocate memory; use PIO */
if (!HDATA(a3000_host)->dma_bounce_buffer) {
HDATA(a3000_host)->dma_bounce_len = 0;
if (!hdata->dma_bounce_buffer) {
hdata->dma_bounce_len = 0;
return 1;
}

if (!dir_in) {
/* copy to bounce buffer for a write */
memcpy(HDATA(a3000_host)->dma_bounce_buffer,
cmd->SCp.ptr, cmd->SCp.this_residual);
memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr,
cmd->SCp.this_residual);
}

addr = virt_to_bus(HDATA(a3000_host)->dma_bounce_buffer);
addr = virt_to_bus(hdata->dma_bounce_buffer);
}

/* setup dma direction */
if (!dir_in)
cntr |= CNTR_DDIR;

/* remember direction */
HDATA(a3000_host)->dma_dir = dir_in;
hdata->dma_dir = dir_in;

DMA(a3000_host)->CNTR = cntr;

Expand All @@ -110,17 +109,19 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
int status)
{
struct WD33C93_hostdata *hdata = shost_priv(instance);

/* disable SCSI interrupts */
unsigned short cntr = CNTR_PDMD;

if (!HDATA(instance)->dma_dir)
if (!hdata->dma_dir)
cntr |= CNTR_DDIR;

DMA(instance)->CNTR = cntr;
mb(); /* make sure CNTR is updated before next IO */

/* flush if we were reading */
if (HDATA(instance)->dma_dir) {
if (hdata->dma_dir) {
DMA(instance)->FLUSH = 1;
mb(); /* don't allow prefetch */
while (!(DMA(instance)->ISTR & ISTR_FE_FLG))
Expand All @@ -143,26 +144,27 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
mb(); /* make sure CNTR is updated before next IO */

/* copy from a bounce buffer, if necessary */
if (status && HDATA(instance)->dma_bounce_buffer) {
if (status && hdata->dma_bounce_buffer) {
if (SCpnt) {
if (HDATA(instance)->dma_dir && SCpnt)
if (hdata->dma_dir && SCpnt)
memcpy(SCpnt->SCp.ptr,
HDATA(instance)->dma_bounce_buffer,
hdata->dma_bounce_buffer,
SCpnt->SCp.this_residual);
kfree(HDATA(instance)->dma_bounce_buffer);
HDATA(instance)->dma_bounce_buffer = NULL;
HDATA(instance)->dma_bounce_len = 0;
kfree(hdata->dma_bounce_buffer);
hdata->dma_bounce_buffer = NULL;
hdata->dma_bounce_len = 0;
} else {
kfree(HDATA(instance)->dma_bounce_buffer);
HDATA(instance)->dma_bounce_buffer = NULL;
HDATA(instance)->dma_bounce_len = 0;
kfree(hdata->dma_bounce_buffer);
hdata->dma_bounce_buffer = NULL;
hdata->dma_bounce_len = 0;
}
}
}

static int __init a3000_detect(struct scsi_host_template *tpnt)
{
wd33c93_regs regs;
struct WD33C93_hostdata *hdata;

if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(A3000_SCSI))
return 0;
Expand All @@ -181,9 +183,10 @@ static int __init a3000_detect(struct scsi_host_template *tpnt)
DMA(a3000_host)->DAWR = DAWR_A3000;
regs.SASR = &(DMA(a3000_host)->SASR);
regs.SCMD = &(DMA(a3000_host)->SCMD);
HDATA(a3000_host)->no_sync = 0xff;
HDATA(a3000_host)->fast = 0;
HDATA(a3000_host)->dma_mode = CTRL_DMA;
hdata = shost_priv(a3000_host);
hdata->no_sync = 0xff;
hdata->fast = 0;
hdata->dma_mode = CTRL_DMA;
wd33c93_init(a3000_host, regs, dma_setup, dma_stop, WD33C93_FS_12_15);
if (request_irq(IRQ_AMIGA_PORTS, a3000_intr, IRQF_SHARED, "A3000 SCSI",
a3000_intr))
Expand Down

0 comments on commit 80aff36

Please sign in to comment.