patch-2.1.126 linux/drivers/block/ide-cd.c

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

diff -u --recursive --new-file v2.1.125/linux/drivers/block/ide-cd.c linux/drivers/block/ide-cd.c
@@ -2600,6 +2600,8 @@
 		return 0;
 	}
 	else {
+		int was_locked;
+
 		if (
 #if ! STANDARD_ATAPI
 		    CDROM_STATE_FLAGS (drive)->sanyo_slot == 0 &&
@@ -2608,6 +2610,10 @@
 			return -ENOMEDIUM;
 		}
 
+		was_locked = CDROM_STATE_FLAGS (drive)->door_locked;
+		if (was_locked)
+			(void) cdrom_lockdoor (drive, 0, NULL);
+
 		stat = cdrom_load_unload (drive, slot, NULL);
 		cdrom_saw_media_change (drive);
 		if (stat)
@@ -2621,10 +2627,12 @@
 			stat = cdrom_read_toc (drive, &my_reqbuf);
 			if (stat)
 				return stat;
-			return slot;
 		}
-		else
-			return stat;
+
+		if (was_locked)
+			(void) cdrom_lockdoor (drive, 1, NULL);
+
+		return stat;
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov