aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/main.c15
-rw-r--r--include/linux/pm.h7
2 files changed, 14 insertions, 8 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 7ae6fe414c38..31b526661ec4 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -51,6 +51,8 @@ static pm_message_t pm_transition;
51 */ 51 */
52static bool transition_started; 52static bool transition_started;
53 53
54static int async_error;
55
54/** 56/**
55 * device_pm_init - Initialize the PM-related part of a device object. 57 * device_pm_init - Initialize the PM-related part of a device object.
56 * @dev: Device object being initialized. 58 * @dev: Device object being initialized.
@@ -602,6 +604,7 @@ static void dpm_resume(pm_message_t state)
602 INIT_LIST_HEAD(&list); 604 INIT_LIST_HEAD(&list);
603 mutex_lock(&dpm_list_mtx); 605 mutex_lock(&dpm_list_mtx);
604 pm_transition = state; 606 pm_transition = state;
607 async_error = 0;
605 608
606 list_for_each_entry(dev, &dpm_list, power.entry) { 609 list_for_each_entry(dev, &dpm_list, power.entry) {
607 if (dev->power.status < DPM_OFF) 610 if (dev->power.status < DPM_OFF)
@@ -831,8 +834,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state,
831 return error; 834 return error;
832} 835}
833 836
834static int async_error;
835
836/** 837/**
837 * device_suspend - Execute "suspend" callbacks for given device. 838 * device_suspend - Execute "suspend" callbacks for given device.
838 * @dev: Device to handle. 839 * @dev: Device to handle.
@@ -887,6 +888,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
887 device_unlock(dev); 888 device_unlock(dev);
888 complete_all(&dev->power.completion); 889 complete_all(&dev->power.completion);
889 890
891 if (error)
892 async_error = error;
893
890 return error; 894 return error;
891} 895}
892 896
@@ -896,10 +900,8 @@ static void async_suspend(void *data, async_cookie_t cookie)
896 int error; 900 int error;
897 901
898 error = __device_suspend(dev, pm_transition, true); 902 error = __device_suspend(dev, pm_transition, true);
899 if (error) { 903 if (error)
900 pm_dev_err(dev, pm_transition, " async", error); 904 pm_dev_err(dev, pm_transition, " async", error);
901 async_error = error;
902 }
903 905
904 put_device(dev); 906 put_device(dev);
905} 907}
@@ -1087,8 +1089,9 @@ EXPORT_SYMBOL_GPL(__suspend_report_result);
1087 * @dev: Device to wait for. 1089 * @dev: Device to wait for.
1088 * @subordinate: Device that needs to wait for @dev. 1090 * @subordinate: Device that needs to wait for @dev.
1089 */ 1091 */
1090void device_pm_wait_for_dev(struct device *subordinate, struct device *dev) 1092int device_pm_wait_for_dev(struct device *subordinate, struct device *dev)
1091{ 1093{
1092 dpm_wait(dev, subordinate->power.async_suspend); 1094 dpm_wait(dev, subordinate->power.async_suspend);
1095 return async_error;
1093} 1096}
1094EXPORT_SYMBOL_GPL(device_pm_wait_for_dev); 1097EXPORT_SYMBOL_GPL(device_pm_wait_for_dev);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index a84118911ced..1abfe84f447d 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -559,7 +559,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
559 __suspend_report_result(__func__, fn, ret); \ 559 __suspend_report_result(__func__, fn, ret); \
560 } while (0) 560 } while (0)
561 561
562extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); 562extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
563#else /* !CONFIG_PM_SLEEP */ 563#else /* !CONFIG_PM_SLEEP */
564 564
565#define device_pm_lock() do {} while (0) 565#define device_pm_lock() do {} while (0)
@@ -572,7 +572,10 @@ static inline int dpm_suspend_start(pm_message_t state)
572 572
573#define suspend_report_result(fn, ret) do {} while (0) 573#define suspend_report_result(fn, ret) do {} while (0)
574 574
575static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} 575static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
576{
577 return 0;
578}
576#endif /* !CONFIG_PM_SLEEP */ 579#endif /* !CONFIG_PM_SLEEP */
577 580
578/* How to reorder dpm_list after device_move() */ 581/* How to reorder dpm_list after device_move() */