2.5.33: Modifiable timeout in sr_packet
PATCH 1/1 2.5.33: Modifiable timeout in sr_packet
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 the sr_do_ioctl() function to take a cdrom_generic_command pointer instead of a whole bunch of parameters.
Please apply.
drivers/scsi/sr.c renamed from linux-2.5.33/drivers/scsi/sr.c +17 -9
@@ -581,7 +581,7 @@void get_capabilities (int i) {Scsi_CD *SCp; -unsigned char cmd[6 ]; +struct cdrom_generic_command cgc;unsigned char *buffer;int rc, n;
@@ -604,13 +604,18 @@printk (KERN_ERR "sr: out of memory.\n" );return ; } - cmd[0 ] =MODE_SENSE ; - cmd[1 ] = (SCp->device->scsi_level <=SCSI_2 ) ? - ((SCp->device->lun <<5 ) &0xe0 ) :0 ; - cmd[2 ] =0x2a ; - cmd[4 ] =128 ; - cmd[3 ] = cmd[5 ] =0 ; - rc =sr_do_ioctl (i, cmd, buffer,128 ,1 ,SCSI_DATA_READ ,NULL ); +memset (&cgc,0 ,sizeof (struct cdrom_generic_command )); + cgc.cmd[0 ] =MODE_SENSE ; + cgc.cmd[1 ] = (SCp->device->scsi_level <=SCSI_2 ) ? + ((SCp->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 (i, &cgc);if (rc) {/* failed, drive doesn't have capabilities mode page */
@@ -687,7 +692,10 @@if (device->scsi_level <=SCSI_2 ) cgc->cmd[1 ] |= device->lun <<5 ; - cgc->stat =sr_do_ioctl (minor (cdi->dev), cgc->cmd, cgc->buffer, cgc->buflen, cgc->quiet, cgc->data_direction, cgc->sense); +if (cgc->timeout <=0 ) + cgc->timeout =IOCTL_TIMEOUT ; + +sr_do_ioctl (minor (cdi->dev), cgc);return cgc->stat; }
drivers/scsi/sr.h renamed from linux-2.5.33/drivers/scsi/sr.h +5 -1
@@ -19,6 +19,10 @@#include "scsi.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 @@extern Scsi_CD *scsi_CDs; -int sr_do_ioctl (int ,unsigned char *,void *,unsigned ,int ,int ,struct request_sense *); +int sr_do_ioctl (int ,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 renamed from linux-2.5.33/drivers/scsi/sr_ioctl.c +148 -122
453 lines not on this page · raw message
drivers/scsi/sr_vendor.c renamed from linux-2.5.33/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