From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbcARCLs (ORCPT ); Sun, 17 Jan 2016 21:11:48 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:36789 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753371AbcARCLm (ORCPT ); Sun, 17 Jan 2016 21:11:42 -0500 Date: Sun, 17 Jan 2016 18:11:38 -0800 From: Dmitry Torokhov To: Greg Kroah-Hartman Cc: Rob Herring , Grant Likely , Linus Walleij , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: [PATCH] driver-core: platform: automatically mark wakeup devices Message-ID: <20160118021138.GA20498@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When probing platform drivers let's check if corresponding devices have "wakeup-source" property defined (either in device tree, ACPI, or static platform properties) and automatically enable such devices as wakeup sources for the system. This will help us standardize on the name for this property and reduce amount of boilerplate code in the drivers. Signed-off-by: Dmitry Torokhov --- drivers/base/platform.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1dd6d3b..d14071a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -514,9 +514,14 @@ static int platform_drv_probe(struct device *_dev) ret = dev_pm_domain_attach(_dev, true); if (ret != -EPROBE_DEFER && drv->probe) { + bool wakeup = device_property_read_bool(_dev, "wakeup-source"); + + device_init_wakeup(_dev, wakeup); ret = drv->probe(dev); - if (ret) + if (ret) { + device_init_wakeup(_dev, false); dev_pm_domain_detach(_dev, true); + } } if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { @@ -540,6 +545,8 @@ static int platform_drv_remove(struct device *_dev) if (drv->remove) ret = drv->remove(dev); + + device_init_wakeup(_dev, false); dev_pm_domain_detach(_dev, true); return ret; -- 2.6.0.rc2.230.g3dd15c0 -- Dmitry