All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@SteelEye.com>
To: Matthew Wilcox <willy@debian.org>
Cc: Patrick Mansfield <patmans@us.ibm.com>,
	Mikael Pettersson <mikpe@csd.uu.se>,
	Andrew Morton <akpm@osdl.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: 2.6.8.1-mm3
Date: 24 Aug 2004 23:50:33 -0400	[thread overview]
Message-ID: <1093405836.2206.447.camel@mulgrave> (raw)
In-Reply-To: <20040821214733.GE9660@parcelfarce.linux.theplanet.co.uk>

On Sat, 2004-08-21 at 17:47, Matthew Wilcox wrote:
> I prefer the former, something like
> 
> int scsi_test_unit_ready(struct scsi_device *sdev);

OK, how about the attached.  It seems to work for me, but then I don't
have any of the problem devices ...

James

===== drivers/scsi/scsi_ioctl.c 1.29 vs edited =====
--- 1.29/drivers/scsi/scsi_ioctl.c	2004-08-19 16:11:54 -05:00
+++ edited/drivers/scsi/scsi_ioctl.c	2004-08-24 22:34:39 -05:00
@@ -432,12 +432,8 @@
 	case SCSI_IOCTL_DOORUNLOCK:
 		return scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
 	case SCSI_IOCTL_TEST_UNIT_READY:
-		scsi_cmd[0] = TEST_UNIT_READY;
-		scsi_cmd[1] = 0;
-		scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
-		scsi_cmd[4] = 0;
-		return ioctl_internal_command(sdev, scsi_cmd,
-				   IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
+		return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT,
+					    NORMAL_RETRIES);
 	case SCSI_IOCTL_START_UNIT:
 		scsi_cmd[0] = START_STOP;
 		scsi_cmd[1] = 0;
===== drivers/scsi/scsi_lib.c 1.130 vs edited =====
--- 1.130/drivers/scsi/scsi_lib.c	2004-08-23 03:14:46 -05:00
+++ edited/drivers/scsi/scsi_lib.c	2004-08-24 22:08:51 -05:00
@@ -1572,6 +1572,34 @@
 	return ret;
 }
 
