drivers/scsi/mac_scsi.c

Source file repositories/reference/linux-study-clean/drivers/scsi/mac_scsi.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/mac_scsi.c
Extension
.c
Size
15748 bytes
Lines
561
Domain
Driver Families
Bucket
drivers/scsi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (bytes > 0) {
			d += bytes;
			hostdata->pdma_residual -= bytes;
		}

		if (hostdata->pdma_residual == 0)
			break;

		if (bytes > 0)
			continue;

		NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
		dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
			 "%s: bus error [%d/%d] (%d/%d)\n",
			 __func__, d - dst, len, bytes, chunk_bytes);

		if (bytes == 0)
			continue;

		if (macscsi_wait_for_drq(hostdata) <= 0)
			set_host_byte(hostdata->connected, DID_ERROR);
		break;
	}

	return 0;
}

static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
                                 unsigned char *src, int len)
{
	unsigned char *s = src;
	u8 __iomem *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4);

	hostdata->pdma_residual = len;

	while (macscsi_wait_for_drq(hostdata) == 0) {
		int bytes, chunk_bytes;

		if (macintosh_config->ident == MAC_MODEL_IIFX)
			write_ctrl_reg(hostdata, CTRL_HANDSHAKE_MODE |
			                         CTRL_INTERRUPTS_ENABLE);

		chunk_bytes = min(hostdata->pdma_residual, 512);
		bytes = mac_pdma_send(s, d, chunk_bytes);

		if (macintosh_config->ident == MAC_MODEL_IIFX)
			write_ctrl_reg(hostdata, CTRL_INTERRUPTS_ENABLE);

		if (bytes > 0) {
			s += bytes;
			hostdata->pdma_residual -= bytes;
		}

		if (hostdata->pdma_residual == 0)
			break;

		if (bytes > 0)
			continue;

		NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
		dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
			 "%s: bus error [%d/%d] (%d/%d)\n",
			 __func__, s - src, len, bytes, chunk_bytes);

		if (bytes == 0)
			continue;

		if (macscsi_wait_for_drq(hostdata) <= 0)
			set_host_byte(hostdata->connected, DID_ERROR);
		break;
	}

	return 0;
}

static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
                                struct scsi_cmnd *cmd)
{
	int resid = NCR5380_to_ncmd(cmd)->this_residual;

	if (hostdata->flags & FLAG_NO_PSEUDO_DMA || resid < setup_use_pdma)
		return 0;

	return resid;
}

static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata)
{
	return hostdata->pdma_residual;
}

Annotation

Implementation Notes