2.5.40: Make sr_packet honor provided timeout value
PATCH 1/1 2.5.40: Make sr_packet honor provided timeout value
Here is a patch that makes the sr_packet function in sr.c use the timeout value provided by the cdrom_generic_command argument, instead of using the previously hardcoded value in sr_do_ioctl.
The patch is needed by some user space tools related to CDRW packet writing and DVD writing. The IDE equivalent (ide_cdrom_packet) has been honoring the provided timeout value for a long time.
This is implemented by changing sr_do_ioctl() to take a cdrom_generic_command pointer instead of adding yet another parameter to the already too long parameter list. It now takes two parameters instead of seven.
Please apply.
drivers/scsi/sr.c | 26 ++-- drivers/scsi/sr.h | 6 - drivers/scsi/sr_ioctl.c | 271 +++++++++++++++++++++++++---------------------- drivers/scsi/sr_vendor.c | 115 ++++++++++++------- 4 files changed, 242 insertions(+), 176 deletions(-)
drivers/scsi/sr.c +17 -9
@@ -575,7 +575,7 @@void get_capabilities (Scsi_CD *cd) { -unsigned char cmd[6 ]; +struct cdrom_generic_command cgc;unsigned char *buffer;int rc, n;
@@ -597,13 +597,18 @@printk (KERN_ERR "sr: out of memory.\n" );return ; } - cmd[0 ] =MODE_SENSE ; - cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? - ((cd->device->lun <<5 ) &0xe0 ) :0 ; - cmd[2 ] =0x2a ; - cmd[4 ] =128 ; - cmd[3 ] = cmd[5 ] =0 ; - rc =sr_do_ioctl (cd, cmd, buffer,128 ,1 ,SCSI_DATA_READ ,NULL ); +memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); + cgc.cmd[0 ] =MODE_SENSE ; + cgc.cmd[1 ] = (cd->device->scsi_level <=SCSI_2 ) ? + ((cd->device->lun <<5 ) &0xe0 ) :0 ; + cgc.cmd[2 ] =0x2a ; + cgc.cmd[4 ] =128 ; + cgc.buffer = buffer; + cgc.buflen =128 ; + cgc.quiet =1 ; + cgc.data_direction =SCSI_DATA_READ ; + cgc.timeout =SR_TIMEOUT ; + rc =sr_do_ioctl (cd, &cgc);if (rc) {/* failed, drive doesn't have capabilities mode page */
@@ -680,7 +685,10 @@if (device->scsi_level <=SCSI_2 ) cgc->cmd[1 ] |= device->lun <<5 ; - cgc->stat =sr_do_ioctl (cdi->handle, cgc->cmd, cgc->buffer, cgc->buflen, cgc->quiet, cgc->data_direction, cgc->sense); +if (cgc->timeout <=0 ) + cgc->timeout =IOCTL_TIMEOUT ; + +sr_do_ioctl (cdi->handle, cgc);return cgc->stat; }
drivers/scsi/sr.h +5 -1
@@ -20,6 +20,10 @@#include "scsi.h" #include <linux/genhd.h> +/* The CDROM is fairly slow, so we need a little extra time */ +/* In fact, it is very slow if it has to spin up first */ +#define IOCTL_TIMEOUT 30*HZ + typedef struct { unsigned capacity; /* size in blocks */ Scsi_Device *device;
@@ -34,7 +38,7 @@struct gendisk *disk; } Scsi_CD; -int sr_do_ioctl (Scsi_CD *,unsigned char *,void *,unsigned ,int ,int ,struct request_sense *); +int sr_do_ioctl (Scsi_CD *,struct cdrom_generic_command *);int sr_lock_door (struct cdrom_device_info *,int );int sr_tray_move (struct cdrom_device_info *,int );
drivers/scsi/sr_ioctl.c +148 -123
459 lines not on this page · raw message
drivers/scsi/sr_vendor.c +72 -43
178 lines not on this page · raw message
Signature · 2 lines
Peter Osterlund - [email protected] http://w1.894.telia.com/~u89404340