summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2019-12-05 18:42:15 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2019-12-05 18:42:15 +0000
commitb294fc68427dc2c6cb6af7eddd235921b1574202 (patch)
tree5786916656edfec208baad428c45f034d88bafb9 /sys/scsi
parent89d62d7c0c01ab249be83ae311e8d08e2ecc0777 (diff)
Shrink scsi_mode_do_sense() parameter list by eliminating the three
pointers returning possible block descriptor values for block size, block count and density. Most calls were passing "NULL, NULL, NULL" since they did not care. Call scsi_parse_blkdesc() directly in those few cases where one or more of the values is of interest. No intentional functional change.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c14
-rw-r--r--sys/scsi/ch.c6
-rw-r--r--sys/scsi/scsi_base.c29
-rw-r--r--sys/scsi/scsiconf.h7
-rw-r--r--sys/scsi/sd.c74
-rw-r--r--sys/scsi/st.c14
6 files changed, 74 insertions, 70 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 1419cbddef9..fefe57f51ae 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.238 2019/11/28 16:27:35 krw Exp $ */
+/* $OpenBSD: cd.c,v 1.239 2019/12/05 18:42:13 krw Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -1173,7 +1173,7 @@ cd_setchan(struct cd_softc *sc, int p0, int p1, int p2, int p3, int flags)
return (ENOMEM);
error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
- (void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
+ (void **)&audio, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1206,7 +1206,7 @@ cd_getvol(struct cd_softc *sc, struct ioc_vol *arg, int flags)
return (ENOMEM);
error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
- (void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
+ (void **)&audio, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1234,8 +1234,8 @@ cd_setvol(struct cd_softc *sc, const struct ioc_vol *arg, int flags)
return (ENOMEM);
error = scsi_do_mode_sense(sc->sc_link,
- AUDIO_PAGE | SMS_PAGE_CTRL_CHANGEABLE, data, (void **)&audio, NULL,
- NULL, NULL, sizeof(*audio), flags, &big);
+ AUDIO_PAGE | SMS_PAGE_CTRL_CHANGEABLE, data, (void **)&audio,
+ sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
if (error != 0) {
@@ -1249,7 +1249,7 @@ cd_setvol(struct cd_softc *sc, const struct ioc_vol *arg, int flags)
mask_volume[3] = audio->port[3].volume;
error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
- (void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
+ (void **)&audio, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
if (error != 0) {
@@ -1313,7 +1313,7 @@ cd_set_pa_immed(struct cd_softc *sc, int flags)
return (ENOMEM);
error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
- (void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
+ (void **)&audio, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c
index 856a0a13714..d47b3bc2f5d 100644
--- a/sys/scsi/ch.c
+++ b/sys/scsi/ch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ch.c,v 1.62 2019/12/01 15:41:43 krw Exp $ */
+/* $OpenBSD: ch.c,v 1.63 2019/12/05 18:42:14 krw Exp $ */
/* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */
/*
@@ -673,7 +673,7 @@ ch_get_params(struct ch_softc *sc, int flags)
* Grab info from the element address assignment page (0x1d).
*/
error = scsi_do_mode_sense(sc->sc_link, EA_PAGE, data,
- (void **)&ea, NULL, NULL, NULL, sizeof(*ea), flags, &big);
+ (void **)&ea, sizeof(*ea), flags, &big);
if (error == 0 && ea == NULL)
error = EIO;
if (error != 0) {
@@ -700,7 +700,7 @@ ch_get_params(struct ch_softc *sc, int flags)
* Grab info from the capabilities page (0x1f).
*/
error = scsi_do_mode_sense(sc->sc_link, CAP_PAGE, data,
- (void **)&cap, NULL, NULL, NULL, sizeof(*cap), flags, &big);
+ (void **)&cap, sizeof(*cap), flags, &big);
if (error == 0 && cap == NULL)
error = EIO;
if (error != 0) {
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 1b301319ce2..2b5d522bd6a 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.257 2019/12/05 16:33:53 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.258 2019/12/05 18:42:14 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -1253,9 +1253,8 @@ scsi_parse_blkdesc(struct scsi_link *link, union scsi_mode_sense_buf *buf,
int
scsi_do_mode_sense(struct scsi_link *link, int pg_code,
- union scsi_mode_sense_buf *buf, void **page_data, u_int32_t *density,
- u_int64_t *block_count, u_int32_t *block_size, int pg_length, int flags,
- int *big)
+ union scsi_mode_sense_buf *buf, void **page_data,
+ int pg_length, int flags, int *big)
{
int error;
@@ -1276,20 +1275,15 @@ scsi_do_mode_sense(struct scsi_link *link, int pg_code,
error = scsi_mode_sense(link, pg_code, &buf->hdr,
sizeof(*buf), flags, 20000);
if (error == 0) {
+ /*
+ * Page data may be invalid (e.g. all zeros) but we
+ * accept the device's word that this is the best it can
+ * do. Some devices will freak out if their word is not
+ * accepted and MODE_SENSE_BIG is attempted.
+ */
*page_data = scsi_mode_sense_page(&buf->hdr, pg_code,
pg_length);
- if (*page_data == NULL) {
- /*
- * XXX
- * Page data may be invalid (e.g. all zeros)
- * but we accept the device's word that this is
- * the best it can do. Some devices will freak
- * out if their word is not accepted and
- * MODE_SENSE_BIG is attempted.
- */
- return (0);
- }
- goto blk_desc;
+ return 0;
}
}
@@ -1314,9 +1308,6 @@ scsi_do_mode_sense(struct scsi_link *link, int pg_code,
*page_data = scsi_mode_sense_big_page(&buf->hdr_big, pg_code,
pg_length);
-blk_desc:
- scsi_parse_blkdesc(link, buf, *big, density, block_count, block_size);
-
return (0);
}
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 6fdb8fcc781..4a53f001acd 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.180 2019/12/05 16:16:01 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.181 2019/12/05 18:42:14 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -486,8 +486,9 @@ int scsi_start(struct scsi_link *, int, int);
void scsi_parse_blkdesc(struct scsi_link *, union scsi_mode_sense_buf *, int,
u_int32_t *, u_int64_t *, u_int32_t *);
int scsi_do_mode_sense(struct scsi_link *, int,
- union scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *,
- u_int32_t *, int, int, int *);
+ union scsi_mode_sense_buf *, void **, int, int, int *);
+void scsi_parse_blkdesc(struct scsi_link *, union scsi_mode_sense_buf *, int,
+ u_int32_t *, u_int64_t *, u_int32_t *);
int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
int, int);
int scsi_mode_select_big(struct scsi_link *, int,
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index c87c127d575..2d6da991851 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.304 2019/12/03 15:58:28 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.305 2019/12/05 18:42:14 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -1058,8 +1058,7 @@ sd_ioctl_cache(struct sd_softc *sc, long cmd, struct dk_cache *dkc)
rv = ENXIO;
goto done;
}
- rv = scsi_do_mode_sense(link, PAGE_CACHING_MODE,
- buf, (void **)&mode, NULL, NULL, NULL,
+ rv = scsi_do_mode_sense(link, PAGE_CACHING_MODE, buf, (void **)&mode,
sizeof(*mode) - 4, scsi_autoconf | SCSI_SILENT, &big);
if (rv == 0 && mode == NULL)
rv = EIO;
@@ -1691,9 +1690,11 @@ sd_get_parms(struct sd_softc *sc, int flags)
/*
* Ask for page 0 (vendor specific) mode sense data to find
* READONLY info. The only thing USB devices will ask for.
+ *
+ * page0 == NULL is a valid situation.
*/
- err = scsi_do_mode_sense(link, 0, buf, (void **)&page0,
- NULL, NULL, NULL, 1, flags | SCSI_SILENT, &big);
+ err = scsi_do_mode_sense(link, 0, buf, (void **)&page0, 1,
+ flags | SCSI_SILENT, &big);
if (ISSET(sc->flags, SDF_DYING))
goto die;
if (err == 0) {
@@ -1720,14 +1721,17 @@ sd_get_parms(struct sd_softc *sc, int flags)
case T_RDIRECT:
/* T_RDIRECT supports only PAGE_REDUCED_GEOMETRY (6). */
- err = scsi_do_mode_sense(link, PAGE_REDUCED_GEOMETRY,
- buf, (void **)&reduced, NULL, NULL, &dp.secsize,
- sizeof(*reduced), flags | SCSI_SILENT, &big);
- if (err == 0 && reduced != NULL) {
- if (dp.disksize == 0)
- dp.disksize = _5btol(reduced->sectors);
- if (dp.secsize == 0)
- dp.secsize = _2btol(reduced->bytes_s);
+ err = scsi_do_mode_sense(link, PAGE_REDUCED_GEOMETRY, buf,
+ (void **)&reduced, sizeof(*reduced), flags | SCSI_SILENT,
+ &big);
+ if (err == 0) {
+ scsi_parse_blkdesc(link, buf, big, NULL, NULL, &dp.secsize);
+ if (reduced != NULL) {
+ if (dp.disksize == 0)
+ dp.disksize = _5btol(reduced->sectors);
+ if (dp.secsize == 0)
+ dp.secsize = _2btol(reduced->bytes_s);
+ }
}
break;
@@ -1742,31 +1746,35 @@ sd_get_parms(struct sd_softc *sc, int flags)
err = 0;
if (!ISSET(link->flags, SDEV_ATAPI) ||
!ISSET(link->flags, SDEV_REMOVABLE))
- err = scsi_do_mode_sense(link,
- PAGE_RIGID_GEOMETRY, buf, (void **)&rigid, NULL,
- NULL, &dp.secsize, sizeof(*rigid) - 4,
+ err = scsi_do_mode_sense(link, PAGE_RIGID_GEOMETRY, buf,
+ (void **)&rigid, sizeof(*rigid) - 4,
flags | SCSI_SILENT, &big);
- if (err == 0 && rigid != NULL) {
- dp.heads = rigid->nheads;
- dp.cyls = _3btol(rigid->ncyl);
- if (dp.heads * dp.cyls > 0)
- dp.sectors = dp.disksize / (dp.heads * dp.cyls);
+ if (err == 0) {
+ scsi_parse_blkdesc(link, buf, big, NULL, NULL, &dp.secsize);
+ if (rigid != NULL) {
+ dp.heads = rigid->nheads;
+ dp.cyls = _3btol(rigid->ncyl);
+ if (dp.heads * dp.cyls > 0)
+ dp.sectors = dp.disksize / (dp.heads * dp.cyls);
+ }
} else {
if (ISSET(sc->flags, SDF_DYING))
goto die;
- err = scsi_do_mode_sense(link,
- PAGE_FLEX_GEOMETRY, buf, (void **)&flex, NULL, NULL,
- &dp.secsize, sizeof(*flex) - 4,
+ err = scsi_do_mode_sense(link, PAGE_FLEX_GEOMETRY, buf,
+ (void **)&flex, sizeof(*flex) - 4,
flags | SCSI_SILENT, &big);
- if (err == 0 && flex != NULL) {
- dp.sectors = flex->ph_sec_tr;
- dp.heads = flex->nheads;
- dp.cyls = _2btol(flex->ncyl);
- if (dp.secsize == 0)
- dp.secsize = _2btol(flex->bytes_s);
- if (dp.disksize == 0)
- dp.disksize = (u_int64_t)dp.cyls *
- dp.heads * dp.sectors;
+ if (err == 0) {
+ scsi_parse_blkdesc(link, buf, big, NULL, NULL, &dp.secsize);
+ if (flex != NULL) {
+ dp.sectors = flex->ph_sec_tr;
+ dp.heads = flex->nheads;
+ dp.cyls = _2btol(flex->ncyl);
+ if (dp.secsize == 0)
+ dp.secsize = _2btol(flex->bytes_s);
+ if (dp.disksize == 0)
+ dp.disksize = (u_int64_t)dp.cyls *
+ dp.heads * dp.sectors;
+ }
}
}
break;
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index 389f4448cd5..30aafd4f2b5 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.171 2019/11/26 20:48:03 krw Exp $ */
+/* $OpenBSD: st.c,v 1.172 2019/12/05 18:42:14 krw Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -1348,10 +1348,12 @@ st_mode_sense(struct st_softc *st, int flags)
density = 0;
block_count = 0;
block_size = 0;
- error = scsi_do_mode_sense(link, 0, data, (void **)&page0,
- &density, &block_count, &block_size, 1, flags | SCSI_SILENT, &big);
+ error = scsi_do_mode_sense(link, 0, data, (void **)&page0, 1,
+ flags | SCSI_SILENT, &big);
if (error != 0)
goto done;
+ scsi_parse_blkdesc(link, data, big, &density, &block_count,
+ &block_size);
/* It is valid for no page0 to be available. */
@@ -1432,9 +1434,11 @@ st_mode_select(struct st_softc *st, int flags)
/*
* Ask for page 0 (vendor specific) mode sense data.
+ *
+ * page0 == NULL is a valid situation.
*/
- error = scsi_do_mode_sense(link, 0, inbuf, (void **)&page0, NULL,
- NULL, NULL, 1, flags | SCSI_SILENT, &big);
+ error = scsi_do_mode_sense(link, 0, inbuf, (void **)&page0, 1,
+ flags | SCSI_SILENT, &big);
if (error != 0)
goto done;