summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2006-07-11 09:12:55 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2006-07-11 09:12:55 +0000
commitd44ab497f01076aa929f9df01f2a7243c215bf07 (patch)
tree08ddf8eb51658aa39edfece0f33f813fdcd33f1b
parentb01121af3c2761f74f0e8a1edbc52222fbc47239 (diff)
knf and ansi. no binary change
-rw-r--r--sys/scsi/scsi_base.c368
1 files changed, 152 insertions, 216 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index a4ad3b362af..7f77286f8bd 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.104 2006/05/28 17:15:23 beck Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.105 2006/07/11 09:12:54 dlg Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -73,7 +73,7 @@ struct pool scsi_xfer_pool;
void
scsi_init()
{
- static int scsi_init_done;
+ static int scsi_init_done;
if (scsi_init_done)
return;
@@ -101,12 +101,10 @@ scsi_init()
*/
struct scsi_xfer *
-scsi_get_xs(sc_link, flags)
- struct scsi_link *sc_link; /* who to charge the xs to */
- int flags; /* if this call can sleep */
+scsi_get_xs(struct scsi_link *sc_link, int flags)
{
- struct scsi_xfer *xs;
- int s;
+ struct scsi_xfer *xs;
+ int s;
SC_DEBUG(sc_link, SDEV_DB3, ("scsi_get_xs\n"));
@@ -128,7 +126,7 @@ scsi_get_xs(sc_link, flags)
xs = pool_get(&scsi_xfer_pool,
((flags & SCSI_NOSLEEP) != 0 ? PR_NOWAIT : PR_WAITOK));
if (xs != NULL) {
- bzero(xs, sizeof *xs);
+ bzero(xs, sizeof(*xs));
sc_link->openings--;
xs->flags = flags;
} else {
@@ -148,10 +146,9 @@ scsi_get_xs(sc_link, flags)
* If another process is waiting for an xs, do a wakeup, let it proceed
*/
void
-scsi_free_xs(xs)
- struct scsi_xfer *xs;
+scsi_free_xs(struct scsi_xfer *xs)
{
- struct scsi_link *sc_link = xs->sc_link;
+ struct scsi_link *sc_link = xs->sc_link;
splassert(IPL_BIO);
@@ -177,22 +174,14 @@ scsi_free_xs(xs)
* Make a scsi_xfer, and return a pointer to it.
*/
static __inline struct scsi_xfer *
-scsi_make_xs(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
- retries, timeout, bp, flags)
- struct scsi_link *sc_link;
- struct scsi_generic *scsi_cmd;
- int cmdlen;
- u_char *data_addr;
- int datalen;
- int retries;
- int timeout;
- struct buf *bp;
- int flags;
+scsi_make_xs(struct scsi_link *sc_link, struct scsi_generic *scsi_cmd,
+ int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
+ struct buf *bp, int flags)
{
- struct scsi_xfer *xs;
+ struct scsi_xfer *xs;
if ((xs = scsi_get_xs(sc_link, flags)) == NULL)
- return NULL;
+ return (NULL);
/*
* Fill out the scsi_xfer structure. We don't know whose context
@@ -221,29 +210,25 @@ scsi_make_xs(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
xs->cmd->bytes[0] |=
((sc_link->lun << SCSI_CMD_LUN_SHIFT) & SCSI_CMD_LUN_MASK);
- return xs;
+ return (xs);
}
/*
* Find out from the device what its capacity is.
*/
u_long
-scsi_size(sc_link, flags, blksize)
- struct scsi_link *sc_link;
- int flags;
- u_int32_t *blksize;
+scsi_size(struct scsi_link *sc_link, int flags, u_int32_t *blksize)
{
- struct scsi_read_capacity scsi_cmd;
- struct scsi_read_cap_data rdcap;
- u_long max_addr;
- int error;
+ struct scsi_read_capacity scsi_cmd;
+ struct scsi_read_cap_data rdcap;
+ u_long max_addr;
+ int error;
- if (blksize)
+ if (blksize != NULL)
*blksize = 0;
/*
- * make up a scsi command and ask the scsi driver to do
- * it for you.
+ * make up a scsi command and ask the scsi driver to do it for you.
*/
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = READ_CAPACITY;
@@ -262,7 +247,7 @@ scsi_size(sc_link, flags, blksize)
}
max_addr = _4btol(rdcap.addr);
- if (blksize)
+ if (blksize != NULL)
*blksize = _4btol(rdcap.length);
if (max_addr == 0xffffffffUL) {
@@ -283,21 +268,18 @@ scsi_size(sc_link, flags, blksize)
* Get scsi driver to send a "are you ready?" command
*/
int
-scsi_test_unit_ready(sc_link, retries, flags)
- struct scsi_link *sc_link;
- int retries;
- int flags;
+scsi_test_unit_ready(struct scsi_link *sc_link, int retries, int flags)
{
- struct scsi_test_unit_ready scsi_cmd;
+ struct scsi_test_unit_ready scsi_cmd;
if (sc_link->quirks & ADEV_NOTUR)
- return 0;
+ return (0);
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = TEST_UNIT_READY;
- return scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), 0, 0, retries, 10000, NULL, flags);
+ return (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
+ sizeof(scsi_cmd), 0, 0, retries, 10000, NULL, flags));
}
/*
@@ -305,18 +287,16 @@ scsi_test_unit_ready(sc_link, retries, flags)
* Use the scsi_cmd routine in the switch table.
*/
int
-scsi_inquire(sc_link, inqbuf, flags)
- struct scsi_link *sc_link;
- struct scsi_inquiry_data *inqbuf;
- int flags;
+scsi_inquire(struct scsi_link *sc_link, struct scsi_inquiry_data *inqbuf,
+ int flags)
{
- struct scsi_inquiry scsi_cmd;
- int error;
+ struct scsi_inquiry scsi_cmd;
+ int error;
- bzero(&scsi_cmd, sizeof scsi_cmd);
+ bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = INQUIRY;
- bzero(inqbuf, sizeof *inqbuf);
+ bzero(inqbuf, sizeof(*inqbuf));
memset(&inqbuf->vendor, ' ', sizeof inqbuf->vendor);
memset(&inqbuf->product, ' ', sizeof inqbuf->product);
@@ -339,50 +319,45 @@ scsi_inquire(sc_link, inqbuf, flags)
* Prevent or allow the user to remove the media
*/
int
-scsi_prevent(sc_link, type, flags)
- struct scsi_link *sc_link;
- int type, flags;
+scsi_prevent(struct scsi_link *sc_link, int type, int flags)
{
- struct scsi_prevent scsi_cmd;
+ struct scsi_prevent scsi_cmd;
if (sc_link->quirks & ADEV_NODOORLOCK)
- return 0;
+ return (0);
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PREVENT_ALLOW;
scsi_cmd.how = type;
- return scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), 0, 0, 2, 5000, NULL, flags);
+
+ return (scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,
+ sizeof(scsi_cmd), 0, 0, 2, 5000, NULL, flags));
}
/*
* Get scsi driver to send a "start up" command
*/
int
-scsi_start(sc_link, type, flags)
- struct scsi_link *sc_link;
- int type, flags;
+scsi_start(struct scsi_link *sc_link, int type, int flags)
{
- struct scsi_start_stop scsi_cmd;
+ struct scsi_start_stop scsi_cmd;
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = START_STOP;
scsi_cmd.byte2 = 0x00;
scsi_cmd.how = type;
- return scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
+
+ return (scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, 2,
- type == SSS_START ? 30000 : 10000, NULL, flags);
+ type == SSS_START ? 30000 : 10000, NULL, flags));
}
int
-scsi_mode_sense(sc_link, byte2, page, data, len, flags, timeout)
- struct scsi_link *sc_link;
- int byte2, page, flags, timeout;
- size_t len;
- struct scsi_mode_header *data;
+scsi_mode_sense(struct scsi_link *sc_link, int byte2, int page,
+ struct scsi_mode_header *data, size_t len, int flags, int timeout)
{
- struct scsi_mode_sense scsi_cmd;
- int error;
+ struct scsi_mode_sense scsi_cmd;
+ int error;
/*
* Make sure the sense buffer is clean before we do the mode sense, so
@@ -411,14 +386,11 @@ scsi_mode_sense(sc_link, byte2, page, data, len, flags, timeout)
}
int
-scsi_mode_sense_big(sc_link, byte2, page, data, len, flags, timeout)
- struct scsi_link *sc_link;
- int byte2, page, flags, timeout;
- size_t len;
- struct scsi_mode_header_big *data;
+scsi_mode_sense_big(struct scsi_link *sc_link, int byte2, int page,
+ struct scsi_mode_header_big *data, size_t len, int flags, int timeout)
{
- struct scsi_mode_sense_big scsi_cmd;
- int error;
+ struct scsi_mode_sense_big scsi_cmd;
+ int error;
/*
* Make sure the sense buffer is clean before we do the mode sense, so
@@ -447,11 +419,9 @@ scsi_mode_sense_big(sc_link, byte2, page, data, len, flags, timeout)
}
void *
-scsi_mode_sense_page(hdr, page_len)
- struct scsi_mode_header *hdr;
- const int page_len;
+scsi_mode_sense_page(struct scsi_mode_header *hdr, const int page_len)
{
- int total_length, header_length;
+ int total_length, header_length;
total_length = hdr->data_length + sizeof(hdr->data_length);
header_length = sizeof(*hdr) + hdr->blk_desc_len;
@@ -463,11 +433,9 @@ scsi_mode_sense_page(hdr, page_len)
}
void *
-scsi_mode_sense_big_page(hdr, page_len)
- struct scsi_mode_header_big *hdr;
- const int page_len;
+scsi_mode_sense_big_page(struct scsi_mode_header_big *hdr, const int page_len)
{
- int total_length, header_length;
+ int total_length, header_length;
total_length = _2btol(hdr->data_length) + sizeof(hdr->data_length);
header_length = sizeof(*hdr) + _2btol(hdr->blk_desc_len);
@@ -479,28 +447,24 @@ scsi_mode_sense_big_page(hdr, page_len)
}
int
-scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
- block_size, page_len, flags, big)
- struct scsi_link *sc_link;
- union scsi_mode_sense_buf *buf;
- int page, page_len, flags, *big;
- u_int32_t *density, *block_size;
- u_int64_t *block_count;
- void **page_data;
+scsi_do_mode_sense(struct scsi_link *sc_link, int page,
+ union scsi_mode_sense_buf *buf, void **page_data, u_int32_t *density,
+ u_int64_t *block_count, u_int32_t *block_size, int page_len, int flags,
+ int *big)
{
- struct scsi_direct_blk_desc *direct;
- struct scsi_blk_desc *general;
- int error, blk_desc_len, offset;
+ struct scsi_direct_blk_desc *direct;
+ struct scsi_blk_desc *general;
+ int error, blk_desc_len, offset;
*page_data = NULL;
- if (density)
+ if (density != NULL)
*density = 0;
- if (block_count)
+ if (block_count != NULL)
*block_count = 0;
- if (block_size)
+ if (block_size != NULL)
*block_size = 0;
- if (big)
+ if (big != NULL)
*big = 0;
if ((sc_link->flags & SDEV_ATAPI) == 0 ||
@@ -518,7 +482,7 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
sizeof(*buf), flags, 20000);
if (error == 0) {
*page_data = scsi_mode_sense_page(&buf->hdr, page_len);
- if (*page_data == NULL)
+ if (*page_data == NULL) {
/*
* XXX
* Page data may be invalid (e.g. all zeros)
@@ -528,6 +492,7 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
* MODE_SENSE_BIG is attempted.
*/
return (0);
+ }
offset = sizeof(struct scsi_mode_header);
blk_desc_len = buf->hdr.blk_desc_len;
goto blk_desc;
@@ -546,7 +511,7 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
if (_2btol(buf->hdr_big.data_length) < 6)
return (EIO);
- if (big)
+ if (big != NULL)
*big = 1;
offset = sizeof(struct scsi_mode_header_big);
*page_data = scsi_mode_sense_big_page(&buf->hdr_big, page_len);
@@ -563,21 +528,21 @@ blk_desc:
* XXX What other device types return general block descriptors?
*/
general = (struct scsi_blk_desc *)&buf->buf[offset];
- if (density)
+ if (density != NULL)
*density = general->density;
- if (block_size)
+ if (block_size != NULL)
*block_size = _3btol(general->blklen);
- if (block_count)
+ if (block_count != NULL)
*block_count = (u_int64_t)_3btol(general->nblocks);
break;
default:
direct = (struct scsi_direct_blk_desc *)&buf->buf[offset];
- if (density)
+ if (density != NULL)
*density = direct->density;
- if (block_size)
+ if (block_size != NULL)
*block_size = _3btol(direct->blklen);
- if (block_count)
+ if (block_count != NULL)
*block_count = (u_int64_t)_4btol(direct->nblocks);
break;
}
@@ -586,13 +551,11 @@ blk_desc:
}
int
-scsi_mode_select(sc_link, byte2, data, flags, timeout)
- struct scsi_link *sc_link;
- int byte2, flags, timeout;
- struct scsi_mode_header *data;
+scsi_mode_select(struct scsi_link *sc_link, int byte2,
+ struct scsi_mode_header *data, int flags, int timeout)
{
- struct scsi_mode_select scsi_cmd;
- int error;
+ struct scsi_mode_select scsi_cmd;
+ int error;
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = MODE_SELECT;
@@ -612,14 +575,12 @@ scsi_mode_select(sc_link, byte2, data, flags, timeout)
}
int
-scsi_mode_select_big(sc_link, byte2, data, flags, timeout)
- struct scsi_link *sc_link;
- int byte2, flags, timeout;
- struct scsi_mode_header_big *data;
+scsi_mode_select_big(struct scsi_link *sc_link, int byte2,
+ struct scsi_mode_header_big *data, int flags, int timeout)
{
- struct scsi_mode_select_big scsi_cmd;
- u_int32_t len;
- int error;
+ struct scsi_mode_select_big scsi_cmd;
+ u_int32_t len;
+ int error;
len = _2btol(data->data_length) + 2; /* 2 == sizeof data->data_length */
@@ -645,12 +606,11 @@ scsi_mode_select_big(sc_link, byte2, data, flags, timeout)
* This routine is called by the scsi interrupt when the transfer is complete.
*/
void
-scsi_done(xs)
- struct scsi_xfer *xs;
+scsi_done(struct scsi_xfer *xs)
{
- struct scsi_link *sc_link = xs->sc_link;
- struct buf *bp;
- int error;
+ struct scsi_link *sc_link = xs->sc_link;
+ struct buf *bp;
+ int error;
splassert(IPL_BIO);
@@ -663,7 +623,7 @@ scsi_done(xs)
/*
* If it's a user level request, bypass all usual completion processing,
* let the user work it out.. We take reponsibility for freeing the
- * xs when the user returns. (and restarting the device's queue).
+ * xs when the user returns (and restarting the device's queue).
*/
if ((xs->flags & SCSI_USER) != 0) {
SC_DEBUG(sc_link, SDEV_DB3, ("calling user done()\n"));
@@ -705,7 +665,7 @@ retry:
}
bp = xs->bp;
- if (bp) {
+ if (bp != NULL) {
if (error) {
bp->b_error = error;
bp->b_flags |= B_ERROR;
@@ -725,15 +685,14 @@ retry:
(*sc_link->device->done)(xs);
}
scsi_free_xs(xs);
- if (bp)
+ if (bp != NULL)
biodone(bp);
}
int
-scsi_execute_xs(xs)
- struct scsi_xfer *xs;
+scsi_execute_xs(struct scsi_xfer *xs)
{
- int error, flags, rslt, s;
+ int error, flags, rslt, s;
xs->flags &= ~ITSDONE;
xs->error = XS_NOERROR;
@@ -782,7 +741,7 @@ retry:
switch (rslt) {
case SUCCESSFULLY_QUEUED:
if ((flags & (SCSI_NOSLEEP | SCSI_POLL)) == SCSI_NOSLEEP)
- return EJUSTRETURN;
+ return (EJUSTRETURN);
#ifdef DIAGNOSTIC
if (flags & SCSI_NOSLEEP)
panic("scsi_execute_xs: NOSLEEP and POLL");
@@ -795,13 +754,13 @@ retry:
/* FALLTHROUGH */
case COMPLETE: /* Polling command completed ok */
if ((flags & (SCSI_NOSLEEP | SCSI_POLL)) == SCSI_NOSLEEP)
- return EJUSTRETURN;
+ return (EJUSTRETURN);
if (xs->bp)
- return EJUSTRETURN;
+ return (EJUSTRETURN);
doit:
SC_DEBUG(xs->sc_link, SDEV_DB3, ("back in cmd()\n"));
if ((error = sc_err1(xs)) != ERESTART)
- return error;
+ return (error);
goto retry;
case TRY_AGAIN_LATER: /* adapter resource shortage */
@@ -815,7 +774,7 @@ retry:
#ifdef DIAGNOSTIC
panic("scsi_execute_xs: impossible");
#endif
- return EINVAL;
+ return (EINVAL);
}
/*
@@ -825,35 +784,27 @@ retry:
* to associate with the transfer, we need that too.
*/
int
-scsi_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
- retries, timeout, bp, flags)
- struct scsi_link *sc_link;
- struct scsi_generic *scsi_cmd;
- int cmdlen;
- u_char *data_addr;
- int datalen;
- int retries;
- int timeout;
- struct buf *bp;
- int flags;
+scsi_scsi_cmd(struct scsi_link *sc_link, struct scsi_generic *scsi_cmd,
+ int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
+ struct buf *bp, int flags)
{
- struct scsi_xfer *xs;
- int error;
- int s;
+ struct scsi_xfer *xs;
+ int error;
+ int s;
SC_DEBUG(sc_link, SDEV_DB2, ("scsi_cmd\n"));
#ifdef DIAGNOSTIC
- if (bp != 0 && (flags & SCSI_NOSLEEP) == 0)
+ if (bp != NULL && (flags & SCSI_NOSLEEP) == 0)
panic("scsi_scsi_cmd: buffer without nosleep");
#endif
if ((xs = scsi_make_xs(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
retries, timeout, bp, flags)) == NULL)
- return ENOMEM;
+ return (ENOMEM);
if ((error = scsi_execute_xs(xs)) == EJUSTRETURN)
- return 0;
+ return (0);
s = splbio();
/*
@@ -862,14 +813,14 @@ scsi_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
*/
scsi_free_xs(xs);
splx(s);
- return error;
+
+ return (error);
}
int
-sc_err1(xs)
- struct scsi_xfer *xs;
+sc_err1(struct scsi_xfer *xs)
{
- int error;
+ int error;
SC_DEBUG(xs->sc_link, SDEV_DB3, ("sc_err1,err = 0x%x\n", xs->error));
@@ -934,13 +885,11 @@ sc_err1(xs)
break;
}
- return error;
+ return (error);
}
int
-scsi_delay(xs, seconds)
- struct scsi_xfer *xs;
- int seconds;
+scsi_delay(struct scsi_xfer *xs, int seconds)
{
switch (xs->flags & (SCSI_POLL | SCSI_NOSLEEP)) {
case SCSI_POLL:
@@ -970,13 +919,12 @@ scsi_delay(xs, seconds)
* THIS IS THE DEFAULT ERROR HANDLER
*/
int
-scsi_interpret_sense(xs)
- struct scsi_xfer *xs;
+scsi_interpret_sense(struct scsi_xfer *xs)
{
- struct scsi_sense_data *sense = &xs->sense;
- struct scsi_link *sc_link = xs->sc_link;
- u_int8_t serr, skey;
- int error;
+ struct scsi_sense_data *sense = &xs->sense;
+ struct scsi_link *sc_link = xs->sc_link;
+ u_int8_t serr, skey;
+ int error;
SC_DEBUG(sc_link, SDEV_DB1,
("code:%#x valid:%d key:%#x ili:%d eom:%d fmark:%d extra:%d\n",
@@ -998,10 +946,11 @@ scsi_interpret_sense(xs)
* it wants us to continue with normal error processing.
*/
if (sc_link->device->err_handler) {
- SC_DEBUG(sc_link, SDEV_DB2, ("calling private err_handler()\n"));
+ SC_DEBUG(sc_link, SDEV_DB2,
+ ("calling private err_handler()\n"));
error = (*sc_link->device->err_handler) (xs);
if (error != EJUSTRETURN)
- return error; /* error >= 0 better ? */
+ return (error); /* error >= 0 better ? */
}
/* Default sense interpretation. */
@@ -1054,11 +1003,11 @@ scsi_interpret_sense(xs)
break;
case SKEY_ILLEGAL_REQUEST:
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
- return 0;
+ return (0);
error = EINVAL;
break;
case SKEY_UNIT_ATTENTION:
- if (sense->add_sense_code == 0x29 /* device or bus reset */)
+ if (sense->add_sense_code == 0x29) /* device or bus reset */
return (scsi_delay(xs, 1));
if ((sc_link->flags & SDEV_REMOVABLE) != 0)
sc_link->flags &= ~SDEV_MEDIA_LOADED;
@@ -1086,7 +1035,7 @@ scsi_interpret_sense(xs)
if (skey && (xs->flags & SCSI_SILENT) == 0)
scsi_print_sense(xs);
- return error;
+ return (error);
}
/*
@@ -1098,10 +1047,8 @@ scsi_interpret_sense(xs)
* Print out the scsi_link structure's address info.
*/
void
-sc_print_addr(sc_link)
- struct scsi_link *sc_link;
+sc_print_addr(struct scsi_link *sc_link)
{
-
printf("%s(%s:%d:%d): ",
sc_link->device_softc ?
((struct device *)sc_link->device_softc)->dv_xname : "probe",
@@ -1130,10 +1077,7 @@ static const char *sense_keys[16] = {
#ifdef SCSITERSE
static __inline void
-asc2ascii(asc, ascq, result, len)
- u_int8_t asc, ascq;
- char *result;
- size_t len;
+asc2ascii(u_int8_t asc, u_int8_t ascq, char *result, size_t len)
{
snprintf(result, len, "ASC 0x%02x ASCQ 0x%02x", asc, ascq);
}
@@ -1674,12 +1618,9 @@ static const struct {
};
static __inline void
-asc2ascii(asc, ascq, result, len)
- u_int8_t asc, ascq;
- char *result;
- size_t len;
+asc2ascii(u_int8_t asc, u_int8_t ascq, char *result, size_t len)
{
- int i;
+ int i;
/* Check for a dynamically built description. */
switch (asc) {
@@ -1704,11 +1645,12 @@ asc2ascii(asc, ascq, result, len)
}
/* Check for a fixed description. */
- for (i = 0; adesc[i].description != NULL; i++)
+ for (i = 0; adesc[i].description != NULL; i++) {
if (adesc[i].asc == asc && adesc[i].ascq == ascq) {
strlcpy(result, adesc[i].description, len);
return;
}
+ }
/* Just print out the ASC and ASCQ values as a description. */
snprintf(result, len, "ASC 0x%02x ASCQ 0x%02x", asc, ascq);
@@ -1716,13 +1658,13 @@ asc2ascii(asc, ascq, result, len)
#endif /* SCSITERSE */
void
-scsi_print_sense(xs)
- struct scsi_xfer *xs;
+scsi_print_sense(struct scsi_xfer *xs)
{
- struct scsi_sense_data *sense = &xs->sense;
- u_int8_t serr = sense->error_code & SSD_ERRCODE;
- int32_t info;
- char *sbs;
+ struct scsi_sense_data *sense = &xs->sense;
+ u_int8_t serr = sense->error_code &
+ SSD_ERRCODE;
+ int32_t info;
+ char *sbs;
sc_print_addr(xs->sc_link);
@@ -1786,16 +1728,14 @@ scsi_print_sense(xs)
}
char *
-scsi_decode_sense(sense, flag)
- struct scsi_sense_data *sense;
- int flag;
+scsi_decode_sense(struct scsi_sense_data *sense, int flag)
{
- static char rqsbuf[132];
- u_int16_t count;
- u_int8_t skey, spec_1;
- int len;
+ static char rqsbuf[132];
+ u_int16_t count;
+ u_int8_t skey, spec_1;
+ int len;
- bzero(rqsbuf, sizeof rqsbuf);
+ bzero(rqsbuf, sizeof(rqsbuf));
skey = sense->flags & SSD_KEY;
spec_1 = sense->sense_key_spec_1;
@@ -1803,11 +1743,11 @@ scsi_decode_sense(sense, flag)
switch (flag) {
case DECODE_SENSE_KEY:
- strlcpy(rqsbuf, sense_keys[skey], sizeof rqsbuf);
+ strlcpy(rqsbuf, sense_keys[skey], sizeof(rqsbuf));
break;
case DECODE_ASC_ASCQ:
asc2ascii(sense->add_sense_code, sense->add_sense_code_qual,
- rqsbuf, sizeof rqsbuf);
+ rqsbuf, sizeof(rqsbuf));
break;
case DECODE_SKSV:
if (sense->extra_len < 9 || ((spec_1 & SSD_SCS_VALID) == 0))
@@ -1844,13 +1784,12 @@ scsi_decode_sense(sense, flag)
return (rqsbuf);
}
-#ifdef SCSIDEBUG
+#ifdef SCSIDEBUG
/*
* Given a scsi_xfer, dump the request, in all it's glory
*/
void
-show_scsi_xs(xs)
- struct scsi_xfer *xs;
+show_scsi_xs(struct scsi_xfer *xs)
{
printf("xs(%p): ", xs);
printf("flg(0x%x)", xs->flags);
@@ -1868,11 +1807,10 @@ show_scsi_xs(xs)
}
void
-show_scsi_cmd(xs)
- struct scsi_xfer *xs;
+show_scsi_cmd(struct scsi_xfer *xs)
{
- u_char *b = (u_char *) xs->cmd;
- int i = 0;
+ u_char *b = (u_char *) xs->cmd;
+ int i = 0;
sc_print_addr(xs->sc_link);
printf("command: ");
@@ -1891,11 +1829,9 @@ show_scsi_cmd(xs)
}
void
-show_mem(address, num)
- u_char *address;
- int num;
+show_mem(u_char *address, int num)
{
- int x;
+ int x;
printf("------------------------------");
for (x = 0; x < num; x++) {