summaryrefslogtreecommitdiff
path: root/sys/dev/ic/ami.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2005-09-21 10:54:38 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2005-09-21 10:54:38 +0000
commit8d1fa756e4d1e0e11c92da78455bfc407dbae480 (patch)
tree1b42a2ac0bd6a980bdef9e2b517332a644e187b7 /sys/dev/ic/ami.c
parent2a3f9392f60ea1239ccfde2bf478d69d061b6169 (diff)
fix ami_drv_inq so it uses ami_cmd's ability to use an arbitrary kernel
buffer for passthrough io rather than setting its own up.
Diffstat (limited to 'sys/dev/ic/ami.c')
-rw-r--r--sys/dev/ic/ami.c90
1 files changed, 32 insertions, 58 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c
index 7606fe0bc69..bae89caed7c 100644
--- a/sys/dev/ic/ami.c
+++ b/sys/dev/ic/ami.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ami.c,v 1.82 2005/09/21 10:36:14 dlg Exp $ */
+/* $OpenBSD: ami.c,v 1.83 2005/09/21 10:54:37 dlg Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -1738,82 +1738,56 @@ ami_drv_inq(sc, ch, tg, page, inqbuf)
void *inqbuf;
{
struct ami_ccb *ccb;
- struct ami_iocmd *cmd;
- struct ami_passthrough *ps;
- struct scsi_inquiry_data *pp;
- void *idata;
- bus_dmamap_t idatamap;
- bus_dma_segment_t idataseg[1];
- paddr_t pa;
- int error = 0;
+ struct ami_passthrough *pt;
+ struct scsi_inquiry_data *inq = inqbuf;
ccb = ami_get_ccb(sc);
if (ccb == NULL)
return (ENOMEM);
- if (!(idata = ami_allocmem(sc->dmat, &idatamap, idataseg, NBPG, 1,
- "ami mgmt"))) {
- ami_put_ccb(ccb);
- return (ENOMEM);
- }
-
- pa = idataseg[0].ds_addr;
- ps = idata;
- pp = idata + sizeof *ps;
-
- ccb->ccb_data = NULL;
ccb->ccb_wakeup = 1;
- cmd = ccb->ccb_cmd;
+ ccb->ccb_data = inqbuf;
+ ccb->ccb_len = sizeof(struct scsi_inquiry_data);
+ ccb->ccb_dir = AMI_CCB_IN;
- cmd->acc_cmd = AMI_PASSTHRU;
- cmd->acc_passthru.apt_data = htole32(pa);
+ ccb->ccb_cmd->acc_cmd = AMI_PASSTHRU;
- memset(ps, 0, sizeof *ps);
+ pt = ccb->ccb_pt;
- ps->apt_channel = ch;
- ps->apt_target = tg;
- ps->apt_ncdb = sizeof(struct scsi_inquiry);
- ps->apt_nsense = sizeof(struct scsi_sense_data);
+ memset(pt, 0, sizeof(struct ami_passthrough));
+ pt->apt_channel = ch;
+ pt->apt_target = tg;
+ pt->apt_ncdb = sizeof(struct scsi_inquiry);
+ pt->apt_nsense = sizeof(struct scsi_sense_data);
+ pt->apt_datalen = sizeof(struct scsi_inquiry_data);
- ps->apt_cdb[0] = INQUIRY;
- ps->apt_cdb[1] = 0;
- ps->apt_cdb[2] = 0;
- ps->apt_cdb[3] = 0;
- ps->apt_cdb[4] = sizeof(struct scsi_inquiry_data); /* INQUIRY length */
- ps->apt_cdb[5] = 0;
+ pt->apt_cdb[0] = INQUIRY;
+ pt->apt_cdb[1] = 0;
+ pt->apt_cdb[2] = 0;
+ pt->apt_cdb[3] = 0;
+ pt->apt_cdb[4] = sizeof(struct scsi_inquiry_data); /* INQUIRY length */
+ pt->apt_cdb[5] = 0;
if (page != 0) {
- ps->apt_cdb[1] = SI_EVPD;
- ps->apt_cdb[2] = page;
+ pt->apt_cdb[1] = SI_EVPD;
+ pt->apt_cdb[2] = page;
}
- ps->apt_data = htole32(pa + sizeof *ps);
- ps->apt_datalen = sizeof(struct scsi_inquiry_data);
+ if (ami_cmd(ccb, BUS_DMA_WAITOK, 0) != 0)
+ return (EIO);
- if (ami_cmd(ccb, BUS_DMA_WAITOK, 0) == 0) {
- while (ccb->ccb_wakeup)
- tsleep(ccb, PRIBIO, "ami_drv_inq", 0);
-
- ami_put_ccb(ccb);
+ while (ccb->ccb_wakeup)
+ tsleep(ccb, PRIBIO, "ami_drv_inq", 0);
- if (ps->apt_scsistat == 0x00) {
- memcpy(inqbuf, pp, sizeof(struct scsi_inquiry_data));
+ ami_put_ccb(ccb);
- if (pp->device != T_DIRECT)
- error = EINVAL;
+ if (pt->apt_scsistat != 0x00)
+ return (EIO);
- goto bail;
- }
-
- error = EINVAL;
- }
- else
- error = EINVAL;
-
-bail:
- ami_freemem(idata, sc->dmat, &idatamap, idataseg, NBPG, 1, "ami mgmt");
+ if ((inq->device & SID_TYPE) != T_DIRECT)
+ return (EINVAL);
- return (error);
+ return (0);
}
int