Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi Attempt to deal with Martin's weirdass Sun dr...
details: https://anonhg.NetBSD.org/src/rev/2c49652e0b9b
branches: trunk
changeset: 551590:2c49652e0b9b
user: mycroft <mycroft%NetBSD.org@localhost>
date: Mon Sep 08 16:16:43 2003 +0000
description:
Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.
Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.
diffstat:
sys/dev/scsipi/cd.c | 121 +++++++++++++++++++++------------------------------
1 files changed, 51 insertions(+), 70 deletions(-)
diffs (215 lines):
diff -r fff62fa870d8 -r 2c49652e0b9b sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c Mon Sep 08 16:07:15 2003 +0000
+++ b/sys/dev/scsipi/cd.c Mon Sep 08 16:16:43 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.190 2003/09/08 01:56:33 mycroft Exp $ */
+/* $NetBSD: cd.c,v 1.191 2003/09/08 16:16:43 mycroft Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.190 2003/09/08 01:56:33 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.191 2003/09/08 16:16:43 mycroft Exp $");
#include "rnd.h"
@@ -140,6 +140,8 @@
static int cd_mode_sense __P((struct cd_softc *, u_int8_t, void *, size_t, int,
int, int *));
+static int cd_mode_select __P((struct cd_softc *, u_int8_t, void *, size_t,
+ int, int));
int cd_setchan __P((struct cd_softc *, int, int, int, int, int));
int cd_getvol __P((struct cd_softc *, struct ioc_vol *, int));
int cd_setvol __P((struct cd_softc *, const struct ioc_vol *, int));
@@ -2214,13 +2216,39 @@
if (cd->sc_periph->periph_quirks & PQUIRK_ONLYBIG) {
*big = 1;
return scsipi_mode_sense_big(cd->sc_periph, byte2, page, sense,
- size, flags | XS_CTL_SILENT | XS_CTL_DATA_ONSTACK,
- CDRETRIES, 20000);
+ size + sizeof(struct scsipi_mode_header_big),
+ flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000);
} else {
*big = 0;
return scsipi_mode_sense(cd->sc_periph, byte2, page, sense,
- size, flags | XS_CTL_SILENT | XS_CTL_DATA_ONSTACK,
- CDRETRIES, 20000);
+ size + sizeof(struct scsipi_mode_header),
+ flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000);
+ }
+}
+
+static int
+cd_mode_select(cd, byte2, sense, size, flags, big)
+ struct cd_softc *cd;
+ u_int8_t byte2;
+ void *sense;
+ size_t size;
+ int flags, big;
+{
+
+ if (big) {
+ struct scsipi_mode_header_big *header = sense;
+
+ _lto2b(0, header->data_length);
+ return scsipi_mode_select_big(cd->sc_periph, byte2, sense,
+ size + sizeof(struct scsipi_mode_header_big),
+ flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000);
+ } else {
+ struct scsipi_mode_header *header = sense;
+
+ header->data_length = 0;
+ return scsipi_mode_select(cd->sc_periph, byte2, sense,
+ size + sizeof(struct scsipi_mode_header_big),
+ flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000);
}
}
@@ -2241,7 +2269,7 @@
int big;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data),
+ if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
AUDIO_PAGE, flags, &big)) != 0)
return (error);
@@ -2256,21 +2284,9 @@
if (oflags == page->flags)
return (0);
- if (big) {
- _lto2b(0, data.header.big.data_length);
- return (scsipi_mode_select_big(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.big) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- } else {
- data.header.small.data_length = 0;
- return (scsipi_mode_select(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.small) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- }
+ return (cd_mode_select(cd, SMS_PF, &data,
+ sizeof(struct scsipi_mode_page_header) + page->pg_length,
+ flags, big));
}
int
@@ -2290,7 +2306,7 @@
int big;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data),
+ if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
AUDIO_PAGE, flags, &big)) != 0)
return (error);
@@ -2304,21 +2320,9 @@
page->port[2].channels = p2;
page->port[3].channels = p3;
- if (big) {
- _lto2b(0, data.header.big.data_length);
- return (scsipi_mode_select_big(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.big) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- } else {
- data.header.small.data_length = 0;
- return (scsipi_mode_select(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.small) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- }
+ return (cd_mode_select(cd, SMS_PF, &data,
+ sizeof(struct scsipi_mode_page_header) + page->pg_length,
+ flags, big));
}
int
@@ -2338,7 +2342,7 @@
int big;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data),
+ if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
AUDIO_PAGE, flags, &big)) != 0)
return (error);
@@ -2372,10 +2376,10 @@
int big;
struct cd_audio_page *page, *page2;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data),
+ if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
AUDIO_PAGE, flags, &big)) != 0)
return (error);
- if ((error = cd_mode_sense(cd, SMS_DBD, &mask, sizeof(mask),
+ if ((error = cd_mode_sense(cd, SMS_DBD, &mask, sizeof(mask.page),
AUDIO_PAGE|SMS_PAGE_CTRL_CHANGEABLE, flags, &big)) != 0)
return (error);
@@ -2395,21 +2399,9 @@
page->port[0].channels = CHANNEL_0;
page->port[1].channels = CHANNEL_1;
- if (big) {
- _lto2b(0, data.header.big.data_length);
- return (scsipi_mode_select_big(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.big) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- } else {
- data.header.small.data_length = 0;
- return (scsipi_mode_select(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.small) +
- sizeof(struct scsipi_mode_page_header) +
- page->pg_length,
- flags | XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- }
+ return (cd_mode_select(cd, SMS_PF, &data,
+ sizeof(struct scsipi_mode_page_header) + page->pg_length,
+ flags, big));
}
int
@@ -2444,7 +2436,7 @@
int big, bsize;
struct scsi_blk_desc *bdesc;
- if ((error = cd_mode_sense(cd, 0, &data, sizeof(data), 0, 0,
+ if ((error = cd_mode_sense(cd, 0, &data, sizeof(data.blk_desc), 0, 0,
&big)) != 0)
return (error);
@@ -2467,17 +2459,6 @@
_lto3b(2048, bdesc->blklen);
- if (big) {
- _lto2b(0, data.header.big.data_length);
- return (scsipi_mode_select_big(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.big) +
- sizeof(struct scsi_blk_desc),
- XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- } else {
- data.header.small.data_length = 0;
- return (scsipi_mode_select(cd->sc_periph, SMS_PF,
- (void *)&data, sizeof(data.header.small) +
- sizeof(struct scsi_blk_desc),
- XS_CTL_DATA_ONSTACK, CDRETRIES, 20000));
- }
+ return (cd_mode_select(cd, SMS_PF, &data,
+ sizeof(struct scsi_blk_desc), 0, big));
}
Home |
Main Index |
Thread Index |
Old Index