@@ -578,6 +578,35 @@ bool dev_pm_skip_resume(struct device *dev)
578578 return !dev -> power .must_resume ;
579579}
580580
581+ static bool is_async (struct device * dev )
582+ {
583+ return dev -> power .async_suspend && pm_async_enabled
584+ && !pm_trace_is_enabled ();
585+ }
586+
587+ static bool dpm_async_fn (struct device * dev , async_func_t func )
588+ {
589+ reinit_completion (& dev -> power .completion );
590+
591+ if (is_async (dev )) {
592+ dev -> power .async_in_progress = true;
593+
594+ get_device (dev );
595+
596+ if (async_schedule_dev_nocall (func , dev ))
597+ return true;
598+
599+ put_device (dev );
600+ }
601+ /*
602+ * Because async_schedule_dev_nocall() above has returned false or it
603+ * has not been called at all, func() is not running and it is safe to
604+ * update the async_in_progress flag without extra synchronization.
605+ */
606+ dev -> power .async_in_progress = false;
607+ return false;
608+ }
609+
581610/**
582611 * device_resume_noirq - Execute a "noirq resume" callback for given device.
583612 * @dev: Device to handle.
@@ -664,35 +693,6 @@ static void device_resume_noirq(struct device *dev, pm_message_t state, bool asy
664693 }
665694}
666695
667- static bool is_async (struct device * dev )
668- {
669- return dev -> power .async_suspend && pm_async_enabled
670- && !pm_trace_is_enabled ();
671- }
672-
673- static bool dpm_async_fn (struct device * dev , async_func_t func )
674- {
675- reinit_completion (& dev -> power .completion );
676-
677- if (is_async (dev )) {
678- dev -> power .async_in_progress = true;
679-
680- get_device (dev );
681-
682- if (async_schedule_dev_nocall (func , dev ))
683- return true;
684-
685- put_device (dev );
686- }
687- /*
688- * Because async_schedule_dev_nocall() above has returned false or it
689- * has not been called at all, func() is not running and it is safe to
690- * update the async_in_progress flag without extra synchronization.
691- */
692- dev -> power .async_in_progress = false;
693- return false;
694- }
695-
696696static void async_resume_noirq (void * data , async_cookie_t cookie )
697697{
698698 struct device * dev = data ;
0 commit comments