From: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
To: torvalds@transmeta.com, Linux SCSI list <linux-scsi@vger.kernel.org>
Cc: Greg KH <greg@kroah.com>,
USB Developers <linux-usb-devel@lists.sourceforge.net>
Subject: PATCH; make sr.c respect use_10_for_ms
Date: Sat, 21 Jun 2003 16:59:20 -0700 [thread overview]
Message-ID: <20030621165920.F2811@one-eyed-alien.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 3375 bytes --]
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 mdharm@zen.san.one-eyed-alien.net 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: mdharm-usb@one-eyed-alien.net
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
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
next reply other threads:[~2003-06-21 23:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-21 23:59 Matthew Dharm [this message]
2003-06-22 0:07 ` PATCH; make sr.c respect use_10_for_ms Linus Torvalds
2003-06-22 0:12 ` Matthew Dharm
2003-06-22 0:21 ` Linus Torvalds
2003-06-22 0:30 ` Matthew Dharm
2003-06-22 0:38 ` Linus Torvalds
2003-06-22 0:46 ` Matthew Dharm
2003-06-22 0:25 ` James Bottomley
2003-06-22 0:46 ` Matthew Dharm
2003-06-22 2:54 ` James Bottomley
2003-06-22 4:24 ` Matthew Dharm
2003-06-22 5:05 ` Douglas Gilbert
2003-06-22 13:58 ` James Bottomley
2003-06-22 19:49 ` Matthew Dharm
2003-06-22 19:56 ` Matthew Dharm
2003-06-22 20:37 ` James Bottomley
2003-06-22 21:06 ` Matthew Dharm
2003-06-23 14:33 ` James Bottomley
2003-06-23 17:30 ` Matthew Dharm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030621165920.F2811@one-eyed-alien.net \
--to=mdharm-usb@one-eyed-alien.net \
--cc=greg@kroah.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox