Do a 36-byte SCSI 2 inquiry first, and iff that returns an additional length

>32 do a 74-byte inquiry.  Fixes problems with devices that barf on longer
inquiries.  (Linux uses 36 bytes almost everywhere, as a data point.)
This commit is contained in:
mycroft 2003-10-16 17:34:43 +00:00
parent cd026bf62c
commit 0f1275cee2
2 changed files with 15 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsipi_all.h,v 1.24 2003/09/08 03:33:31 mycroft Exp $ */
/* $NetBSD: scsipi_all.h,v 1.25 2003/10/16 17:34:43 mycroft Exp $ */
/*
* SCSI and SCSI-like general interface description
@ -280,6 +280,7 @@ struct scsipi_inquiry_data {
/* 9*/ char vendor[8];
/*17*/ char product[16];
/*33*/ char revision[4];
#define SCSIPI_INQUIRY_LENGTH_SCSI2 36
/*37*/ u_int8_t vendor_specific[20];
/*57*/ u_int8_t flags4;
#define SID_IUS 0x01
@ -290,6 +291,7 @@ struct scsipi_inquiry_data {
#define SID_CLOCKING_SD_DT 0x0C
/*58*/ u_int8_t reserved;
/*59*/ char version_descriptor[8][2];
#define SCSIPI_INQUIRY_LENGTH_SCSI3 74
} __attribute__((packed)); /* 74 Bytes */
/* Data structures for mode select/mode sense */

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsipi_base.c,v 1.95 2003/10/12 03:21:56 thorpej Exp $ */
/* $NetBSD: scsipi_base.c,v 1.96 2003/10/16 17:34:43 mycroft Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.95 2003/10/12 03:21:56 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.96 2003/10/16 17:34:43 mycroft Exp $");
#include "opt_scsi.h"
@ -1083,8 +1083,13 @@ scsipi_inquire(periph, inqbuf, flags)
error = scsipi_command(periph,
(struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
(u_char *) inqbuf, sizeof(struct scsipi_inquiry_data),
(u_char *) inqbuf, SCSIPI_INQUIRY_LENGTH_SCSI2,
retries, 10000, NULL, XS_CTL_DATA_IN | flags);
if (!error && inqbuf->additional_length > SCSIPI_INQUIRY_LENGTH_SCSI2 - 4)
error = scsipi_command(periph,
(struct scsipi_generic *) &scsipi_cmd, sizeof(scsipi_cmd),
(u_char *) inqbuf, SCSIPI_INQUIRY_LENGTH_SCSI3,
retries, 10000, NULL, XS_CTL_DATA_IN | flags);
#ifdef SCSI_OLD_NOINQUIRY
/*
@ -1101,12 +1106,9 @@ scsipi_inquire(periph, inqbuf, flags)
inqbuf->dev_qual2 = 0;
inqbuf->version = 0;
inqbuf->response_format = SID_FORMAT_SCSI1;
inqbuf->additional_length = 3 + 28;
inqbuf->additional_length = SCSIPI_INQUIRY_LENGTH_SCSI2 - 4;
inqbuf->flags1 = inqbuf->flags2 = inqbuf->flags3 = 0;
memcpy(inqbuf->vendor, "ADAPTEC ", sizeof(inqbuf->vendor));
memcpy(inqbuf->product, "ACB-4000 ",
sizeof(inqbuf->product));
memcpy(inqbuf->revision, " ", sizeof(inqbuf->revision));
memcpy(inqbuf->vendor, "ADAPTEC ACB-4000 ", 28);
error = 0;
}
@ -1124,12 +1126,9 @@ scsipi_inquire(periph, inqbuf, flags)
*/
inqbuf->device = (SID_QUAL_LU_PRESENT | T_SEQUENTIAL);
inqbuf->dev_qual2 = SID_REMOVABLE;
inqbuf->additional_length = 3 + 28;
inqbuf->additional_length = SCSIPI_INQUIRY_LENGTH_SCSI2 - 4;
inqbuf->flags1 = inqbuf->flags2 = inqbuf->flags3 = 0;
memcpy(inqbuf->vendor, "EMULEX ", sizeof(inqbuf->vendor));
memcpy(inqbuf->product, "MT-02 QIC ",
sizeof(inqbuf->product));
memcpy(inqbuf->revision, " ", sizeof(inqbuf->revision));
memcpy(inqbuf->vendor, "EMULEX MT-02 QIC ", 28);
}
#endif /* SCSI_OLD_NOINQUIRY */