]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Suspend IDE disks on shutdown
authorBartlomiej Zolnierkiewicz <b.zolnierkiewicz@elka.pw.edu.pl>
Fri, 7 May 2004 00:27:25 +0000 (17:27 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 7 May 2004 00:27:25 +0000 (17:27 -0700)
When Patrick removed ide_notify_reboot() in 2.5.42, he didn't notice
that it meant that IDE no longer had any shutdown() functionality.

So we did the right thing on suspend, but not on shutdown.

ide_notify_reboot() was only doing STANDBY on shutdown (because FLUSH
'doesn't work' in 2.4 too) but it worked okay and we still should do STANDBY
on shutdown because some broken disks flush their caches.

Thus just calls bus->suspend() (FLUSH+STANDBY) at shutdown time.  We can
add some safety delay later - 2.4 doesn't have any.

drivers/ide/ide-disk.c

index 64f42ad0fb0c0f54b2d90f8a04d0a913657dea87..e8cfd222669cc302046ae1c8dd5c2a3c605395e3 100644 (file)
@@ -1702,11 +1702,22 @@ static int idedisk_cleanup (ide_drive_t *drive)
 
 static int idedisk_attach(ide_drive_t *drive);
 
+static void ide_device_shutdown(struct device *dev)
+{
+       ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
+
+       printk("Shutdown: %s\n", drive->name);
+       dev->bus->suspend(dev, PM_SUSPEND_STANDBY);
+}
+
 /*
  *      IDE subdriver functions, registered with ide.c
  */
 static ide_driver_t idedisk_driver = {
        .owner                  = THIS_MODULE,
+       .gen_driver = {
+               .shutdown       = ide_device_shutdown,
+       },
        .name                   = "ide-disk",
        .version                = IDEDISK_VERSION,
        .media                  = ide_disk,