From: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>

Fixes possible drive->wcache race and sending of unknown commands on
->suspend() and ->shutdown().  Cache handling needs rewrite (later).


---

 25-akpm/drivers/ide/ide-disk.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff -puN drivers/ide/ide-disk.c~ide-diskc-revert-to-previous-24-way-of-handling-flush-cache-commands drivers/ide/ide-disk.c
--- 25/drivers/ide/ide-disk.c~ide-diskc-revert-to-previous-24-way-of-handling-flush-cache-commands	Tue May 11 18:07:04 2004
+++ 25-akpm/drivers/ide/ide-disk.c	Tue May 11 18:07:04 2004
@@ -1740,11 +1740,12 @@ static ide_driver_t idedisk_driver = {
 
 static int idedisk_open(struct inode *inode, struct file *filp)
 {
-	u8 cf;
 	ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
 	drive->usage++;
 	if (drive->removable && drive->usage == 1) {
 		ide_task_t args;
+		u8 cf;
+
 		memset(&args, 0, sizeof(ide_task_t));
 		args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK;
 		args.command_type = IDE_DRIVE_TASK_NO_DATA;
@@ -1757,26 +1758,25 @@ static int idedisk_open(struct inode *in
 		 */
 		if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
 			drive->doorlocking = 0;
+
+		/* FIXME: 2.4 behavior for now */
+		drive->wcache = 0;
+		/* Cache enabled? */
+		if (drive->id->csfo & 1)
+			drive->wcache = 1;
+		/* Cache command set available? */
+		if (drive->id->cfs_enable_1 & (1 << 5))
+			drive->wcache = 1;
+		/* ATA6 cache extended commands */
+		cf = drive->id->command_set_2 >> 24;
+		if ((cf & 0xC0) == 0x40 && (cf & 0x30) != 0)
+			drive->wcache = 1;
 	}
-	drive->wcache = 0;
-	/* Cache enabled? */
-	if (drive->id->csfo & 1)
-		drive->wcache = 1;
-	/* Cache command set available? */
-	if (drive->id->cfs_enable_1 & (1 << 5))
-		drive->wcache = 1;
-	/* ATA6 cache extended commands */
-	cf = drive->id->command_set_2 >> 24;
-	if ((cf & 0xC0) == 0x40 && (cf & 0x30) != 0)
-		drive->wcache = 1;
 	return 0;
 }
 
 static int ide_cacheflush_p(ide_drive_t *drive)
 {
-	if (!(drive->id->cfs_enable_2 & 0x3000))
-		return 0;
-
 	if(drive->wcache)
 	{
 		if (do_idedisk_flushcache(drive))

_