From patchwork Mon Feb 20 20:33:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9583641 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68F9C600C1 for ; Mon, 20 Feb 2017 20:34:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586982886C for ; Mon, 20 Feb 2017 20:34:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A46228892; Mon, 20 Feb 2017 20:34:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 024612886C for ; Mon, 20 Feb 2017 20:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752319AbdBTUeE (ORCPT ); Mon, 20 Feb 2017 15:34:04 -0500 Received: from albert.telenet-ops.be ([195.130.137.90]:42256 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbdBTUeC (ORCPT ); Mon, 20 Feb 2017 15:34:02 -0500 Received: from ayla.of.borg ([84.193.137.253]) by albert.telenet-ops.be with bizsmtp id n8Zs1u00E5UCtCs068Zsmg; Mon, 20 Feb 2017 21:34:00 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1cfuee-0003mj-2P; Mon, 20 Feb 2017 21:33:52 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1cfuee-0006YG-1F; Mon, 20 Feb 2017 21:33:52 +0100 From: Geert Uytterhoeven To: Lorenzo Pieralisi , Mark Rutland , Sudeep Holla , Lina Iyer , John Stultz , Thomas Gleixner , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Rob Herring Cc: Magnus Damm , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 2/6] PM / Wakeup: Add wakeup_source_available() Date: Mon, 20 Feb 2017 21:33:25 +0100 Message-Id: <1487622809-25127-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487622809-25127-1-git-send-email-geert+renesas@glider.be> References: <1487622809-25127-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a helper function to find out if any wake-up sources have been registered. Signed-off-by: Geert Uytterhoeven --- drivers/base/power/wakeup.c | 8 ++++++++ include/linux/pm_wakeup.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index f546f8f107b06a45..1cf8320ed1a67dc4 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -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. diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index a3447932df1ff0a0..c5eaa8dbf27033df 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h @@ -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;