diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-14 00:20:44 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-14 00:20:44 +0000 |
commit | 34083bc7fc0c5e904388864bf4b609651528a65b (patch) | |
tree | 173b30652dbeccffae4397f7cdfb4c6b0efe127e | |
parent | eb133e7a93232e289147e2dbccbd4da5916d141a (diff) |
Add scsi_mode_[sense|select]_big() and use it instead of
atapi_mode_[sense|select](). This will allow the removal of
atapi_base.c and atapi_all.h files, and sets the stage for better usb
mode sense handling amoung other things.
Remove cd_scsibus_[get|set]_mode() and
sd_scsibus_mode_sense() shims in favour of scsi_mode_[sense|select]().
Add zero'ing of reserved length field in scsi_mode_select(). Change
some uchar * type parameters to scsi_mode_header *.
No functional changes. Mostly from NetBSD.
ok dlg@.
-rw-r--r-- | sys/scsi/cd_atapi.c | 50 | ||||
-rw-r--r-- | sys/scsi/cd_scsi.c | 79 | ||||
-rw-r--r-- | sys/scsi/ch.c | 10 | ||||
-rw-r--r-- | sys/scsi/files.scsi | 3 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 74 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 14 | ||||
-rw-r--r-- | sys/scsi/sd_atapi.c | 8 | ||||
-rw-r--r-- | sys/scsi/sd_scsi.c | 41 | ||||
-rw-r--r-- | sys/scsi/ss_mustek.c | 6 | ||||
-rw-r--r-- | sys/scsi/st.c | 13 |
10 files changed, 182 insertions, 116 deletions
diff --git a/sys/scsi/cd_atapi.c b/sys/scsi/cd_atapi.c index 22fb4995f5d..2954c5a7de9 100644 --- a/sys/scsi/cd_atapi.c +++ b/sys/scsi/cd_atapi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd_atapi.c,v 1.4 2005/04/16 16:41:46 krw Exp $ */ +/* $OpenBSD: cd_atapi.c,v 1.5 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: cd_atapi.c,v 1.10 1998/08/31 22:28:06 cgd Exp $ */ /* @@ -64,7 +64,6 @@ #include <scsi/scsi_all.h> #include <scsi/cd.h> -#include <scsi/atapi_all.h> #include <scsi/atapi_cd.h> #include <scsi/cdvar.h> #include <scsi/scsiconf.h> @@ -93,17 +92,21 @@ cd_atapibus_setchan(cd, p0, p1, p2, p3, flags) struct atapi_cd_mode_data data; int error; - if ((error = atapi_mode_sense(cd->sc_link, ATAPI_AUDIO_PAGE, - (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, - CDRETRIES, 20000)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense_big(cd->sc_link, 0, ATAPI_AUDIO_PAGE, + (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + data.pages.audio.port[LEFT_PORT].channels = p0; data.pages.audio.port[RIGHT_PORT].channels = p1; data.pages.audio.port[2].channels = p2; data.pages.audio.port[3].channels = p3; - return (atapi_mode_select(cd->sc_link, - (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, - CDRETRIES, 20000)); + + error = scsi_mode_select_big(cd->sc_link, SMS_PF, + (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, 20000); + + return (error); } static int @@ -115,14 +118,17 @@ cd_atapibus_getvol(cd, arg, flags) struct atapi_cd_mode_data data; int error; - if ((error = atapi_mode_sense(cd->sc_link, ATAPI_AUDIO_PAGE, - (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, - CDRETRIES, 20000)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense_big(cd->sc_link, 0, ATAPI_AUDIO_PAGE, + (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + arg->vol[0] = data.pages.audio.port[0].volume; arg->vol[1] = data.pages.audio.port[1].volume; arg->vol[2] = data.pages.audio.port[2].volume; arg->vol[3] = data.pages.audio.port[3].volume; + return (0); } @@ -135,13 +141,16 @@ cd_atapibus_setvol(cd, arg, flags) struct atapi_cd_mode_data data, mask; int error; - if ((error = atapi_mode_sense(cd->sc_link, ATAPI_AUDIO_PAGE, - (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, - CDRETRIES, 20000)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense_big(cd->sc_link, 0, ATAPI_AUDIO_PAGE, + (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); - if ((error = atapi_mode_sense(cd->sc_link, ATAPI_AUDIO_PAGE_MASK, - (struct scsi_mode_header_big *)&mask, AUDIOPAGESIZE, flags, - CDRETRIES, 20000)) != 0) + + bzero(&mask, sizeof(mask)); + error = scsi_mode_sense_big(cd->sc_link, 0, ATAPI_AUDIO_PAGE_MASK, + (struct scsi_mode_header_big *)&mask, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); data.pages.audio.port[0].volume = arg->vol[0] & @@ -153,9 +162,10 @@ cd_atapibus_setvol(cd, arg, flags) data.pages.audio.port[3].volume = arg->vol[3] & mask.pages.audio.port[3].volume; - return (atapi_mode_select(cd->sc_link, - (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, - flags, CDRETRIES, 20000)); + error = scsi_mode_select_big(cd->sc_link, SMS_PF, + (struct scsi_mode_header_big *)&data, AUDIOPAGESIZE, flags, 20000); + + return (error); } static int diff --git a/sys/scsi/cd_scsi.c b/sys/scsi/cd_scsi.c index b148d4b15d8..760cdac868b 100644 --- a/sys/scsi/cd_scsi.c +++ b/sys/scsi/cd_scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd_scsi.c,v 1.6 2005/04/05 12:13:16 krw Exp $ */ +/* $OpenBSD: cd_scsi.c,v 1.7 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: cd_scsi.c,v 1.14 1998/08/31 22:28:06 cgd Exp $ */ /*- @@ -75,11 +75,6 @@ #include <scsi/scsiconf.h> #include <scsi/cdvar.h> -int cd_scsibus_get_mode(struct cd_softc *, - struct scsi_cd_mode_data *, int, int, int); -int cd_scsibus_set_mode(struct cd_softc *, - struct scsi_cd_mode_data *, int, int); - int cd_scsibus_setchan(struct cd_softc *, int, int, int, int, int); int cd_scsibus_getvol(struct cd_softc *, struct ioc_vol *, int); int cd_scsibus_setvol(struct cd_softc *, const struct ioc_vol *, @@ -95,37 +90,6 @@ const struct cd_ops cd_scsibus_ops = { cd_scsibus_load_unload, }; -/* - * Get the requested page into the buffer given - */ -int -cd_scsibus_get_mode(cd, data, page, len, flags) - struct cd_softc *cd; - struct scsi_cd_mode_data *data; - int page, len, flags; -{ - return scsi_mode_sense(cd->sc_link, 0, page, (u_char *)data, - len, flags, 20000); -} - -/* - * Get the requested page into the buffer given - */ -int -cd_scsibus_set_mode(cd, data, len, flags) - struct cd_softc *cd; - struct scsi_cd_mode_data *data; - int len, flags; -{ - /* SPC-2 revision 16, section 8.3: Mode parameters - When used with the [MODE SELECT command], the data - length field is reserved. */ - data->header.data_length = 0; - - return scsi_mode_select(cd->sc_link, SMS_PF, (u_char *)data, len, flags, - 20000); -} - int cd_scsibus_set_pa_immed(cd, flags) struct cd_softc *cd; @@ -134,12 +98,17 @@ cd_scsibus_set_pa_immed(cd, flags) struct scsi_cd_mode_data data; int error; - if ((error = cd_scsibus_get_mode(cd, &data, AUDIO_PAGE, - AUDIOPAGESIZE, flags)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense(cd->sc_link, 0, AUDIO_PAGE, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + data.page.audio.flags &= ~CD_PA_SOTC; data.page.audio.flags |= CD_PA_IMMED; - return (cd_scsibus_set_mode(cd, &data, AUDIOPAGESIZE, flags)); + + return (scsi_mode_select(cd->sc_link, SMS_PF, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000)); } int @@ -151,14 +120,19 @@ cd_scsibus_setchan(cd, p0, p1, p2, p3, flags) struct scsi_cd_mode_data data; int error; - if ((error = cd_scsibus_get_mode(cd, &data, AUDIO_PAGE, - AUDIOPAGESIZE, flags)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense(cd->sc_link, 0, AUDIO_PAGE, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + data.page.audio.port[LEFT_PORT].channels = p0; data.page.audio.port[RIGHT_PORT].channels = p1; data.page.audio.port[2].channels = p2; data.page.audio.port[3].channels = p3; - return (cd_scsibus_set_mode(cd, &data, AUDIOPAGESIZE, flags)); + + return (scsi_mode_select(cd->sc_link, SMS_PF, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000)); } int @@ -171,13 +145,17 @@ cd_scsibus_getvol(cd, arg, flags) struct scsi_cd_mode_data data; int error; - if ((error = cd_scsibus_get_mode(cd, &data, AUDIO_PAGE, - AUDIOPAGESIZE, flags)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense(cd->sc_link, 0, AUDIO_PAGE, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + arg->vol[LEFT_PORT] = data.page.audio.port[LEFT_PORT].volume; arg->vol[RIGHT_PORT] = data.page.audio.port[RIGHT_PORT].volume; arg->vol[2] = data.page.audio.port[2].volume; arg->vol[3] = data.page.audio.port[3].volume; + return (0); } @@ -190,16 +168,21 @@ cd_scsibus_setvol(cd, arg, flags) struct scsi_cd_mode_data data; int error; - if ((error = cd_scsibus_get_mode(cd, &data, AUDIO_PAGE, - AUDIOPAGESIZE, flags)) != 0) + bzero(&data, sizeof(data)); + error = scsi_mode_sense(cd->sc_link, 0, AUDIO_PAGE, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000); + if (error != 0) return (error); + data.page.audio.port[LEFT_PORT].channels = CHANNEL_0; data.page.audio.port[LEFT_PORT].volume = arg->vol[LEFT_PORT]; data.page.audio.port[RIGHT_PORT].channels = CHANNEL_1; data.page.audio.port[RIGHT_PORT].volume = arg->vol[RIGHT_PORT]; data.page.audio.port[2].volume = arg->vol[2]; data.page.audio.port[3].volume = arg->vol[3]; - return (cd_scsibus_set_mode(cd, &data, AUDIOPAGESIZE, flags)); + + return (scsi_mode_select(cd->sc_link, SMS_PF, + (struct scsi_mode_header *)&data, AUDIOPAGESIZE, flags, 20000)); } int diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index 45e8bcf0324..568a1eb9814 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ch.c,v 1.18 2005/04/05 12:13:16 krw Exp $ */ +/* $OpenBSD: ch.c,v 1.19 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */ /* @@ -627,8 +627,10 @@ ch_get_params(sc, flags) /* * Grab info from the element address assignment page (0x1d). */ + bzero(&sense_data, sizeof(sense_data)); error = scsi_mode_sense(sc->sc_link, SMS_DBD, 0x1d, - (u_char *)&sense_data, sizeof(sense_data), flags, 6000); + (struct scsi_mode_header *)&sense_data, sizeof(sense_data), flags, + 6000); if (error) { printf("%s: could not sense element address page\n", sc->sc_dev.dv_xname); @@ -649,8 +651,10 @@ ch_get_params(sc, flags) /* * Grab info from the capabilities page (0x1f). */ + bzero(&sense_data, sizeof(sense_data)); error = scsi_mode_sense(sc->sc_link, SMS_DBD, 0x1f, - (u_char *)&sense_data, sizeof(sense_data), flags, 6000); + (struct scsi_mode_header *)&sense_data, sizeof(sense_data), flags, + 6000); if (error) { printf("%s: could not sense capabilities page\n", sc->sc_dev.dv_xname); diff --git a/sys/scsi/files.scsi b/sys/scsi/files.scsi index 2b389411d3c..bc4073a77d5 100644 --- a/sys/scsi/files.scsi +++ b/sys/scsi/files.scsi @@ -1,4 +1,4 @@ -# $OpenBSD: files.scsi,v 1.13 2005/03/08 20:00:25 tdeval Exp $ +# $OpenBSD: files.scsi,v 1.14 2005/05/14 00:20:43 krw Exp $ # $NetBSD: files.scsi,v 1.4 1996/05/16 04:01:08 mycroft Exp $ # # Config.new file and device description for machine-independent SCSI code. @@ -8,7 +8,6 @@ file scsi/scsi_base.c scsi file scsi/scsi_ioctl.c scsi file scsi/scsiconf.c scsi -file scsi/atapi_base.c scsi device scsibus {[target = -1], [lun = -1]} attach scsibus at scsi diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 4797fd56209..a8981675c1a 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.67 2005/04/28 10:16:04 moritz Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.68 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -361,7 +361,7 @@ scsi_mode_sense(sc_link, byte2, page, data, len, flags, timeout) struct scsi_link *sc_link; int byte2, page, flags, timeout; size_t len; - u_char *data; + struct scsi_mode_header *data; { struct scsi_mode_sense scsi_cmd; int error; @@ -380,7 +380,7 @@ scsi_mode_sense(sc_link, byte2, page, data, len, flags, timeout) scsi_cmd.length = len & 0xff; error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), data, len, 4, timeout, NULL, + sizeof(scsi_cmd), (u_char *)data, len, 4, timeout, NULL, flags | SCSI_DATA_IN); SC_DEBUG(sc_link, SDEV_DB2, ("scsi_mode_sense: page %#x, error = %d\n", @@ -390,11 +390,44 @@ 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; +{ + struct scsi_mode_sense_big scsi_cmd; + int error; + + /* + * Make sure the sense buffer is clean before we do the mode sense, so + * that checks for bogus values of 0 will work in case the mode sense + * fails. + */ + bzero(data, len); + + bzero(&scsi_cmd, sizeof(scsi_cmd)); + scsi_cmd.opcode = MODE_SENSE_BIG; + scsi_cmd.byte2 = byte2; + scsi_cmd.page = page; + _lto2b(len, scsi_cmd.length); + + error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, + sizeof(scsi_cmd), (u_char *)data, len, 4, timeout, NULL, + flags | SCSI_DATA_IN); + + SC_DEBUG(sc_link, SDEV_DB2, + ("scsi_mode_sense_big: page %#x, error = %d\n", page, error)); + + return (error); +} + +int scsi_mode_select(sc_link, byte2, data, len, flags, timeout) struct scsi_link *sc_link; int byte2, flags, timeout; size_t len; - u_char *data; + struct scsi_mode_header *data; { struct scsi_mode_select scsi_cmd; int error; @@ -404,8 +437,11 @@ scsi_mode_select(sc_link, byte2, data, len, flags, timeout) scsi_cmd.byte2 = byte2; scsi_cmd.length = len & 0xff; + /* Length is reserved when doing mode select so zero it. */ + data->data_length = 0; + error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), data, len, 4, timeout, NULL, + sizeof(scsi_cmd), (u_char *)data, len, 4, timeout, NULL, flags | SCSI_DATA_OUT); SC_DEBUG(sc_link, SDEV_DB2, ("scsi_mode_select: error = %d\n", error)); @@ -413,6 +449,34 @@ scsi_mode_select(sc_link, byte2, data, len, flags, timeout) return (error); } +int +scsi_mode_select_big(sc_link, byte2, data, len, flags, timeout) + struct scsi_link *sc_link; + int byte2, flags, timeout; + size_t len; + struct scsi_mode_header_big *data; +{ + struct scsi_mode_select_big scsi_cmd; + int error; + + bzero(&scsi_cmd, sizeof(scsi_cmd)); + scsi_cmd.opcode = MODE_SELECT_BIG; + scsi_cmd.byte2 = byte2; + _lto2b(len, scsi_cmd.length); + + /* Length is reserved when doing mode select so zero it. */ + _lto2b(0, data->data_length); + + error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, + sizeof(scsi_cmd), (u_char *)data, len, 4, timeout, NULL, + flags | SCSI_DATA_OUT); + + SC_DEBUG(sc_link, SDEV_DB2, ("scsi_mode_select_big: error = %d\n", + error)); + + return (error); +} + /* * This routine is called by the scsi interrupt when the transfer is complete. */ diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index d4469361366..52c09756127 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.51 2005/04/27 23:54:44 krw Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.52 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -331,10 +331,14 @@ int scsi_test_unit_ready(struct scsi_link *, int, int); int scsi_inquire(struct scsi_link *, struct scsi_inquiry_data *, int); int scsi_prevent(struct scsi_link *, int, int); int scsi_start(struct scsi_link *, int, int); -int scsi_mode_sense(struct scsi_link *, int, int, u_char *, size_t, - int, int); -int scsi_mode_select(struct scsi_link *, int, u_char *, size_t, int, - int); +int scsi_mode_sense(struct scsi_link *, int, int, struct scsi_mode_header *, + size_t, int, int); +int scsi_mode_sense_big(struct scsi_link *, int, int, + struct scsi_mode_header_big *, size_t, int, int); +int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *, + size_t, int, int); +int scsi_mode_select_big(struct scsi_link *, int, + struct scsi_mode_header_big *, size_t, int, int); void scsi_done(struct scsi_xfer *); void scsi_user_done(struct scsi_xfer *); int scsi_scsi_cmd(struct scsi_link *, struct scsi_generic *, diff --git a/sys/scsi/sd_atapi.c b/sys/scsi/sd_atapi.c index 52d3827c514..731d100b258 100644 --- a/sys/scsi/sd_atapi.c +++ b/sys/scsi/sd_atapi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd_atapi.c,v 1.5 2005/04/16 16:41:46 krw Exp $ */ +/* $OpenBSD: sd_atapi.c,v 1.6 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: sd_atapi.c,v 1.3 1998/08/31 22:28:07 cgd Exp $ */ /* @@ -54,7 +54,6 @@ #include <scsi/scsi_all.h> #include <scsi/scsi_disk.h> #include <scsi/scsiconf.h> -#include <scsi/atapi_all.h> #include <scsi/atapi_disk.h> #include <scsi/sdvar.h> @@ -127,9 +126,10 @@ sd_atapibus_get_parms(sd, dp, flags) if (dp->disksize == 0) return (SDGP_RESULT_OFFLINE); - error = atapi_mode_sense(sd->sc_link, ATAPI_FLEX_GEOMETRY_PAGE, + bzero(&sense_data, sizeof(sense_data)); + error = scsi_mode_sense_big(sd->sc_link, 0, ATAPI_FLEX_GEOMETRY_PAGE, (struct scsi_mode_header_big *)&sense_data, FLEXGEOMETRYPAGESIZE, - flags, SDRETRIES, 20000); + flags, 20000); SC_DEBUG(sd->sc_link, SDEV_DB2, ("sd_atapibus_get_parms: mode sense (flex) error=%d\n", error)); if (error == 0) { diff --git a/sys/scsi/sd_scsi.c b/sys/scsi/sd_scsi.c index 5018fd55c8a..d6498e66943 100644 --- a/sys/scsi/sd_scsi.c +++ b/sys/scsi/sd_scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd_scsi.c,v 1.8 2005/05/07 16:24:46 krw Exp $ */ +/* $OpenBSD: sd_scsi.c,v 1.9 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: sd_scsi.c,v 1.8 1998/10/08 20:21:13 thorpej Exp $ */ /*- @@ -76,8 +76,6 @@ struct sd_scsibus_mode_sense_data { union scsi_disk_pages pages; }; -int sd_scsibus_mode_sense(struct sd_softc *, - struct sd_scsibus_mode_sense_data *, int, int); int sd_scsibus_get_parms(struct sd_softc *, struct disk_parms *, int); int sd_scsibus_get_optparms(struct sd_softc *, @@ -90,16 +88,6 @@ const struct sd_ops sd_scsibus_ops = { }; int -sd_scsibus_mode_sense(sd, scsi_sense, page, flags) - struct sd_softc *sd; - struct sd_scsibus_mode_sense_data *scsi_sense; - int page, flags; -{ - return scsi_mode_sense(sd->sc_link, 0, page, (u_char *)scsi_sense, - sizeof(*scsi_sense), flags | SCSI_SILENT, 6000); -} - -int sd_scsibus_get_optparms(sd, dp, flags) struct sd_softc *sd; struct disk_parms *dp; @@ -119,8 +107,10 @@ sd_scsibus_get_optparms(sd, dp, flags) * However, there are stupid optical devices which does NOT * support the page 6. Ask for all (0x3f) pages. Ghaa.... */ - error = scsi_mode_sense(sd->sc_link, 0, 0x3f, (u_char *)&scsi_sense, - sizeof(scsi_sense), flags, 6000); + bzero(&scsi_sense, sizeof(scsi_sense)); + error = scsi_mode_sense(sd->sc_link, 0, 0x3f, + (struct scsi_mode_header *)&scsi_sense, sizeof(scsi_sense), flags, + 6000); if (error != 0) return (SDGP_RESULT_OFFLINE); /* XXX? */ @@ -162,8 +152,11 @@ sd_scsibus_get_parms(sd, dp, flags) if (sd->type == T_OPTICAL) return (sd_scsibus_get_optparms(sd, dp, flags)); - if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 4, - flags)) == 0) { + bzero(&scsi_sense, sizeof(scsi_sense)); + error = scsi_mode_sense(sd->sc_link, 0, page = 4, + (struct scsi_mode_header *)&scsi_sense, sizeof(scsi_sense), + flags | SCSI_SILENT, 6000); + if (error == 0) { sense_pages = (union scsi_disk_pages *) ((char *)&scsi_sense.blk_desc + (size_t)scsi_sense.header.blk_desc_len); @@ -208,8 +201,11 @@ sd_scsibus_get_parms(sd, dp, flags) return (SDGP_RESULT_OK); } - if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 5, - flags)) == 0) { + bzero(&scsi_sense, sizeof(scsi_sense)); + error = scsi_mode_sense(sd->sc_link, 0, page = 5, + (struct scsi_mode_header *)&scsi_sense, sizeof(scsi_sense), + flags | SCSI_SILENT, 6000); + if (error == 0) { sense_pages = (union scsi_disk_pages *) ((char *)&scsi_sense.blk_desc + (size_t)scsi_sense.header.blk_desc_len); @@ -233,8 +229,11 @@ sd_scsibus_get_parms(sd, dp, flags) } /* T_RDIRECT define page 6. */ - if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 6, - flags)) == 0) { + bzero(&scsi_sense, sizeof(scsi_sense)); + error = scsi_mode_sense(sd->sc_link, 0, page = 6, + (struct scsi_mode_header *)&scsi_sense, sizeof(scsi_sense), + flags | SCSI_SILENT, 6000); + if (error == 0) { sense_pages = (union scsi_disk_pages *) ((char *)&scsi_sense.blk_desc + (size_t)scsi_sense.header.blk_desc_len); diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c index aa37da6151e..e9f53e4ac1c 100644 --- a/sys/scsi/ss_mustek.c +++ b/sys/scsi/ss_mustek.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ss_mustek.c,v 1.10 2005/04/05 12:13:16 krw Exp $ */ +/* $OpenBSD: ss_mustek.c,v 1.11 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: ss_mustek.c,v 1.4 1996/05/05 19:52:57 christos Exp $ */ /* @@ -336,8 +336,8 @@ mustek_trigger_scanner(ss) SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n")); /* send the command to the scanner */ - error = scsi_mode_select(sc_link, 0, (u_char *)&mode_data, - sizeof(mode_data), 0, 5000); + error = scsi_mode_select(sc_link, 0, + (struct scsi_mode_header *)&mode_data, sizeof(mode_data), 0, 5000); if (error) return (error); diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 9a58d5ade0c..9bdb5ba1204 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.45 2005/04/06 02:51:13 krw Exp $ */ +/* $OpenBSD: st.c,v 1.46 2005/05/14 00:20:43 krw Exp $ */ /* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */ /* @@ -1443,8 +1443,10 @@ st_mode_sense(st, flags) /* * Ask for page 0 mode sense data. */ - error = scsi_mode_sense(sc_link, 0, 0, (u_char *)&scsi_sense, - scsi_sense_len, flags, ST_CTL_TIME); + bzero(&scsi_sense, sizeof(scsi_sense)); + error = scsi_mode_sense(sc_link, 0, 0, + (struct scsi_mode_header *)&scsi_sense, scsi_sense_len, flags, + ST_CTL_TIME); if (error) return error; @@ -1521,8 +1523,9 @@ st_mode_select(st, flags) /* * do the command */ - return scsi_mode_select(st->sc_link, 0, (u_char *)&scsi_select, - scsi_select_len, flags, ST_CTL_TIME); + return (scsi_mode_select(st->sc_link, 0, + (struct scsi_mode_header *)&scsi_select, scsi_select_len, flags, + ST_CTL_TIME)); } /* |