From patchwork Mon Feb 24 17:08:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Cartwright X-Patchwork-Id: 3710721 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 2CAB5BF13A for ; Mon, 24 Feb 2014 17:11:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C8B420160 for ; Mon, 24 Feb 2014 17:11:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8623920154 for ; Mon, 24 Feb 2014 17:11:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752452AbaBXRLG (ORCPT ); Mon, 24 Feb 2014 12:11:06 -0500 Received: from smtp.codeaurora.org ([198.145.11.231]:45076 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464AbaBXRLE (ORCPT ); Mon, 24 Feb 2014 12:11:04 -0500 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id D852E13EF4A; Mon, 24 Feb 2014 17:11:03 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id CC11013F121; Mon, 24 Feb 2014 17:11:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from joshc.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: joshc@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7949C13EF4A; Mon, 24 Feb 2014 17:11:03 +0000 (UTC) Received: by joshc.qualcomm.com (Postfix, from userid 1000) id F35E76353C; Mon, 24 Feb 2014 11:08:27 -0600 (CST) From: Josh Cartwright To: Pavel Machek , "Rafael J. Wysocki" , Len Brown Cc: Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] PM: define new ASSIGN_*_PM_OPS macros based on assign_if Date: Mon, 24 Feb 2014 11:08:26 -0600 Message-Id: <1393261707-30565-3-git-send-email-joshc@codeaurora.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393261707-30565-1-git-send-email-joshc@codeaurora.org> References: <1393261707-30565-1-git-send-email-joshc@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Similar to the SET_*_PM_OPS(), these functions are to be used in initializers of struct dev_pm_ops, for example: static const struct dev_pm_ops foo_pm_ops = { ASSIGN_RUNTIME_PM_OPS(foo_rpm_suspend, foo_rpm_resume, NULL) ASSIGN_SYSTEM_SLEEP_PM_OPS(foo_suspend, foo_resume) }; Unlike their SET_*_PM_OPS() counter parts, it is unnecessary to wrap the function callbacks in #ifdeffery in order to prevent 'defined but not used' warnings when the corresponding CONFIG_PM* options are unset. Signed-off-by: Josh Cartwright --- include/linux/pm.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/linux/pm.h b/include/linux/pm.h index db2be5f..3810d56 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -299,6 +299,15 @@ struct dev_pm_ops { int (*runtime_idle)(struct device *dev); }; +#define assign_if_pm_sleep(fn) \ + assign_if_enabled(CONFIG_PM_SLEEP, fn) + +#define assign_if_pm_runtime(fn) \ + assign_if_enabled(CONFIG_PM_RUNTIME, fn) + +#define assign_if_pm(fn) \ + assign_if_enabled(CONFIG_PM, fn) + #ifdef CONFIG_PM_SLEEP #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ .suspend = suspend_fn, \ @@ -342,6 +351,36 @@ struct dev_pm_ops { #endif /* + * The ASSIGN_* variations of the above make wrapping the associated callback + * functions in preprocessor defines unnecessary. + */ +#define ASSIGN_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \ + .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn), + +#define ASSIGN_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ + .suspend_late = assign_if_pm_sleep(suspend_fn), \ + .resume_early = assign_if_pm_sleep(resume_fn), \ + .freeze_late = assign_if_pm_sleep(suspend_fn), \ + .thaw_early = assign_if_pm_sleep(resume_fn), \ + .poweroff_late = assign_if_pm_sleep(suspend_fn), \ + .restore_early = assign_if_pm_sleep(resume_fn), + +#define ASSIGN_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm_runtime(suspend_fn), \ + .runtime_resume = assign_if_pm_runtime(resume_fn), \ + .runtime_idle = assign_if_pm_runtime(idle_fn), + +#define ASSIGN_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm(suspend_fn), \ + .runtime_resume = assign_if_pm(resume_fn), \ + .runtime_idle = assign_if_pm(idle_fn), + +/* * Use this if you want to use the same suspend and resume callbacks for suspend * to RAM and hibernation. */