]> err.no Git - linux-2.6/blobdiff - drivers/scsi/sr.c
[PATCH] gianfar mii needs to zero out the mii_bus structure
[linux-2.6] / drivers / scsi / sr.c
index f63d8c6c2a3314303a95544b14cc1d2c109a903a..d68cea753bb2222629db977d5ebf37614dc9c093 100644 (file)
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_driver.h>
+#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_ioctl.h>   /* For the door lock/unlock commands */
-#include <scsi/scsi_request.h>
 
 #include "scsi_logging.h"
 #include "sr.h"
@@ -326,6 +326,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
                        return 0;
 
                memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
+               SCpnt->cmd_len = rq->cmd_len;
                if (!rq->data_len)
                        SCpnt->sc_data_direction = DMA_NONE;
                else if (rq_data_dir(rq) == WRITE)
@@ -359,7 +360,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
        }
 
        if (s_size != 512 && s_size != 1024 && s_size != 2048) {
-               printk("sr: bad sector size %d\n", s_size);
+               scmd_printk(KERN_ERR, SCpnt, "bad sector size %d\n", s_size);
                return 0;
        }
 
@@ -384,8 +385,9 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
                        size += sg[i].length;
 
                if (size != SCpnt->request_bufflen && SCpnt->use_sg) {
-                       printk(KERN_ERR "sr: mismatch count %d, bytes %d\n",
-                                       size, SCpnt->request_bufflen);
+                       scmd_printk(KERN_ERR, SCpnt,
+                               "mismatch count %d, bytes %d\n",
+                               size, SCpnt->request_bufflen);
                        if (SCpnt->request_bufflen > size)
                                SCpnt->request_bufflen = SCpnt->bufflen = size;
                }
@@ -396,7 +398,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
         */
        if (((unsigned int)SCpnt->request->sector % (s_size >> 9)) ||
            (SCpnt->request_bufflen % s_size)) {
-               printk("sr: unaligned transfer\n");
+               scmd_printk(KERN_NOTICE, SCpnt, "unaligned transfer\n");
                return 0;
        }
 
@@ -454,7 +456,7 @@ queue:
 static int sr_block_open(struct inode *inode, struct file *file)
 {
        struct gendisk *disk = inode->i_bdev->bd_disk;
-       struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
+       struct scsi_cd *cd;
        int ret = 0;
 
        if(!(cd = scsi_cd_get(disk)))
@@ -621,10 +623,8 @@ static int sr_probe(struct device *dev)
        disk->flags |= GENHD_FL_REMOVABLE;
        add_disk(disk);
 
-       printk(KERN_DEBUG
-           "Attached scsi CD-ROM %s at scsi%d, channel %d, id %d, lun %d\n",
-           cd->cdi.name, sdev->host->host_no, sdev->channel,
-           sdev->id, sdev->lun);
+       sdev_printk(KERN_DEBUG, sdev,
+                   "Attached scsi CD-ROM %s\n", cd->cdi.name);
        return 0;
 
 fail_put:
@@ -642,39 +642,27 @@ static void get_sectorsize(struct scsi_cd *cd)
        unsigned char *buffer;
        int the_result, retries = 3;
        int sector_size;
-       struct scsi_request *SRpnt = NULL;
        request_queue_t *queue;
 
        buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
        if (!buffer)
                goto Enomem;
-       SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
-       if (!SRpnt)
-               goto Enomem;
 
        do {
                cmd[0] = READ_CAPACITY;
                memset((void *) &cmd[1], 0, 9);
-               /* Mark as really busy */
-               SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
-               SRpnt->sr_cmd_len = 0;
-
                memset(buffer, 0, 8);
 
                /* Do the command and wait.. */
-               SRpnt->sr_data_direction = DMA_FROM_DEVICE;
-               scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
-                             8, SR_TIMEOUT, MAX_RETRIES);
+               the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
+                                             buffer, 8, NULL, SR_TIMEOUT,
+                                             MAX_RETRIES);
 
-               the_result = SRpnt->sr_result;
                retries--;
 
        } while (the_result && retries);
 
 
-       scsi_release_request(SRpnt);
-       SRpnt = NULL;
-
        if (the_result) {
                cd->capacity = 0x1fffff;
                sector_size = 2048;     /* A guess, just in case */
@@ -730,8 +718,6 @@ out:
 Enomem:
        cd->capacity = 0x1fffff;
        cd->device->sector_size = 2048; /* A guess, just in case */
-       if (SRpnt)
-               scsi_release_request(SRpnt);
        goto out;
 }
 
@@ -739,8 +725,8 @@ static void get_capabilities(struct scsi_cd *cd)
 {
        unsigned char *buffer;
        struct scsi_mode_data data;
-       struct scsi_request *SRpnt;
        unsigned char cmd[MAX_COMMAND_SIZE];
+       struct scsi_sense_hdr sshdr;
        unsigned int the_result;
        int retries, rc, n;
 
@@ -756,19 +742,11 @@ static void get_capabilities(struct scsi_cd *cd)
                ""
        };
 
-       /* allocate a request for the TEST_UNIT_READY */
-       SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
-       if (!SRpnt) {
-               printk(KERN_WARNING "(get_capabilities:) Request allocation "
-                      "failure.\n");
-               return;
-       }
 
        /* allocate transfer buffer */
        buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
        if (!buffer) {
                printk(KERN_ERR "sr: out of memory.\n");
-               scsi_release_request(SRpnt);
                return;
        }
 
@@ -780,24 +758,19 @@ static void get_capabilities(struct scsi_cd *cd)
                memset((void *)cmd, 0, MAX_COMMAND_SIZE);
                cmd[0] = TEST_UNIT_READY;
 
-               SRpnt->sr_cmd_len = 0;
-               SRpnt->sr_sense_buffer[0] = 0;
-               SRpnt->sr_sense_buffer[2] = 0;
-               SRpnt->sr_data_direction = DMA_NONE;
-
-               scsi_wait_req (SRpnt, (void *) cmd, buffer,
-                              0, SR_TIMEOUT, MAX_RETRIES);
+               the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
+                                              0, &sshdr, SR_TIMEOUT,
+                                              MAX_RETRIES);
 
-               the_result = SRpnt->sr_result;
                retries++;
        } while (retries < 5 && 
                 (!scsi_status_is_good(the_result) ||
-                 ((driver_byte(the_result) & DRIVER_SENSE) &&
-                  SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION)));
+                 (scsi_sense_valid(&sshdr) &&
+                  sshdr.sense_key == UNIT_ATTENTION)));
 
        /* ask for mode page 0x2a */
        rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
-                            SR_TIMEOUT, 3, &data);
+                            SR_TIMEOUT, 3, &data, NULL);
 
        if (!scsi_status_is_good(rc)) {
                /* failed, drive doesn't have capabilities mode page */
@@ -805,7 +778,6 @@ static void get_capabilities(struct scsi_cd *cd)
                cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
                                         CDC_DVD | CDC_DVD_RAM |
                                         CDC_SELECT_DISC | CDC_SELECT_SPEED);
-               scsi_release_request(SRpnt);
                kfree(buffer);
                printk("%s: scsi-1 drive\n", cd->cdi.name);
                return;
@@ -865,7 +837,6 @@ static void get_capabilities(struct scsi_cd *cd)
                cd->device->writeable = 1;
        }
 
-       scsi_release_request(SRpnt);
        kfree(buffer);
 }