diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-09-11 17:34:28 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-09-11 17:34:28 +0000 |
commit | 17f93f987c477cb6765780b9c59e7b41af5740f1 (patch) | |
tree | faae77e00ba669952a7dcb18d2e302aefa629c93 /sys | |
parent | be3f710a56e4630a4e815111fec121a52ba2896c (diff) |
Simplify code by changing struct scsi_mode_sense_buf{ union {}
headers; } to just union scsi_mode_sense_buf {}. No functional change.
ok marco@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/cd.c | 22 | ||||
-rw-r--r-- | sys/scsi/ch.c | 4 | ||||
-rw-r--r-- | sys/scsi/scsi_all.h | 14 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 26 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 4 | ||||
-rw-r--r-- | sys/scsi/sd.c | 4 | ||||
-rw-r--r-- | sys/scsi/st.c | 58 |
7 files changed, 63 insertions, 69 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index c49411c5741..6f59995776c 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.87 2005/08/23 23:38:00 krw Exp $ */ +/* $OpenBSD: cd.c,v 1.88 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -1364,7 +1364,7 @@ cd_setchan(cd, p0, p1, p2, p3, flags) struct cd_softc *cd; int p0, p1, p2, p3, flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct cd_audio_page *audio = NULL; int error, big; @@ -1384,10 +1384,10 @@ cd_setchan(cd, p0, p1, p2, p3, flags) audio->port[3].channels = p3; if (big) error = scsi_mode_select_big(cd->sc_link, SMS_PF, - &data->headers.hdr_big, flags, 20000); + &data->hdr_big, flags, 20000); else error = scsi_mode_select(cd->sc_link, SMS_PF, - &data->headers.hdr, flags, 20000); + &data->hdr, flags, 20000); } free(data, M_TEMP); @@ -1400,7 +1400,7 @@ cd_getvol(cd, arg, flags) struct ioc_vol *arg; int flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct cd_audio_page *audio = NULL; int error; @@ -1430,7 +1430,7 @@ cd_setvol(cd, arg, flags) const struct ioc_vol *arg; int flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct cd_audio_page *audio = NULL; u_int8_t mask_volume[4]; int error, big; @@ -1470,10 +1470,10 @@ cd_setvol(cd, arg, flags) if (big) error = scsi_mode_select_big(cd->sc_link, SMS_PF, - &data->headers.hdr_big, flags, 20000); + &data->hdr_big, flags, 20000); else error = scsi_mode_select(cd->sc_link, SMS_PF, - &data->headers.hdr, flags, 20000); + &data->hdr, flags, 20000); free(data, M_TEMP); return (error); @@ -1500,7 +1500,7 @@ cd_set_pa_immed(cd, flags) struct cd_softc *cd; int flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct cd_audio_page *audio = NULL; int error, oflags, big; @@ -1524,11 +1524,11 @@ cd_set_pa_immed(cd, flags) if (audio->flags != oflags) { if (big) error = scsi_mode_select_big(cd->sc_link, - SMS_PF, &data->headers.hdr_big, flags, + SMS_PF, &data->hdr_big, flags, 20000); else error = scsi_mode_select(cd->sc_link, SMS_PF, - &data->headers.hdr, flags, 20000); + &data->hdr, flags, 20000); } } diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index 13c2ba5c58a..e33572ea98f 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ch.c,v 1.22 2005/08/23 23:38:00 krw Exp $ */ +/* $OpenBSD: ch.c,v 1.23 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */ /* @@ -613,7 +613,7 @@ ch_get_params(sc, flags) struct ch_softc *sc; int flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct page_element_address_assignment *ea; struct page_device_capabilities *cap; int error, from; diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index 0ef1485d3bc..2869ba8b795 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.33 2005/08/29 00:33:55 krw Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.34 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -338,13 +338,11 @@ struct scsi_mode_header_big { u_int8_t blk_desc_len[2]; }; -struct scsi_mode_sense_buf { - union { - struct scsi_mode_header hdr; - struct scsi_mode_header_big hdr_big; - u_char buf[255]; /* 256 bytes breaks some devices. */ - } __packed headers; /* Ensure sizeof() is 255! */ -} __packed; +union scsi_mode_sense_buf { + struct scsi_mode_header hdr; + struct scsi_mode_header_big hdr_big; + u_char buf[255]; /* 256 bytes breaks some devices. */ +} __packed; /* Ensure sizeof() is 255! */ /* * SPI status information unit. See section 14.3.5 of SPI-3. diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 2234141ac22..6ebc782e345 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.87 2005/08/29 00:41:44 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.88 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -471,7 +471,7 @@ 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; - struct scsi_mode_sense_buf *buf; + union scsi_mode_sense_buf *buf; int page, page_len, flags, *big; u_int32_t *density, *block_size; u_int64_t *block_count; @@ -500,13 +500,12 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count, * with SMS_DBD. Check returned data length to ensure that * at least a header (3 additional bytes) is returned. */ - error = scsi_mode_sense(sc_link, 0, page, &buf->headers.hdr, + error = scsi_mode_sense(sc_link, 0, page, &buf->hdr, sizeof(*buf), flags, 20000); - if (error == 0 && buf->headers.hdr.data_length > 2) { - *page_data = scsi_mode_sense_page(&buf->headers.hdr, - page_len); + if (error == 0 && buf->hdr.data_length > 2) { + *page_data = scsi_mode_sense_page(&buf->hdr, page_len); offset = sizeof(struct scsi_mode_header); - blk_desc_len = buf->headers.hdr.blk_desc_len; + blk_desc_len = buf->hdr.blk_desc_len; goto blk_desc; } } @@ -516,18 +515,18 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count, * SMS_LLBAA. Bail out if the returned information is less than * a big header in size (6 additional bytes). */ - error = scsi_mode_sense_big(sc_link, 0, page, &buf->headers.hdr_big, + error = scsi_mode_sense_big(sc_link, 0, page, &buf->hdr_big, sizeof(*buf), flags, 20000); if (error != 0) return (error); - if (_2btol(buf->headers.hdr_big.data_length) < 6) + if (_2btol(buf->hdr_big.data_length) < 6) return (EIO); if (big) *big = 1; offset = sizeof(struct scsi_mode_header_big); - *page_data = scsi_mode_sense_big_page(&buf->headers.hdr_big, page_len); - blk_desc_len = _2btol(buf->headers.hdr_big.blk_desc_len); + *page_data = scsi_mode_sense_big_page(&buf->hdr_big, page_len); + blk_desc_len = _2btol(buf->hdr_big.blk_desc_len); blk_desc: /* Both scsi_blk_desc and scsi_direct_blk_desc are 8 bytes. */ @@ -539,7 +538,7 @@ blk_desc: /* * XXX What other device types return general block descriptors? */ - general = (struct scsi_blk_desc *)&buf->headers.buf[offset]; + general = (struct scsi_blk_desc *)&buf->buf[offset]; if (density) *density = general->density; if (block_size) @@ -549,8 +548,7 @@ blk_desc: break; default: - direct = (struct scsi_direct_blk_desc *)&buf-> - headers.buf[offset]; + direct = (struct scsi_direct_blk_desc *)&buf->buf[offset]; if (density) *density = direct->density; if (block_size) diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 0a998bbc536..da6330b2920 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.60 2005/06/24 23:39:18 krw Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.61 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -338,7 +338,7 @@ int scsi_mode_sense_big(struct scsi_link *, int, int, void * scsi_mode_sense_page(struct scsi_mode_header *, int); void * scsi_mode_sense_big_page(struct scsi_mode_header_big *, int); int scsi_do_mode_sense(struct scsi_link *, int, - struct scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *, + union scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *, u_int32_t *, int, int, int *); int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *, int, int); diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index fe339ef77ed..bda748be3f0 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.92 2005/09/11 17:18:53 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.93 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -1328,7 +1328,7 @@ sd_get_parms(sd, dp, flags) struct disk_parms *dp; int flags; { - struct scsi_mode_sense_buf *buf = NULL; + union scsi_mode_sense_buf *buf = NULL; struct page_rigid_geometry *rigid; struct page_flex_geometry *flex; struct page_reduced_geometry *reduced; diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 22233566c0d..9ed1bfe42ab 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.49 2005/08/23 23:38:00 krw Exp $ */ +/* $OpenBSD: st.c,v 1.50 2005/09/11 17:34:27 krw Exp $ */ /* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */ /* @@ -1421,7 +1421,7 @@ st_mode_sense(st, flags) struct st_softc *st; int flags; { - struct scsi_mode_sense_buf *data; + union scsi_mode_sense_buf *data; struct scsi_link *sc_link = st->sc_link; u_int64_t block_count; u_int32_t density, block_size; @@ -1446,9 +1446,9 @@ st_mode_sense(st, flags) /* It is valid for no page0 to be available. */ if (big) - dev_spec = data->headers.hdr_big.dev_spec; + dev_spec = data->hdr_big.dev_spec; else - dev_spec = data->headers.hdr.dev_spec; + dev_spec = data->hdr.dev_spec; if (dev_spec & SMH_DSP_WRITE_PROT) st->flags |= ST_READONLY; @@ -1481,7 +1481,7 @@ st_mode_select(st, flags) struct st_softc *st; int flags; { - struct scsi_mode_sense_buf *inbuf, *outbuf; + union scsi_mode_sense_buf *inbuf, *outbuf; struct scsi_blk_desc general; struct scsi_link *sc_link = st->sc_link; u_int8_t *page0 = NULL; @@ -1537,34 +1537,33 @@ st_mode_select(st, flags) if (page0 == NULL) { page0_size = 0; } else if (big == 0) { - page0_size = inbuf->headers.hdr.data_length + - sizeof(inbuf->headers.hdr.data_length) - - sizeof(inbuf->headers.hdr) - - inbuf->headers.hdr.blk_desc_len; - memcpy(&outbuf->headers.buf[sizeof(outbuf->headers.hdr)+ - sizeof(general)], page0, page0_size); + page0_size = inbuf->hdr.data_length + + sizeof(inbuf->hdr.data_length) - sizeof(inbuf->hdr) - + inbuf->hdr.blk_desc_len; + memcpy(&outbuf->buf[sizeof(outbuf->hdr)+ sizeof(general)], + page0, page0_size); } else { - page0_size = _2btol(inbuf->headers.hdr_big.data_length) + - sizeof(inbuf->headers.hdr_big.data_length) - - sizeof(inbuf->headers.hdr_big) - - _2btol(inbuf->headers.hdr_big.blk_desc_len); - memcpy(&outbuf->headers.buf[sizeof(outbuf->headers.hdr_big) + - sizeof(general)], page0, page0_size); + page0_size = _2btol(inbuf->hdr_big.data_length) + + sizeof(inbuf->hdr_big.data_length) - + sizeof(inbuf->hdr_big) - + _2btol(inbuf->hdr_big.blk_desc_len); + memcpy(&outbuf->buf[sizeof(outbuf->hdr_big) + sizeof(general)], + page0, page0_size); } /* * Set up for a mode select. */ if (big == 0) { - outbuf->headers.hdr.data_length = sizeof(outbuf->headers.hdr) + + outbuf->hdr.data_length = sizeof(outbuf->hdr) + sizeof(general) + page0_size - - sizeof(outbuf->headers.hdr.data_length); + sizeof(outbuf->hdr.data_length); if ((st->flags & ST_DONTBUFFER) == 0) - outbuf->headers.hdr.dev_spec = SMH_DSP_BUFF_MODE_ON; - outbuf->headers.hdr.blk_desc_len = sizeof(general); - memcpy(&outbuf->headers.buf[sizeof(outbuf->headers.hdr)], + outbuf->hdr.dev_spec = SMH_DSP_BUFF_MODE_ON; + outbuf->hdr.blk_desc_len = sizeof(general); + memcpy(&outbuf->buf[sizeof(outbuf->hdr)], &general, sizeof(general)); - error = scsi_mode_select(st->sc_link, 0, &outbuf->headers.hdr, + error = scsi_mode_select(st->sc_link, 0, &outbuf->hdr, flags, ST_CTL_TIME); free(inbuf, M_TEMP); free(outbuf, M_TEMP); @@ -1572,16 +1571,15 @@ st_mode_select(st, flags) } /* MODE SENSE (10) header was returned, so use MODE SELECT (10). */ - _lto2b((sizeof(outbuf->headers.hdr_big) + sizeof(general) + page0_size - - sizeof(outbuf->headers.hdr_big.data_length)), - outbuf->headers.hdr_big.data_length); + _lto2b((sizeof(outbuf->hdr_big) + sizeof(general) + page0_size - + sizeof(outbuf->hdr_big.data_length)), outbuf->hdr_big.data_length); if ((st->flags & ST_DONTBUFFER) == 0) - outbuf->headers.hdr_big.dev_spec = SMH_DSP_BUFF_MODE_ON; - _lto2b(sizeof(general), outbuf->headers.hdr_big.blk_desc_len); - memcpy(&outbuf->headers.buf[sizeof(outbuf->headers.hdr_big)], &general, + outbuf->hdr_big.dev_spec = SMH_DSP_BUFF_MODE_ON; + _lto2b(sizeof(general), outbuf->hdr_big.blk_desc_len); + memcpy(&outbuf->buf[sizeof(outbuf->hdr_big)], &general, sizeof(general)); - error = scsi_mode_select_big(st->sc_link, 0, &outbuf->headers.hdr_big, + error = scsi_mode_select_big(st->sc_link, 0, &outbuf->hdr_big, flags, ST_CTL_TIME); free(inbuf, M_TEMP); free(outbuf, M_TEMP); |