patch-2.3.47 linux/drivers/scsi/sd.c

Next file: linux/drivers/scsi/sr.c
Previous file: linux/drivers/scsi/scsi_syms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.46/linux/drivers/scsi/sd.c linux/drivers/scsi/sd.c
@@ -309,9 +309,11 @@
 			return 0;
 		}
 		SCpnt->cmnd[0] = WRITE_6;
+		SCpnt->sc_data_direction = SCSI_DATA_WRITE;
 		break;
 	case READ:
 		SCpnt->cmnd[0] = READ_6;
+		SCpnt->sc_data_direction = SCSI_DATA_READ;
 		break;
 	default:
 		panic("Unknown sd command %d\n", SCpnt->request.cmd);
@@ -695,6 +697,7 @@
 			SCpnt->cmd_len = 0;
 			SCpnt->sense_buffer[0] = 0;
 			SCpnt->sense_buffer[2] = 0;
+			SCpnt->sc_data_direction = SCSI_DATA_READ;
 
 			scsi_wait_cmd (SCpnt, (void *) cmd, (void *) buffer,
 				0/*512*/, SD_TIMEOUT, MAX_RETRIES);
@@ -706,6 +709,22 @@
 				break;
 		}
 
+		/*
+		 * If the drive has indicated to us that it doesn't have
+		 * any media in it, don't bother with any of the rest of
+		 * this crap.
+		 */
+		if( the_result != 0
+		    && ((driver_byte(the_result) & DRIVER_SENSE) != 0)
+		    && SCpnt->sense_buffer[2] == UNIT_ATTENTION
+		    && SCpnt->sense_buffer[12] == 0x3A ) {
+			rscsi_disks[i].capacity = 0x1fffff;
+			sector_size = 512;
+			rscsi_disks[i].device->changed = 1;
+			rscsi_disks[i].ready = 0;
+			break;
+		}
+
 		/* Look for non-removable devices that return NOT_READY.
 		 * Issue command to spin up drive for these cases. */
 		if (the_result && !rscsi_disks[i].device->removable &&
@@ -722,6 +741,7 @@
 				SCpnt->sense_buffer[0] = 0;
 				SCpnt->sense_buffer[2] = 0;
 
+				SCpnt->sc_data_direction = SCSI_DATA_READ;
 				scsi_wait_cmd(SCpnt, (void *) cmd, (void *) buffer,
 					    0/*512*/, SD_TIMEOUT, MAX_RETRIES);
 			}
@@ -752,6 +772,7 @@
 		SCpnt->sense_buffer[0] = 0;
 		SCpnt->sense_buffer[2] = 0;
 
+		SCpnt->sc_data_direction = SCSI_DATA_READ;
 		scsi_wait_cmd(SCpnt, (void *) cmd, (void *) buffer,
 			    8, SD_TIMEOUT, MAX_RETRIES);
 
@@ -903,6 +924,7 @@
 		SCpnt->sense_buffer[2] = 0;
 
 		/* same code as READCAPA !! */
+		SCpnt->sc_data_direction = SCSI_DATA_READ;
 		scsi_wait_cmd(SCpnt, (void *) cmd, (void *) buffer,
 			    512, SD_TIMEOUT, MAX_RETRIES);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)