···5858 * by @begin().5959 * @prepare() is called right after devices have been suspended (ie. the6060 * appropriate .suspend() method has been executed for each device) and6161- * before the nonboot CPUs are disabled (it is executed with IRQs enabled).6262- * This callback is optional. It returns 0 on success or a negative6363- * error code otherwise, in which case the system cannot enter the desired6464- * sleep state (@enter() and @finish() will not be called in that case).6161+ * before device drivers' late suspend callbacks are executed. It returns6262+ * 0 on success or a negative error code otherwise, in which case the6363+ * system cannot enter the desired sleep state (@prepare_late(), @enter(),6464+ * @wake(), and @finish() will not be called in that case).6565+ *6666+ * @prepare_late: Finish preparing the platform for entering the system sleep6767+ * state indicated by @begin().6868+ * @prepare_late is called before disabling nonboot CPUs and after6969+ * device drivers' late suspend callbacks have been executed. It returns7070+ * 0 on success or a negative error code otherwise, in which case the7171+ * system cannot enter the desired sleep state (@enter() and @wake()).6572 *6673 * @enter: Enter the system sleep state indicated by @begin() or represented by6774 * the argument if @begin() is not implemented.···7669 * error code otherwise, in which case the system cannot enter the desired7770 * sleep state.7871 *7979- * @finish: Called when the system has just left a sleep state, right after8080- * the nonboot CPUs have been enabled and before devices are resumed (it is8181- * executed with IRQs enabled).7272+ * @wake: Called when the system has just left a sleep state, right after7373+ * the nonboot CPUs have been enabled and before device drivers' early7474+ * resume callbacks are executed.7575+ * This callback is optional, but should be implemented by the platforms7676+ * that implement @prepare_late(). If implemented, it is always called7777+ * after @enter(), even if @enter() fails.7878+ *7979+ * @finish: Finish wake-up of the platform.8080+ * @finish is called right prior to calling device drivers' regular suspend8181+ * callbacks.8282 * This callback is optional, but should be implemented by the platforms8383 * that implement @prepare(). If implemented, it is always called after8484- * @enter() (even if @enter() fails).8484+ * @enter() and @wake(), if implemented, even if any of them fails.8585 *8686 * @end: Called by the PM core right after resuming devices, to indicate to8787 * the platform that the system has returned to the working state or8888 * the transition to the sleep state has been aborted.8989 * This callback is optional, but should be implemented by the platforms9090- * that implement @begin(), but platforms implementing @begin() should9191- * also provide a @end() which cleans up transitions aborted before9090+ * that implement @begin(). Accordingly, platforms implementing @begin()9191+ * should also provide a @end() which cleans up transitions aborted before9292 * @enter().9393 *9494 * @recover: Recover the platform from a suspend failure.···10793 int (*valid)(suspend_state_t state);10894 int (*begin)(suspend_state_t state);10995 int (*prepare)(void);9696+ int (*prepare_late)(void);11097 int (*enter)(suspend_state_t state);9898+ void (*wake)(void);11199 void (*finish)(void);112100 void (*end)(void);113101 void (*recover)(void);
+17-7
kernel/power/main.c
···291291292292 device_pm_lock();293293294294+ if (suspend_ops->prepare) {295295+ error = suspend_ops->prepare();296296+ if (error)297297+ goto Done;298298+ }299299+294300 error = device_power_down(PMSG_SUSPEND);295301 if (error) {296302 printk(KERN_ERR "PM: Some devices failed to power down\n");297297- goto Done;303303+ goto Platfrom_finish;298304 }299305300300- if (suspend_ops->prepare) {301301- error = suspend_ops->prepare();306306+ if (suspend_ops->prepare_late) {307307+ error = suspend_ops->prepare_late();302308 if (error)303309 goto Power_up_devices;304310 }305311306312 if (suspend_test(TEST_PLATFORM))307307- goto Platfrom_finish;313313+ goto Platform_wake;308314309315 error = disable_nonboot_cpus();310316 if (error || suspend_test(TEST_CPUS))···332326 Enable_cpus:333327 enable_nonboot_cpus();334328335335- Platfrom_finish:336336- if (suspend_ops->finish)337337- suspend_ops->finish();329329+ Platform_wake:330330+ if (suspend_ops->wake)331331+ suspend_ops->wake();338332339333 Power_up_devices:340334 device_power_up(PMSG_RESUME);335335+336336+ Platfrom_finish:337337+ if (suspend_ops->finish)338338+ suspend_ops->finish();341339342340 Done:343341 device_pm_unlock();