if (ehc->i.flags & ATA_EHI_DID_RESET)
                        readid_flags |= ATA_READID_POSTRESET;
 
-               /*
-                * When resuming, before executing any command, make sure to
-                * transition the device to the active power mode.
-                */
-               if ((action & ATA_EH_SET_ACTIVE) && ata_dev_enabled(dev)) {
-                       ata_dev_power_set_active(dev);
-                       ata_eh_done(link, dev, ATA_EH_SET_ACTIVE);
-               }
-
                if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
                        WARN_ON(dev->class == ATA_DEV_PMP);
 
                        }
                }
 
+               /*
+                * Make sure to transition devices to the active power mode
+                * if needed (e.g. if we were scheduled on system resume).
+                */
+               ata_for_each_dev(dev, link, ENABLED) {
+                       if (ehc->i.dev_action[dev->devno] & ATA_EH_SET_ACTIVE) {
+                               ata_dev_power_set_active(dev);
+                               ata_eh_done(link, dev, ATA_EH_SET_ACTIVE);
+                       }
+               }
+
                /* retry flush if necessary */
                ata_for_each_dev(dev, link, ALL) {
                        if (dev->class != ATA_DEV_ATA &&