]> git.hungrycats.org Git - linux/commitdiff
Add internal API to remove reliance on deprecated SCSI_IOCTL_TEST_UNIT_READY
authorJames Bottomley <jejb@mulgrave.(none)>
Wed, 25 Aug 2004 08:22:18 +0000 (04:22 -0400)
committerJames Bottomley <jejb@mulgrave.(none)>
Wed, 25 Aug 2004 08:22:18 +0000 (04:22 -0400)
This was used by sd and sr

Instead make them use

scsi_test_unit_ready() which is exported now
from scsi_lib.c

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_ioctl.c
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/scsi/sr.c
include/scsi/scsi_device.h

index ce3d9632a594e22b64706a0e131a37dec8e15559..e26addada4f7cfec5ec66bc28816b4775d91ce28 100644 (file)
@@ -432,12 +432,8 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
        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;
index d6a2ef0b95f5a29c2b58abc0b89bbfa8542b6287..ac16f21dc3a12d405dc4a1c9369f66f7c177b6bd 100644 (file)
@@ -1572,6 +1572,34 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
        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.
index 72f0446623e4bff642ae72f0715c4e87c8f6a1be..e614aa640d56b9122d4367986490fb440bc7509a 100644 (file)
@@ -648,7 +648,7 @@ static int sd_media_changed(struct gendisk *disk)
         */
        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
index b80aa283c9212955bae627e19e71969683233490..3fabc11003556415283ed53446865c1d879afe07 100644 (file)
@@ -183,7 +183,7 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
                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,
index 36c3a23ab4ab0630a4da8511a021285ef8c6eaba..e76510c345c4112038283ae914d6713a40c2392a 100644 (file)
@@ -185,6 +185,8 @@ extern int scsi_set_medium_removal(struct scsi_device *, char);
 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);