From patchwork Mon Feb 10 16:12:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 3620501 Return-Path: X-Original-To: patchwork-linux-arm@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 7DC23BF418 for ; Mon, 10 Feb 2014 16:19:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF969201D5 for ; Mon, 10 Feb 2014 16:19:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2483F20148 for ; Mon, 10 Feb 2014 16:19:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCtZ8-0004GM-QL; Mon, 10 Feb 2014 16:18:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCtUG-0001XE-0p; Mon, 10 Feb 2014 16:13:36 +0000 Received: from qmta08.emeryville.ca.mail.comcast.net ([2001:558:fe2d:43:76:96:30:80]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCtTm-0001SL-Ds for linux-arm-kernel@lists.infradead.org; Mon, 10 Feb 2014 16:13:09 +0000 Received: from omta12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by qmta08.emeryville.ca.mail.comcast.net with comcast id Qg1K1n0030x6nqcA8gCiAk; Mon, 10 Feb 2014 16:12:42 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta12.emeryville.ca.mail.comcast.net with comcast id QgCg1n00d0MU7Qa8YgChpX; Mon, 10 Feb 2014 16:12:41 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 7F400406D1; Mon, 10 Feb 2014 09:12:40 -0700 (MST) From: Shuah Khan To: rjw@rjwysocki.net, linux@arm.linux.org.uk Subject: [RFT][PATCH 02/12] arm: change sa1111 platform and bus power management to use dev_pm_ops Date: Mon, 10 Feb 2014 09:12:25 -0700 Message-Id: <9946f14a5837560d5aa83bf3501685365a1aa759.1392040067.git.shuah.kh@samsung.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1392048762; bh=LStUw1IGCd9cDAU0LN0ylpC5sGgvCB0DQ93TPoZOzAk=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=Hij9mkO2REEc1PclvBGPlaurK9nJ7z1fNJnquXTmUg97694vUnRiCbmxZp2/RATa3 3S11yprZv7j3NHf5/Ss5OT8icmAcBvY+D31GOoruA8Hh3RSbhZ6aNLE4HXLWm7nrfy vlKQ1KUDAmwazbFL2GNQvNxn84780xaADopZLXYWTrT4fuIafS0gqIG48SdU5uxM5R x0PXYRDJhyOBhKfV7pouPqRc4VOfHYjRBB626e/22KvehzFjp6I/uXIoSZBdpUCHrr zRCqKKq9tz1PRFAZ4+jucg1Or3OrQLiX0MHrihy6leBICYjcwab7MJ6YaS4evnorK6 Jzff4bZEH/qcw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140210_111306_812319_D5677024 X-CRM114-Status: GOOD ( 16.05 ) X-Spam-Score: -1.9 (-) Cc: shuahkhan@gmail.com, Shuah Khan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org 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: , MIME-Version: 1.0 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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Change sa1111 platform and bus drivers to register pm ops using dev_pm_ops instead of legacy pm_ops. .pm hooks call existing legacy suspend and resume interfaces by passing in the right pm state. Signed-off-by: Shuah Khan --- arch/arm/common/sa1111.c | 88 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index e57d7e5..db017b2 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -872,7 +872,7 @@ struct sa1111_save_data { #ifdef CONFIG_PM -static int sa1111_suspend(struct platform_device *dev, pm_message_t state) +static int __sa1111_suspend(struct platform_device *dev, pm_message_t state) { struct sa1111 *sachip = platform_get_drvdata(dev); struct sa1111_save_data *save; @@ -928,6 +928,21 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) return 0; } +static int sa1111_suspend(struct device *dev) +{ + return __sa1111_suspend(to_platform_device(dev), PMSG_SUSPEND); +} + +static int sa1111_freeze(struct device *dev) +{ + return __sa1111_suspend(to_platform_device(dev), PMSG_FREEZE); +} + +static int sa1111_poweroff(struct device *dev) +{ + return __sa1111_suspend(to_platform_device(dev), PMSG_HIBERNATE); +} + /* * sa1111_resume - Restore the SA1111 device state. * @dev: device to restore @@ -937,7 +952,7 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) * restored by their respective drivers, and must be called * via LDM after this function. */ -static int sa1111_resume(struct platform_device *dev) +static int __sa1111_resume(struct platform_device *dev) { struct sa1111 *sachip = platform_get_drvdata(dev); struct sa1111_save_data *save; @@ -1005,9 +1020,10 @@ static int sa1111_resume(struct platform_device *dev) return 0; } -#else -#define sa1111_suspend NULL -#define sa1111_resume NULL +static int sa1111_resume(struct device *dev) +{ + return __sa1111_resume(to_platform_device(dev)); +} #endif static int sa1111_probe(struct platform_device *pdev) @@ -1041,6 +1057,18 @@ static int sa1111_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static const struct dev_pm_ops sa1111_dev_pm_ops = { + .suspend = sa1111_suspend, + .resume = sa1111_resume, + /* Hibernate hooks */ + .freeze = sa1111_freeze, + .thaw = sa1111_resume, + .poweroff = sa1111_poweroff, + .restore = sa1111_resume, +}; +#endif + /* * Not sure if this should be on the system bus or not yet. * We really want some way to register a system device at @@ -1053,11 +1081,12 @@ static int sa1111_remove(struct platform_device *pdev) static struct platform_driver sa1111_device_driver = { .probe = sa1111_probe, .remove = sa1111_remove, - .suspend = sa1111_suspend, - .resume = sa1111_resume, .driver = { .name = "sa1111", .owner = THIS_MODULE, +#ifdef CONFIG_PM + .pm = &sa1111_dev_pm_ops, +#endif }, }; @@ -1297,26 +1326,44 @@ static int sa1111_match(struct device *_dev, struct device_driver *_drv) return dev->devid & drv->devid; } -static int sa1111_bus_suspend(struct device *dev, pm_message_t state) +static int __sa1111_bus_suspend(struct device *dev, pm_message_t state) { struct sa1111_dev *sadev = SA1111_DEV(dev); struct sa1111_driver *drv = SA1111_DRV(dev->driver); - int ret = 0; + + if (drv && drv->drv.pm && drv->drv.pm->suspend) + return drv->drv.pm->suspend(dev); if (drv && drv->suspend) - ret = drv->suspend(sadev, state); - return ret; + return drv->suspend(sadev, state); + return 0; +} + +static int sa1111_bus_suspend(struct device *dev) +{ + return __sa1111_bus_suspend(dev, PMSG_SUSPEND); +} + +static int sa1111_bus_freeze(struct device *dev) +{ + return __sa1111_bus_suspend(dev, PMSG_FREEZE); +} + +static int sa1111_bus_poweroff(struct device *dev) +{ + return __sa1111_bus_suspend(dev, PMSG_HIBERNATE); } static int sa1111_bus_resume(struct device *dev) { struct sa1111_dev *sadev = SA1111_DEV(dev); struct sa1111_driver *drv = SA1111_DRV(dev->driver); - int ret = 0; + if (drv && drv->drv.pm && drv->drv.pm->resume) + return drv->drv.pm->resume(dev); if (drv && drv->resume) - ret = drv->resume(sadev); - return ret; + return drv->resume(sadev); + return 0; } static void sa1111_bus_shutdown(struct device *dev) @@ -1349,14 +1396,23 @@ static int sa1111_bus_remove(struct device *dev) return ret; } +static const struct dev_pm_ops sa1111_bus_dev_pm_ops = { + .suspend = sa1111_bus_suspend, + .resume = sa1111_bus_resume, + /* Hibernate hooks */ + .freeze = sa1111_bus_freeze, + .thaw = sa1111_bus_resume, + .poweroff = sa1111_bus_poweroff, + .restore = sa1111_bus_resume, +}; + struct bus_type sa1111_bus_type = { .name = "sa1111-rab", .match = sa1111_match, .probe = sa1111_bus_probe, .remove = sa1111_bus_remove, - .suspend = sa1111_bus_suspend, - .resume = sa1111_bus_resume, .shutdown = sa1111_bus_shutdown, + .pm = &sa1111_bus_dev_pm_ops, }; EXPORT_SYMBOL(sa1111_bus_type);