···58 * by @begin().59 * @prepare() is called right after devices have been suspended (ie. the60 * appropriate .suspend() method has been executed for each device) and61- * before the nonboot CPUs are disabled (it is executed with IRQs enabled).62- * This callback is optional. It returns 0 on success or a negative63- * error code otherwise, in which case the system cannot enter the desired64- * sleep state (@enter() and @finish() will not be called in that case).000000065 *66 * @enter: Enter the system sleep state indicated by @begin() or represented by67 * the argument if @begin() is not implemented.···76 * error code otherwise, in which case the system cannot enter the desired77 * sleep state.78 *79- * @finish: Called when the system has just left a sleep state, right after80- * the nonboot CPUs have been enabled and before devices are resumed (it is81- * executed with IRQs enabled).000000082 * This callback is optional, but should be implemented by the platforms83 * that implement @prepare(). If implemented, it is always called after84- * @enter() (even if @enter() fails).85 *86 * @end: Called by the PM core right after resuming devices, to indicate to87 * the platform that the system has returned to the working state or88 * the transition to the sleep state has been aborted.89 * This callback is optional, but should be implemented by the platforms90- * that implement @begin(), but platforms implementing @begin() should91- * also provide a @end() which cleans up transitions aborted before92 * @enter().93 *94 * @recover: Recover the platform from a suspend failure.···107 int (*valid)(suspend_state_t state);108 int (*begin)(suspend_state_t state);109 int (*prepare)(void);0110 int (*enter)(suspend_state_t state);0111 void (*finish)(void);112 void (*end)(void);113 void (*recover)(void);
···58 * by @begin().59 * @prepare() is called right after devices have been suspended (ie. the60 * appropriate .suspend() method has been executed for each device) and61+ * before device drivers' late suspend callbacks are executed. It returns62+ * 0 on success or a negative error code otherwise, in which case the63+ * system cannot enter the desired sleep state (@prepare_late(), @enter(),64+ * @wake(), and @finish() will not be called in that case).65+ *66+ * @prepare_late: Finish preparing the platform for entering the system sleep67+ * state indicated by @begin().68+ * @prepare_late is called before disabling nonboot CPUs and after69+ * device drivers' late suspend callbacks have been executed. It returns70+ * 0 on success or a negative error code otherwise, in which case the71+ * system cannot enter the desired sleep state (@enter() and @wake()).72 *73 * @enter: Enter the system sleep state indicated by @begin() or represented by74 * the argument if @begin() is not implemented.···69 * error code otherwise, in which case the system cannot enter the desired70 * sleep state.71 *72+ * @wake: Called when the system has just left a sleep state, right after73+ * the nonboot CPUs have been enabled and before device drivers' early74+ * resume callbacks are executed.75+ * This callback is optional, but should be implemented by the platforms76+ * that implement @prepare_late(). If implemented, it is always called77+ * after @enter(), even if @enter() fails.78+ *79+ * @finish: Finish wake-up of the platform.80+ * @finish is called right prior to calling device drivers' regular suspend81+ * callbacks.82 * This callback is optional, but should be implemented by the platforms83 * that implement @prepare(). If implemented, it is always called after84+ * @enter() and @wake(), if implemented, even if any of them fails.85 *86 * @end: Called by the PM core right after resuming devices, to indicate to87 * the platform that the system has returned to the working state or88 * the transition to the sleep state has been aborted.89 * This callback is optional, but should be implemented by the platforms90+ * that implement @begin(). Accordingly, platforms implementing @begin()91+ * should also provide a @end() which cleans up transitions aborted before92 * @enter().93 *94 * @recover: Recover the platform from a suspend failure.···93 int (*valid)(suspend_state_t state);94 int (*begin)(suspend_state_t state);95 int (*prepare)(void);96+ int (*prepare_late)(void);97 int (*enter)(suspend_state_t state);98+ void (*wake)(void);99 void (*finish)(void);100 void (*end)(void);101 void (*recover)(void);
+17-7
kernel/power/main.c
···291292 device_pm_lock();293000000294 error = device_power_down(PMSG_SUSPEND);295 if (error) {296 printk(KERN_ERR "PM: Some devices failed to power down\n");297- goto Done;298 }299300- if (suspend_ops->prepare) {301- error = suspend_ops->prepare();302 if (error)303 goto Power_up_devices;304 }305306 if (suspend_test(TEST_PLATFORM))307- goto Platfrom_finish;308309 error = disable_nonboot_cpus();310 if (error || suspend_test(TEST_CPUS))···332 Enable_cpus:333 enable_nonboot_cpus();334335- Platfrom_finish:336- if (suspend_ops->finish)337- suspend_ops->finish();338339 Power_up_devices:340 device_power_up(PMSG_RESUME);0000341342 Done:343 device_pm_unlock();
···291292 device_pm_lock();293294+ if (suspend_ops->prepare) {295+ error = suspend_ops->prepare();296+ if (error)297+ goto Done;298+ }299+300 error = device_power_down(PMSG_SUSPEND);301 if (error) {302 printk(KERN_ERR "PM: Some devices failed to power down\n");303+ goto Platfrom_finish;304 }305306+ if (suspend_ops->prepare_late) {307+ error = suspend_ops->prepare_late();308 if (error)309 goto Power_up_devices;310 }311312 if (suspend_test(TEST_PLATFORM))313+ goto Platform_wake;314315 error = disable_nonboot_cpus();316 if (error || suspend_test(TEST_CPUS))···326 Enable_cpus:327 enable_nonboot_cpus();328329+ Platform_wake:330+ if (suspend_ops->wake)331+ suspend_ops->wake();332333 Power_up_devices:334 device_power_up(PMSG_RESUME);335+336+ Platfrom_finish:337+ if (suspend_ops->finish)338+ suspend_ops->finish();339340 Done:341 device_pm_unlock();