static int macscsi_pwrite (struct Scsi_Host *instance, unsigned char *src, int len) { unsigned char *s; volatile unsigned char *d; NCR5380_local_declare(); NCR5380_setup(instance); s = src; d = mac_scsi_drq; /* These conditions are derived from MacOS */ while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && (!(NCR5380_read(STATUS_REG) & SR_REQ) || (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) ; if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) { printk(KERN_ERR "Error in macscsi_pwrite\n"); return -1; } CP_MEM_TO_IO(s, d, len); if (len != 0) { printk(KERN_NOTICE "Bus error in macscsi_pwrite\n"); return -1; } return 0; }
static int macscsi_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) { struct NCR5380_hostdata *hostdata = shost_priv(instance); unsigned char *s; unsigned char *d; NCR5380_local_declare(); NCR5380_setup(instance); s = src; d = hostdata->pdma_base + (OUTPUT_DATA_REG << 4); /* These conditions are derived from MacOS */ while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && (!(NCR5380_read(STATUS_REG) & SR_REQ) || (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) ; if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) { pr_err("Error in macscsi_pwrite\n"); return -1; } CP_MEM_TO_IO(s, d, len); if (len != 0) { pr_notice("Bus error in macscsi_pwrite\n"); return -1; } return 0; }
static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata, unsigned char *src, int len) { unsigned char *s = src; unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4); int n = len; int transferred; while (!NCR5380_poll_politely(hostdata, BUS_AND_STATUS_REG, BASR_DRQ | BASR_PHASE_MATCH, BASR_DRQ | BASR_PHASE_MATCH, HZ / 64)) { CP_MEM_TO_IO(s, d, n); transferred = s - src - n; hostdata->pdma_residual = len - transferred; /* Target changed phase early? */ if (NCR5380_poll_politely2(hostdata, STATUS_REG, SR_REQ, SR_REQ, BUS_AND_STATUS_REG, BASR_ACK, BASR_ACK, HZ / 64) < 0) scmd_printk(KERN_ERR, hostdata->connected, "%s: !REQ and !ACK\n", __func__); if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) return 0; /* No bus error. */ if (n == 0) { if (NCR5380_poll_politely(hostdata, TARGET_COMMAND_REG, TCR_LAST_BYTE_SENT, TCR_LAST_BYTE_SENT, HZ / 64) < 0) scmd_printk(KERN_ERR, hostdata->connected, "%s: Last Byte Sent timeout\n", __func__); return 0; } dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host, "%s: bus error (%d/%d)\n", __func__, transferred, len); NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); s = src + transferred; n = len - transferred; } scmd_printk(KERN_ERR, hostdata->connected, "%s: phase mismatch or !DRQ\n", __func__); NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); return -1; }