From patchwork Tue Nov 26 11:04:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3238741 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 9AEC3C045B for ; Tue, 26 Nov 2013 11:05:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D392203DC for ; Tue, 26 Nov 2013 11:05:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02EB2203B6 for ; Tue, 26 Nov 2013 11:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756502Ab3KZLE4 (ORCPT ); Tue, 26 Nov 2013 06:04:56 -0500 Received: from mail-lb0-f180.google.com ([209.85.217.180]:44659 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755495Ab3KZLEy (ORCPT ); Tue, 26 Nov 2013 06:04:54 -0500 Received: by mail-lb0-f180.google.com with SMTP id w6so4149275lbh.25 for ; Tue, 26 Nov 2013 03:04:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VfCcjo2xN1Dn0Zs95PI1ssQC2xdvTHOduUvkyR/X+OE=; b=hSUSa2OKdY6nmXL/dVjYGKJ2OKxcBt5mT0QOC7JP2w9ViJrjufzw3SnufLetSq52OO NXAI3Q4YRWYJfr5rnsdXgyM3rWf2gaXMaXY1CBWo2Dna8ptfP7Lm4hp6Hp4dyNMRp9gD u4C6PW6jCZ5eSjj1TgPJcJnT1yWDiX1x6xqFn79usm10tpeholy1cDAhKLsVqgyfjMe+ FWATSXLvBVhFmzsorvp9iZoKUsCQMyBtWxkU9UHdMEgfaWd9JeuMBAIvzT0UTIvdpPy6 Pbm+sf4U5CoEKsW0TTPFTKUEDHL0XoG28OItBqXSJlqVR3o6Jl9kqotOISVDbNjLfxQ0 iulA== X-Gm-Message-State: ALoCoQkiNV3mDj2hUJ2XxrtIvvOq2pq7nlUCvaa/W6VtEjhosLk2lKOLJ7rb+YX/X1ai/YnLcjat X-Received: by 10.152.20.6 with SMTP id j6mr25332484lae.8.1385463893538; Tue, 26 Nov 2013 03:04:53 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id bo10sm9566938lbb.16.2013.11.26.03.04.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 03:04:52 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, Ulf Hansson , Kevin Hilman , Alan Stern Subject: [PATCH 1/2] PM / Runtime: Add second macro for definition of runtime PM callbacks Date: Tue, 26 Nov 2013 12:04:45 +0100 Message-Id: <1385463886-9335-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 It is allowed and will in many cases make sense to have the runtime PM callbacks to be defined for CONFIG_PM instead of CONFIG_PM_RUNTIME. Since the PM core disables runtime PM during system suspend, before the .suspend_late callbacks are invoked, drivers could at this point directly invoke it's runtime PM callbacks or even walk through it's bus or power domain, to put it's device into low power state. Use the new macro SET_PM_RUNTIME_PM_OPS in cases were the above makes sense. Make sure the callbacks are encapsulated within CONFIG_PM instead of CONFIG_PM_RUNTIME. Do note that the old macro SET_RUNTIME_PM_OPS, which is being quite widely used right now, requires the callbacks to be defined for CONFIG_PM_RUNTIME. In many cases it will certainly be convenient to convert to the new macro above, but still some cases are optimal for only CONFIG_PM_RUNTIME. Cc: Kevin Hilman Cc: Alan Stern Signed-off-by: Ulf Hansson --- include/linux/pm.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/pm.h b/include/linux/pm.h index a224c7f..7a830a7 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -320,6 +320,15 @@ struct dev_pm_ops { #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) #endif +#ifdef CONFIG_PM +#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = suspend_fn, \ + .runtime_resume = resume_fn, \ + .runtime_idle = idle_fn, +#else +#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) +#endif + /* * Use this if you want to use the same suspend and resume callbacks for suspend * to RAM and hibernation.