summaryrefslogtreecommitdiff
path: root/sys/scsi/cd_scsi.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-04-05 12:13:17 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-04-05 12:13:17 +0000
commit6925dcc5a6aeebcfd28fd678a39f45cd5e642fc4 (patch)
treeedff0ec67ee1aff67ce310d4cb4f112eb8f2621e /sys/scsi/cd_scsi.c
parentb4e7d5833ec209b9297616ebee0f72301a626151 (diff)
Factor out scsi_mode_sense() and scsi_mode_select() like NetBSD does.
Eliminate some duplicate structures and defines along the way. SCSI CD drives will now pay attention to the 'flags' parameter for MODE SENSE and MODE SELECT commands. No other functional change. ok tdeval@
Diffstat (limited to 'sys/scsi/cd_scsi.c')
-rw-r--r--sys/scsi/cd_scsi.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/sys/scsi/cd_scsi.c b/sys/scsi/cd_scsi.c
index a423823d0b6..b148d4b15d8 100644
--- a/sys/scsi/cd_scsi.c
+++ b/sys/scsi/cd_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd_scsi.c,v 1.5 2004/05/09 14:08:11 krw Exp $ */
+/* $OpenBSD: cd_scsi.c,v 1.6 2005/04/05 12:13:16 krw Exp $ */
/* $NetBSD: cd_scsi.c,v 1.14 1998/08/31 22:28:06 cgd Exp $ */
/*-
@@ -104,25 +104,8 @@ cd_scsibus_get_mode(cd, data, page, len, flags)
struct scsi_cd_mode_data *data;
int page, len, flags;
{
- struct scsi_mode_sense scsi_cmd;
-
-#ifdef DIAGNOSTIC
- if (len == 0 || len > 256) {
- printf ("cd_scsibus_get_mode: Mode page %02x request "
- "bad size: %d bytes\n", page, len);
- return (EINVAL);
- }
-#endif
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- bzero(data, sizeof(*data));
- scsi_cmd.opcode = MODE_SENSE;
- scsi_cmd.page = page;
- scsi_cmd.length = len & 0xff;
- return (scsi_scsi_cmd(cd->sc_link,
- (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
- (u_char *)data, len, CDRETRIES, 20000, NULL,
- SCSI_DATA_IN));
+ return scsi_mode_sense(cd->sc_link, 0, page, (u_char *)data,
+ len, flags, 20000);
}
/*
@@ -134,30 +117,13 @@ cd_scsibus_set_mode(cd, data, len, flags)
struct scsi_cd_mode_data *data;
int len, flags;
{
- struct scsi_mode_select scsi_cmd;
-
-#ifdef DIAGNOSTIC
- if (len == 0 || len > 256) {
- printf ("cd_scsibus_set_mode: Set mode request "
- "bad size: %d bytes\n", len);
- return (EINVAL);
- }
-#endif
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = MODE_SELECT;
- scsi_cmd.byte2 |= SMS_PF;
- scsi_cmd.length = len & 0xff;
-
/* 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_scsi_cmd(cd->sc_link,
- (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
- (u_char *)data, len, CDRETRIES, 20000, NULL,
- SCSI_DATA_OUT));
+ return scsi_mode_select(cd->sc_link, SMS_PF, (u_char *)data, len, flags,
+ 20000);
}
int