]> git.neil.brown.name Git - history.git/commitdiff
Add a "cmd_len" parameter to the request, so that device drivers
authorLinus Torvalds <torvalds@home.transmeta.com>
Sat, 2 Nov 2002 03:55:44 +0000 (19:55 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sat, 2 Nov 2002 03:55:44 +0000 (19:55 -0800)
don't have to try to figure it out for themselves.

Make ide-cd.c use it.

drivers/block/scsi_ioctl.c
drivers/ide/ide-cd.c
include/linux/blkdev.h

index 5460d6cb6269005c626f9800e74f1ea16a6a5dd8..081682e37f05f75a4f682ab4be5b7697af8a1895 100644 (file)
@@ -226,6 +226,7 @@ static int sg_io(request_queue_t *q, struct block_device *bdev,
        /*
         * fill in request structure
         */
+       rq->cmd_len = hdr.cmd_len;
        copy_from_user(rq->cmd, hdr.cmdp, hdr.cmd_len);
        if (sizeof(rq->cmd) != hdr.cmd_len)
                memset(rq->cmd + hdr.cmd_len, 0, sizeof(rq->cmd) - hdr.cmd_len);
@@ -348,6 +349,7 @@ static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
         * get command and data to send to device, if any
         */
        err = -EFAULT;
+       rq->cmd_len = cmdlen;
        if (copy_from_user(rq->cmd, sic->data, cmdlen))
                goto error;
 
index dcc1cc66f51584f3bc3158e51264e7fcbee491a4..41417bf58d59c0b3ce6adf4e51acdcc6918c814f 100644 (file)
@@ -882,6 +882,15 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
                                          struct request *rq,
                                          ide_handler_t *handler)
 {
+       /*
+        * FIXME! This should be 'rq->cmd_len' when that is reliable.
+        *
+        * This breaks for real 16-byte commands. however, lots of drives
+        * currently break if we just send 16-bytes for 10/12 byte commands.
+        */
+#define MAX_CDB_BYTES  12
+       int cmd_len = MAX_CDB_BYTES;
+
        struct cdrom_info *info = drive->driver_data;
        ide_startstop_t startstop;
 
@@ -906,7 +915,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
        ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry);
 
        /* Send the command to the device. */
-       HWIF(drive)->atapi_output_bytes(drive, rq->cmd, sizeof(rq->cmd));
+       HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len);
 
        /* Start the DMA if need be */
        if (info->dma)
@@ -3004,6 +3013,7 @@ static int ide_cdrom_prep_fs(request_queue_t *q, struct request *rq)
         */
        rq->cmd[7] = (blocks >> 8) & 0xff;
        rq->cmd[8] = blocks & 0xff;
+       rq->cmd_len = 10;
        return BLKPREP_OK;
 }
 
@@ -3026,6 +3036,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
                c[2] = 0;
                c[1] &= 0xe0;
                c[0] += (READ_10 - READ_6);
+               rq->cmd_len = 10;
                return BLKPREP_OK;
        }
 
index 9f84bcbf0c59965cbf751e3d579aa06096a7c4d2..5fe4ade9e2bd85dd16487dc7f507e0ea6e7bcdc5 100644 (file)
@@ -92,6 +92,7 @@ struct request {
        /*
         * when request is used as a packet command carrier
         */
+       unsigned int cmd_len;
        unsigned char cmd[16];
 
        unsigned int data_len;