@@ -232,6 +232,14 @@ void wakeup_source_unregister(struct wakeup_source *ws)
EXPORT_SYMBOL_GPL(wakeup_source_unregister);
/**
+ * wakeup_source_available - Check if any wakeup sources have been registered
+ */
+bool wakeup_source_available(void)
+{
+ return !list_empty(&wakeup_sources);
+}
+
+/**
* device_wakeup_attach - Attach a wakeup source object to a device object.
* @dev: Device to handle.
* @ws: Wakeup source object to attach to @dev.
@@ -97,6 +97,7 @@ extern void wakeup_source_add(struct wakeup_source *ws);
extern void wakeup_source_remove(struct wakeup_source *ws);
extern struct wakeup_source *wakeup_source_register(const char *name);
extern void wakeup_source_unregister(struct wakeup_source *ws);
+extern bool wakeup_source_available(void);
extern int device_wakeup_enable(struct device *dev);
extern int device_wakeup_disable(struct device *dev);
extern void device_set_wakeup_capable(struct device *dev, bool capable);
@@ -144,6 +145,8 @@ static inline struct wakeup_source *wakeup_source_register(const char *name)
static inline void wakeup_source_unregister(struct wakeup_source *ws) {}
+static inline bool wakeup_source_available(void) { return false; }
+
static inline int device_wakeup_enable(struct device *dev)
{
dev->power.should_wakeup = true;
Add a helper function to find out if any wake-up sources have been registered. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/base/power/wakeup.c | 8 ++++++++ include/linux/pm_wakeup.h | 3 +++ 2 files changed, 11 insertions(+)