diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-03-12 19:21:02 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-03-12 19:21:02 +0000 |
commit | baa8a00d0bf78a33a2aa37515d46db8da1809f64 (patch) | |
tree | 9e2b7caeaa59857cbed056dd7d594a60cd5b282a /sys/scsi/scsi_base.c | |
parent | 25992d68d86b5221f9d925929dd854e1a939869a (diff) |
Pass scsi_mode_sense_buf pointers to scsi_mode_sense[_buf]() rather
than scsi_mode_header[_big] pointers to the same data.
Continues the umtamgling and simplification of the mode sense code.
CID 1491299
CID 1491297
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r-- | sys/scsi/scsi_base.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 2028360e363..07be9de8a29 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.264 2020/03/12 16:15:03 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.265 2020/03/12 19:21:01 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -90,9 +90,9 @@ void scsi_iopool_put(struct scsi_iopool *, void *); /* Various helper functions for scsi_do_mode_sense() */ int scsi_mode_sense(struct scsi_link *, int, - struct scsi_mode_header *, int); + union scsi_mode_sense_buf *, int); int scsi_mode_sense_big(struct scsi_link *, int, - struct scsi_mode_header_big *, int); + union scsi_mode_sense_buf *, int); void * scsi_mode_sense_page(struct scsi_mode_header *, int, int); void * scsi_mode_sense_big_page(struct scsi_mode_header_big *, @@ -1062,7 +1062,7 @@ scsi_start(struct scsi_link *link, int type, int flags) int scsi_mode_sense(struct scsi_link *link, int pg_code, - struct scsi_mode_header *data, int flags) + union scsi_mode_sense_buf *data, int flags) { struct scsi_mode_sense *cmd; struct scsi_xfer *xs; @@ -1072,7 +1072,7 @@ scsi_mode_sense(struct scsi_link *link, int pg_code, size_t bytes; #endif /* SCSIDEBUG */ - len = sizeof(union scsi_mode_sense_buf); + len = sizeof(*data); xs = scsi_xs_get(link, flags | SCSI_DATA_IN); if (xs == NULL) @@ -1103,7 +1103,7 @@ scsi_mode_sense(struct scsi_link *link, int pg_code, #ifdef SCSIDEBUG sc_print_addr(link); if (error == 0) { - bytes = sizeof(data->data_length) + data->data_length; + bytes = sizeof(data->hdr.data_length) + data->hdr.data_length; if (bytes < len) len = bytes; printf("got %zu of %zu bytes of mode sense (6) page %d data:\n", @@ -1118,7 +1118,7 @@ scsi_mode_sense(struct scsi_link *link, int pg_code, int scsi_mode_sense_big(struct scsi_link *link, int pg_code, - struct scsi_mode_header_big *data, int flags) + union scsi_mode_sense_buf *data, int flags) { struct scsi_mode_sense_big *cmd; struct scsi_xfer *xs; @@ -1128,7 +1128,7 @@ scsi_mode_sense_big(struct scsi_link *link, int pg_code, size_t bytes; #endif /* SCSIDEBUG */ - len = sizeof(union scsi_mode_sense_buf); + len = sizeof(*data); xs = scsi_xs_get(link, flags | SCSI_DATA_IN); if (xs == NULL) @@ -1156,13 +1156,14 @@ scsi_mode_sense_big(struct scsi_link *link, int pg_code, error = scsi_xs_sync(xs); scsi_xs_put(xs); - if (_2btol(data->data_length) < 6) + if (_2btol(data->hdr_big.data_length) < 6) error = EIO; #ifdef SCSIDEBUG sc_print_addr(link); if (error == 0) { - bytes = sizeof(data->data_length) + _2btol(data->data_length); + bytes = sizeof(data->hdr_big.data_length) + + _2btol(data->hdr_big.data_length); if (bytes < len) len = bytes; printf("got %zu bytes of %zu bytes of mode sense (10) page %d " @@ -1282,7 +1283,7 @@ scsi_do_mode_sense(struct scsi_link *link, int pg_code, * data length to ensure that at least a header (3 additional * bytes) is returned. */ - error = scsi_mode_sense(link, pg_code, &buf->hdr, flags); + error = scsi_mode_sense(link, pg_code, buf, flags); if (error == 0) { /* * Page data may be invalid (e.g. all zeros) but we @@ -1307,7 +1308,7 @@ scsi_do_mode_sense(struct scsi_link *link, int pg_code, /* * Try 10 byte mode sense request. */ - error = scsi_mode_sense_big(link, pg_code, &buf->hdr_big, flags); + error = scsi_mode_sense_big(link, pg_code, buf, flags); if (error != 0) return error; |