patch-2.4.0-test10 linux/drivers/ide/ide-tape.c

Next file: linux/drivers/ide/ide.c
Previous file: linux/drivers/ide/ide-proc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test9/linux/drivers/ide/ide-tape.c linux/drivers/ide/ide-tape.c
@@ -3126,8 +3126,11 @@
 	idetape_init_pc (pc);
 	pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD;
 	pc->c[4] = cmd;
-	if (tape->onstream)
+	if (tape->onstream) {
 		pc->c[1] = 1;
+		if (cmd == !IDETAPE_LU_LOAD_MASK)
+			pc->c[4] = 4;
+	}
 	set_bit (PC_WAIT_FOR_DSC, &pc->flags);
 	pc->callback = &idetape_pc_callback;
 }
@@ -3239,12 +3242,18 @@
 	pc->callback = &idetape_pc_callback;
 }
 
-static void idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent)
+static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent)
 {
+	idetape_tape_t *tape = drive->driver_data;
+
+	if (!tape->capabilities.lock)
+		return 0;
+
 	idetape_init_pc(pc);
 	pc->c[0] = IDETAPE_PREVENT_CMD;
 	pc->c[4] = prevent;
 	pc->callback = &idetape_pc_callback;
+	return 1;
 }
 
 static int __idetape_discard_read_pipeline (ide_drive_t *drive)
@@ -5017,13 +5026,15 @@
 				}
 			}
 		case MTLOCK:
-			idetape_create_prevent_cmd(drive, &pc, 1);
+			if (!idetape_create_prevent_cmd(drive, &pc, 1))
+				return 0;
 			retval = idetape_queue_pc_tail (drive,&pc);
 			if (retval) return retval;
 			tape->door_locked = DOOR_EXPLICITLY_LOCKED;
 			return 0;
 		case MTUNLOCK:
-			idetape_create_prevent_cmd(drive, &pc, 0);
+			if (!idetape_create_prevent_cmd(drive, &pc, 0))
+				return 0;
 			retval = idetape_queue_pc_tail (drive,&pc);
 			if (retval) return retval;
 			tape->door_locked = DOOR_UNLOCKED;
@@ -5262,10 +5273,11 @@
 	clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
 
 	if (tape->chrdev_direction == idetape_direction_none) {
-		idetape_create_prevent_cmd(drive, &pc, 1);
-		if (!idetape_queue_pc_tail (drive,&pc)) {
-			if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
-				tape->door_locked = DOOR_LOCKED;
+		if (idetape_create_prevent_cmd(drive, &pc, 1)) {
+			if (!idetape_queue_pc_tail (drive,&pc)) {
+				if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
+					tape->door_locked = DOOR_LOCKED;
+			}
 		}
 		idetape_analyze_headers(drive);
 	}
@@ -5320,9 +5332,9 @@
 		(void) idetape_rewind_tape (drive);
 	if (tape->chrdev_direction == idetape_direction_none) {
 		if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) {
-			idetape_create_prevent_cmd(drive, &pc, 0);
-			if (!idetape_queue_pc_tail (drive,&pc))
-				tape->door_locked = DOOR_UNLOCKED;
+			if (idetape_create_prevent_cmd(drive, &pc, 0))
+				if (!idetape_queue_pc_tail (drive,&pc))
+					tape->door_locked = DOOR_UNLOCKED;
 		}
 	}
 	clear_bit (IDETAPE_BUSY, &tape->flags);

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