+int
+scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries)
+{
+	struct scsi_request *sreq;
+	char cmd[] = {
+		TEST_UNIT_READY, 0, 0, 0, 0, 0,
+	};
+	int result;
+	
+	sreq = scsi_allocate_request(sdev, GFP_KERNEL);
+	if (!sreq)
+		return -ENOMEM;
+
+		sreq->sr_data_direction = DMA_NONE;
+        scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
+
+	if ((driver_byte(sreq->sr_result) & DRIVER_SENSE)
+	    && (sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION
+	    && sdev->removable) {
+		sdev->changed = 1;
+		sreq->sr_result = 0;
+	}
+	result = sreq->sr_result;
+	scsi_release_request(sreq);
+	return result;
+}
+EXPORT_SYMBOL(scsi_test_unit_ready);
+
 /**
  *	scsi_device_set_state - Take the given device through the device
  *		state model.
===== drivers/scsi/sd.c 1.157 vs edited =====
--- 1.157/drivers/scsi/sd.c	2004-08-24 18:09:03 -05:00
+++ edited/drivers/scsi/sd.c	2004-08-24 22:36:10 -05:00
@@ -648,7 +648,7 @@
 	 */
 	retval = -ENODEV;
 	if (scsi_block_when_processing_errors(sdp))
-		retval = scsi_ioctl(sdp, SCSI_IOCTL_TEST_UNIT_READY, NULL);
+		retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES);
 
 	/*
 	 * Unable to test, unit probably not ready.   This usually
===== drivers/scsi/sr.c 1.114 vs edited =====
--- 1.114/drivers/scsi/sr.c	2004-08-12 19:03:53 -05:00
+++ edited/drivers/scsi/sr.c	2004-08-24 22:39:41 -05:00
@@ -183,7 +183,7 @@
 		return -EINVAL;
 	}
 
-	retval = scsi_ioctl(cd->device, SCSI_IOCTL_TEST_UNIT_READY, NULL);
+	retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES);
 	if (retval) {
 		/* Unable to test, unit probably not ready.  This usually
 		 * means there is no disc in the drive.  Mark as changed,
===== include/scsi/scsi_device.h 1.21 vs edited =====
--- 1.21/include/scsi/scsi_device.h	2004-08-22 20:06:22 -05:00
+++ edited/include/scsi/scsi_device.h	2004-08-24 22:11:48 -05:00
@@ -185,6 +185,8 @@
 extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 			   unsigned char *buffer, int len, int timeout,
 			   int retries, struct scsi_mode_data *data);
+extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
+				int retries);
 extern int scsi_device_set_state(struct scsi_device *sdev,
 				 enum scsi_device_state state);
 extern int scsi_device_quiesce(struct scsi_device *sdev);


  reply	other threads:[~2004-08-25  3:51 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-21 18:38 2.6.8.1-mm3 Mikael Pettersson
2004-08-21 19:14 ` 2.6.8.1-mm3 Patrick Mansfield
2004-08-21 19:24   ` 2.6.8.1-mm3 James Bottomley
2004-08-21 21:47     ` 2.6.8.1-mm3 Matthew Wilcox
2004-08-25  3:50       ` James Bottomley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-08-21 17:15 2.6.8.1-mm3 Mikael Pettersson
2004-08-21 14:43 2.6.8.1-mm3 Mikael Pettersson
2004-08-21 16:02 ` 2.6.8.1-mm3 James Bottomley
2004-08-20 10:19 2.6.8.1-mm3 Andrew Morton
2004-08-20 11:46 ` 2.6.8.1-mm3 Russell King
2004-08-20 15:44 ` 2.6.8.1-mm3 Jesse Barnes
2004-08-20 16:57   ` 2.6.8.1-mm3 Jesse Barnes
2004-08-20 17:08     ` 2.6.8.1-mm3 Jesse Barnes
2004-08-20 18:55     ` 2.6.8.1-mm3 Andrew Morton
2004-08-20 19:56       ` 2.6.8.1-mm3 Jesse Barnes
2004-08-20 20:02       ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-20 23:31         ` 2.6.8.1-mm3 Anton Blanchard
2004-08-21  0:03           ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-21  7:04             ` 2.6.8.1-mm3 Martin J. Bligh
2004-08-21 15:22             ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-21 19:59         ` 2.6.8.1-mm3 Jesse Barnes
2004-08-21 20:24           ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-21 20:35             ` 2.6.8.1-mm3 Jesse Barnes
2004-08-23  9:02         ` 2.6.8.1-mm3 David Mosberger
2004-08-23 16:27           ` 2.6.8.1-mm3 wli
2004-08-23 18:18             ` 2.6.8.1-mm3 Jesse Barnes
2004-08-24  7:24             ` 2.6.8.1-mm3 David Mosberger
2004-08-20 18:46   ` 2.6.8.1-mm3 Jesse Barnes
2004-08-21  1:26   ` 2.6.8.1-mm3 Nick Piggin
2004-08-21 20:05     ` 2.6.8.1-mm3 Jesse Barnes
2004-08-22  1:27       ` 2.6.8.1-mm3 Jesse Barnes
2004-08-22  2:11         ` 2.6.8.1-mm3 Nick Piggin
2004-08-22 15:44           ` 2.6.8.1-mm3 Jesse Barnes
2004-08-21 17:37 ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-22 13:02   ` 2.6.8.1-mm3 William Lee Irwin III
2004-08-21 18:51 ` 2.6.8.1-mm3 R. J. Wysocki
2004-08-22  4:32 ` 2.6.8.1-mm3 Thomas Davis
2004-08-22  4:48   ` 2.6.8.1-mm3 Andrew Morton
2004-08-22  4:58     ` 2.6.8.1-mm3 Nick Piggin
2004-08-22  6:26       ` 2.6.8.1-mm3 Thomas Davis
2004-08-22  6:51     ` 2.6.8.1-mm3 Pete Zaitcev
2004-08-22 15:11   ` 2.6.8.1-mm3 Bartlomiej Zolnierkiewicz

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=1093405836.2206.447.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mikpe@csd.uu.se \
    --cc=patmans@us.ibm.com \
    --cc=willy@debian.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.