From patchwork Tue Nov 12 13:52:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas KANDAGATLA X-Patchwork-Id: 3172921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CBD829F3A0 for ; Tue, 12 Nov 2013 14:26:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4C5C204E7 for ; Tue, 12 Nov 2013 14:26:46 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24023204D1 for ; Tue, 12 Nov 2013 14:26:45 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgES1-00016t-M5; Tue, 12 Nov 2013 13:56:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgERG-0006Ja-Vm; Tue, 12 Nov 2013 13:55:30 +0000 Received: from eu1sys200aog110.obsmtp.com ([207.126.144.129]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgEQ6-00068q-Oa for linux-arm-kernel@lists.infradead.org; Tue, 12 Nov 2013 13:54:21 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob110.postini.com ([207.126.147.11]) with SMTP ID DSNKUoIy4ugyB3QZOg5eEkbXf+Y84reMNLlF@postini.com; Tue, 12 Nov 2013 13:54:18 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4362BFE; Tue, 12 Nov 2013 13:53:06 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6D177542D; Tue, 12 Nov 2013 13:40:14 +0000 (GMT) Received: from localhost (10.65.51.59) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 12 Nov 2013 14:53:37 +0100 From: To: , Subject: [PATCH RFC 07/10] PM / wakeup : Introduce device_child_may_wakeup Date: Tue, 12 Nov 2013 13:52:57 +0000 Message-ID: <1384264377-7609-1-git-send-email-srinivas.kandagatla@st.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1384264311-7308-1-git-send-email-srinivas.kandagatla@st.com> References: <1384264311-7308-1-git-send-email-srinivas.kandagatla@st.com> MIME-Version: 1.0 X-Originating-IP: [10.65.51.59] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131112_085419_112043_F6DC207E X-CRM114-Status: GOOD ( 15.92 ) X-Spam-Score: -4.2 (----) Cc: Mark Rutland , Len Brown , Russell King , Pavel Machek , Pawel Moll , Ian Campbell , Srinivas Kandagatla , Greg Kroah-Hartman , linux-pm@vger.kernel.org, Stephen Warren , "Rafael J. Wysocki" , stephen.gallimore@st.com, Rob Herring , linux-doc@vger.kernel.org, Stuart Menefy , devicetree@vger.kernel.org, Rob Landley , Grant Likely , Giuseppe Cavallaro , linux-kernel@vger.kernel.org, kernel@stlinux.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srinivas Kandagatla This patch introduces device_child_may_wakeup function, which will be useful for wrapper or SoC level driver power management code. Without this patch each driver has to write this same code to get the functionality. Signed-off-by: Srinivas Kandagatla --- drivers/base/power/wakeup.c | 23 +++++++++++++++++++++++ include/linux/pm_wakeup.h | 1 + 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 2d56f41..270f000 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -342,6 +342,29 @@ int device_set_wakeup_enable(struct device *dev, bool enable) } EXPORT_SYMBOL_GPL(device_set_wakeup_enable); +/* callback for device_child_may_wakeup */ +static int __device_child_may_wakeup(struct device *dev, void *c) +{ + return device_may_wakeup(dev); +} + +/** + * device_child_may_wakeup - Check if any of the child devices are wakeup + * sources. + * @dev: parent device to handle. + * + * Function to check if any of the children of a given parent are wakeup + * sources. + * + * This function will return true if any one of the children of given parent + * are wakeup sources, else it returns false. + */ +bool device_child_may_wakeup(struct device *parent) +{ + return device_for_each_child(parent, NULL, __device_child_may_wakeup); +} +EXPORT_SYMBOL_GPL(device_child_may_wakeup); + /* * The functions below use the observation that each wakeup event starts a * period in which the system should not be suspended. The moment this period diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index a0f7080..b376584 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h @@ -93,6 +93,7 @@ extern int device_wakeup_disable(struct device *dev); extern void device_set_wakeup_capable(struct device *dev, bool capable); extern int device_init_wakeup(struct device *dev, bool val); extern int device_set_wakeup_enable(struct device *dev, bool enable); +bool device_child_may_wakeup(struct device *parent); extern void __pm_stay_awake(struct wakeup_source *ws); extern void pm_stay_awake(struct device *dev); extern void __pm_relax(struct wakeup_source *ws);