diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-07-22 00:31:07 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-07-22 00:31:07 +0000 |
commit | 7c351f415e435dae95ca2eea23093104d43ad122 (patch) | |
tree | 142edc77e65f3cd89053cd0bfcb1501ab394fbca /sys/scsi/ses.c | |
parent | 32fa5c6fc524bcbf6c862f638be5614530fbab5f (diff) |
Eliminate scsi_scsi_cmd() now that ss(4) is gone and with it the
last bastardized sync and buf call through scsi_scsi_cmd(). Flatten
code to call scsi_xs_sync() directly for all commands.
Airplane typos shaken out by various.
ok dlg@ matthew@ deraadt@
Diffstat (limited to 'sys/scsi/ses.c')
-rw-r--r-- | sys/scsi/ses.c | 131 |
1 files changed, 77 insertions, 54 deletions
diff --git a/sys/scsi/ses.c b/sys/scsi/ses.c index e8d6992d083..b6674ada864 100644 --- a/sys/scsi/ses.c +++ b/sys/scsi/ses.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ses.c,v 1.47 2007/09/16 01:30:24 krw Exp $ */ +/* $OpenBSD: ses.c,v 1.48 2010/07/22 00:31:06 krw Exp $ */ /* * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> @@ -257,45 +257,52 @@ ses_detach(struct device *self, int flags) int ses_read_config(struct ses_softc *sc) { - struct ses_scsi_diag cmd; - int flags; - - u_char *buf, *p; - - struct ses_config_hdr *cfg; - struct ses_enc_hdr *enc; + struct ses_scsi_diag *cmd; + struct ses_config_hdr *cfg; + struct ses_type_desc *tdh, *tdlist; #ifdef SES_DEBUG - struct ses_enc_desc *desc; + struct ses_enc_desc *desc; #endif - struct ses_type_desc *tdh, *tdlist; - - int i, ntypes = 0, nelems = 0; + struct ses_enc_hdr *enc; + struct scsi_xfer *xs; + u_char *buf, *p; + int error, i; + int flags = 0, ntypes = 0, nelems = 0; buf = malloc(SES_BUFLEN, M_DEVBUF, M_NOWAIT | M_ZERO); if (buf == NULL) return (1); - memset(&cmd, 0, sizeof(cmd)); - cmd.opcode = RECEIVE_DIAGNOSTIC; - cmd.flags |= SES_DIAG_PCV; - cmd.pgcode = SES_PAGE_CONFIG; - cmd.length = htobe16(SES_BUFLEN); - flags = SCSI_DATA_IN; -#ifndef SCSIDEBUG - flags |= SCSI_SILENT; -#endif - if (cold) flags |= SCSI_AUTOCONF; - - if (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd, - sizeof(cmd), buf, SES_BUFLEN, 2, 3000, NULL, flags) != 0) { + xs = scsi_xs_get(sc->sc_link, flags | SCSI_DATA_IN | SCSI_SILENT); + if (xs == NULL) { + free(buf, M_DEVBUF); + return (1); + } + xs->cmd->opcode = RECEIVE_DIAGNOSTIC; + xs->cmdlen = sizeof(*cmd); + xs->data = buf; + xs->datalen = SES_BUFLEN; + xs->retries = 2; + xs->timeout = 3000; + + cmd = (struct ses_scsi_diag *)xs->cmd; + cmd->flags |= SES_DIAG_PCV; + cmd->pgcode = SES_PAGE_CONFIG; + cmd->length = htobe16(SES_BUFLEN); + + error = scsi_xs_sync(xs); + scsi_xs_put(xs); + + if (error) { free(buf, M_DEVBUF); return (1); } cfg = (struct ses_config_hdr *)buf; - if (cfg->pgcode != cmd.pgcode || betoh16(cfg->length) > SES_BUFLEN) { + if (cfg->pgcode != cmd->pgcode || betoh16(cfg->length) > + SES_BUFLEN) { free(buf, M_DEVBUF); return (1); } @@ -360,23 +367,31 @@ ses_read_config(struct ses_softc *sc) int ses_read_status(struct ses_softc *sc) { - struct ses_scsi_diag cmd; - int flags; - - memset(&cmd, 0, sizeof(cmd)); - cmd.opcode = RECEIVE_DIAGNOSTIC; - cmd.flags |= SES_DIAG_PCV; - cmd.pgcode = SES_PAGE_STATUS; - cmd.length = htobe16(sc->sc_buflen); - flags = SCSI_DATA_IN; -#ifndef SCSIDEBUG - flags |= SCSI_SILENT; -#endif + struct ses_scsi_diag *cmd; + struct scsi_xfer *xs; + int error, flags = 0; + if (cold) flags |= SCSI_AUTOCONF; - - if (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd, - sizeof(cmd), sc->sc_buf, sc->sc_buflen, 2, 3000, NULL, flags) != 0) + xs = scsi_xs_get(sc->sc_link, flags | SCSI_DATA_IN | SCSI_SILENT); + if (xs == NULL) + return (1); + xs->cmd->opcode = RECEIVE_DIAGNOSTIC; + xs->cmdlen = sizeof(*cmd); + xs->data = sc->sc_buf; + xs->datalen = sc->sc_buflen; + xs->retries = 2; + xs->timeout = 3000; + + cmd = (struct ses_scsi_diag *)xs->cmd; + cmd->flags |= SES_DIAG_PCV; + cmd->pgcode = SES_PAGE_STATUS; + cmd->length = htobe16(sc->sc_buflen); + + error = scsi_xs_sync(xs); + scsi_xs_put(xs); + + if (error != 0) return (1); return (0); @@ -582,23 +597,31 @@ ses_ioctl(struct device *dev, u_long cmd, caddr_t addr) int ses_write_config(struct ses_softc *sc) { - struct ses_scsi_diag cmd; - int flags; - - memset(&cmd, 0, sizeof(cmd)); - cmd.opcode = SEND_DIAGNOSTIC; - cmd.flags |= SES_DIAG_PF; - cmd.length = htobe16(sc->sc_buflen); - flags = SCSI_DATA_OUT; -#ifndef SCSIDEBUG - flags |= SCSI_SILENT; -#endif + struct ses_scsi_diag *cmd; + struct scsi_xfer *xs; + int error, flags = 0; if (cold) flags |= SCSI_AUTOCONF; - if (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd, - sizeof(cmd), sc->sc_buf, sc->sc_buflen, 2, 3000, NULL, flags) != 0) + xs = scsi_xs_get(sc->sc_link, flags | SCSI_DATA_OUT | SCSI_SILENT); + if (xs == NULL) + return (1); + xs->cmd->opcode = SEND_DIAGNOSTIC; + xs->cmdlen = sizeof(*cmd); + xs->data = sc->sc_buf; + xs->datalen = sc->sc_buflen; + xs->retries = 2; + xs->timeout = 3000; + + cmd = (struct ses_scsi_diag *)xs->cmd; + cmd->flags |= SES_DIAG_PF; + cmd->length = htobe16(sc->sc_buflen); + + error = scsi_xs_sync(xs); + scsi_xs_put(xs); + + if (error != 0) return (1); return (0); |