Skip to contentSkip to conversation

Patch: Fix BUGging in ide-disk.c

DISCUSSION Nigel Cunningham 2 participants 2 messages Mar 17, 2003 – Mar 18, 2003

lore
Share & tools
lore
#0 lore raw

Hi.

This patch fixes a problem with the suspend/resume code in ide-disk.c which is triggered when the code is called multiple times for a drive. When the second resume call was made, the BUG was activated.

Please apply if something hasn't already been done about this.

Regards,

Nigel

Signature · 37 lines
Nigel Cunningham
495 St Georges Road South, Hastings 4201, New Zealand

Be diligent to present yourself approved to God as a workman who does
not need to be ashamed, handling accurately the word of truth.
	-- 2 Timothy 2:14, NASB.

diff -ruN linux-2.5.64-original/drivers/ide/ide-disk.c
linux-2.5.64-clean/drivers/ide/ide-disk.c
--- linux-2.5.64-original/drivers/ide/ide-disk.c	2002-12-11 11:45:51.000000000 +1300
+++ linux-2.5.64-clean/drivers/ide/ide-disk.c	2003-03-18 08:59:29.000000000 +1200
@@ -1552,7 +1552,8 @@
 	/* set the drive to standby */
 	printk(KERN_INFO "suspending: %s ", drive->name);
 	do_idedisk_standby(drive);
-	drive->blocked = 1;
+	/* Handle multiple calls for the same drive without bugging */
+	drive->blocked++;
 
 	BUG_ON (HWGROUP(drive)->handler);
 	return 0;
@@ -1562,10 +1563,14 @@
 {
 	ide_drive_t *drive = dev->driver_data;
 
+	printk("Resuming device %p\n", dev->driver_data);
+
 	if (level != RESUME_RESTORE_STATE)
 		return 0;
-	BUG_ON(!drive->blocked);
-	drive->blocked = 0;
+	if (drive->blocked)
+		drive->blocked--;
+	else
+		printk("Warning: More calls to resume device %p than calls to suspend it.\n", dev->driver_data);
 	return 0;
 }
#1 lore raw

Hi!

Quoted 5 lines

This patch fixes a problem with the suspend/resume code in ide-disk.c which is triggered when the code is called multiple times for a drive. When the second resume call was made, the BUG was activated.

Please apply if something hasn't already been done about this.

Yes, this looks good.
Pavel

Signature · 2 lines
Horseback riding is like software...
...vgf orggre jura vgf serr.