From patchwork Wed May 28 07:23:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 4253111 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D90C1BF90B for ; Wed, 28 May 2014 07:23:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3194E202E6 for ; Wed, 28 May 2014 07:23:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65093202C8 for ; Wed, 28 May 2014 07:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbaE1HXo (ORCPT ); Wed, 28 May 2014 03:23:44 -0400 Received: from mga11.intel.com ([192.55.52.93]:40127 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbaE1HXo (ORCPT ); Wed, 28 May 2014 03:23:44 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 28 May 2014 00:23:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,926,1392192000"; d="scan'208";a="546011059" Received: from unknown (HELO rzhang1-toshiba.ccr.corp.intel.com) ([10.255.20.133]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2014 00:23:41 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org Cc: rafael.j.wysocki@intel.com, anton@enomsg.org, Zhang Rui Subject: [PATCH 1/4] PM: unregister the wakeup source when disabling a device' wakeup capability Date: Wed, 28 May 2014 15:23:35 +0800 Message-Id: <1401261818-2978-2-git-send-email-rui.zhang@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401261818-2978-1-git-send-email-rui.zhang@intel.com> References: <1401261818-2978-1-git-send-email-rui.zhang@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 When enabling a device' wakeup capability, a wakeup source is created for the device automatically. But the wakeup source is not unregistered when disabling the device' wakeup capability. This results in zombie wakeup sources, after devices/drivers are unregistered. Signed-off-by: Zhang Rui --- drivers/base/power/wakeup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 2d56f41..030b069 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -318,10 +318,15 @@ int device_init_wakeup(struct device *dev, bool enable) { int ret = 0; + if (!dev) + return -EINVAL; + if (enable) { device_set_wakeup_capable(dev, true); ret = device_wakeup_enable(dev); } else { + if (dev->power.can_wakeup) + device_wakeup_disable(dev); device_set_wakeup_capable(dev, false); }