This patch makes sr.c respect the use_10_for_ms flag. The old behavior was to try the 6-byte command, and if it fails make some assumptions.
The new behavior is to first try the 10-bit version (only if use_10_for_ms
is set), the fall back to the old behavior.
With this patch, we should be able to cut out a few hundred lines of
problematic code in usb-storage.
Linus, please apply.
Matt
# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.709 -> 1.710
# drivers/scsi/sr.c 1.47 -> 1.48
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/06/20 [EMAIL PROTECTED] 1.710
# Make SCSI CD-ROM driver respect the use_10_for_ms flag.
# --------------------------------------------
#
diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
--- a/drivers/scsi/sr.c Fri Jun 20 17:34:56 2003
+++ b/drivers/scsi/sr.c Fri Jun 20 17:34:56 2003
@@ -663,7 +663,7 @@
{
struct cdrom_generic_command cgc;
unsigned char *buffer;
- int rc, n;
+ int n, rc = 0;
static char *loadmech[] =
{
@@ -682,16 +682,38 @@
printk(KERN_ERR "sr: out of memory.\n");
return;
}
- memset(&cgc, 0, sizeof(struct cdrom_generic_command));
- cgc.cmd[0] = MODE_SENSE;
- cgc.cmd[2] = 0x2a;
- cgc.cmd[4] = 128;
- cgc.buffer = buffer;
- cgc.buflen = 128;
- cgc.quiet = 1;
- cgc.data_direction = SCSI_DATA_READ;
- cgc.timeout = SR_TIMEOUT;
- rc = sr_do_ioctl(cd, &cgc);
+
+ /* first, attempt 10-byte command */
+ if (cd->device->use_10_for_ms) {
+ memset(&cgc, 0, sizeof(struct cdrom_generic_command));
+ cgc.cmd[0] = MODE_SENSE_10;
+ cgc.cmd[2] = 0x2a; /* page code */
+ cgc.cmd[8] = 128; /* allocation length */
+ cgc.buffer = buffer;
+ cgc.buflen = 128;
+ cgc.quiet = 1;
+ cgc.data_direction = SCSI_DATA_READ;
+ cgc.timeout = SR_TIMEOUT;
+ rc = sr_do_ioctl(cd, &cgc);
+ }
+
+ /* if we got an error, return to old behavior */
+ if (rc)
+ cd->device->use_10_for_ms = 0;
+
+ /* issue 6-byte command */
+ if (!cd->device->use_10_for_ms) {
+ memset(&cgc, 0, sizeof(struct cdrom_generic_command));
+ cgc.cmd[0] = MODE_SENSE;
+ cgc.cmd[2] = 0x2a; /* page code */
+ cgc.cmd[4] = 128; /* allocation length */
+ cgc.buffer = buffer;
+ cgc.buflen = 128;
+ cgc.quiet = 1;
+ cgc.data_direction = SCSI_DATA_READ;
+ cgc.timeout = SR_TIMEOUT;
+ rc = sr_do_ioctl(cd, &cgc);
+ }
if (rc) {
/* failed, drive doesn't have capabilities mode page */
@@ -703,7 +725,13 @@
printk("%s: scsi-1 drive\n", cd->cdi.name);
return;
}
- n = buffer[3] + 4;
+
+ /* calculate the start of the page */
+ if (cd->device->use_10_for_ms)
+ n = (buffer[6] << 8) + buffer[7] + 8;
+ else
+ n = buffer[3] + 4;
+
cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
cd->readcd_known = 1;
cd->readcd_cdda = buffer[n + 5] & 0x01;
--
Matthew Dharm Home: [EMAIL PROTECTED]
Maintainer, Linux USB Mass Storage Driver
P: How about "Web Designer"?
DP: I'd like a name that people won't laugh at.
-- Pitr and Dust Puppy
User Friendly, 12/6/1997
pgp00000.pgp
Description: PGP signature
