Commit 6892c800 authored by Linus Torvalds's avatar Linus Torvalds

Add a "cmd_len" parameter to the request, so that device drivers

don't have to try to figure it out for themselves.

Make ide-cd.c use it. 
parent 1c58248d
...@@ -226,6 +226,7 @@ static int sg_io(request_queue_t *q, struct block_device *bdev, ...@@ -226,6 +226,7 @@ static int sg_io(request_queue_t *q, struct block_device *bdev,
/* /*
* fill in request structure * fill in request structure
*/ */
rq->cmd_len = hdr.cmd_len;
copy_from_user(rq->cmd, hdr.cmdp, hdr.cmd_len); copy_from_user(rq->cmd, hdr.cmdp, hdr.cmd_len);
if (sizeof(rq->cmd) != hdr.cmd_len) if (sizeof(rq->cmd) != hdr.cmd_len)
memset(rq->cmd + hdr.cmd_len, 0, 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, ...@@ -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 * get command and data to send to device, if any
*/ */
err = -EFAULT; err = -EFAULT;
rq->cmd_len = cmdlen;
if (copy_from_user(rq->cmd, sic->data, cmdlen)) if (copy_from_user(rq->cmd, sic->data, cmdlen))
goto error; goto error;
......
...@@ -882,6 +882,15 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, ...@@ -882,6 +882,15 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
struct request *rq, struct request *rq,
ide_handler_t *handler) 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; struct cdrom_info *info = drive->driver_data;
ide_startstop_t startstop; ide_startstop_t startstop;
...@@ -906,7 +915,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, ...@@ -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); ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry);
/* Send the command to the device. */ /* 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 */ /* Start the DMA if need be */
if (info->dma) if (info->dma)
...@@ -3004,6 +3013,7 @@ static int ide_cdrom_prep_fs(request_queue_t *q, struct request *rq) ...@@ -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[7] = (blocks >> 8) & 0xff;
rq->cmd[8] = blocks & 0xff; rq->cmd[8] = blocks & 0xff;
rq->cmd_len = 10;
return BLKPREP_OK; return BLKPREP_OK;
} }
...@@ -3026,6 +3036,7 @@ static int ide_cdrom_prep_pc(struct request *rq) ...@@ -3026,6 +3036,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
c[2] = 0; c[2] = 0;
c[1] &= 0xe0; c[1] &= 0xe0;
c[0] += (READ_10 - READ_6); c[0] += (READ_10 - READ_6);
rq->cmd_len = 10;
return BLKPREP_OK; return BLKPREP_OK;
} }
......
...@@ -92,6 +92,7 @@ struct request { ...@@ -92,6 +92,7 @@ struct request {
/* /*
* when request is used as a packet command carrier * when request is used as a packet command carrier
*/ */
unsigned int cmd_len;
unsigned char cmd[16]; unsigned char cmd[16];
unsigned int data_len; unsigned int data_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment