From patchwork Mon Feb 10 16:12:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 3620511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 195909F382 for ; Mon, 10 Feb 2014 16:20:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EE7620148 for ; Mon, 10 Feb 2014 16:20:07 +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 EE51B2010F for ; Mon, 10 Feb 2014 16:20:05 +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 1WCtZG-0004Mn-Qi; Mon, 10 Feb 2014 16:18:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCtUM-0001Xs-Mk; Mon, 10 Feb 2014 16:13:42 +0000 Received: from qmta02.emeryville.ca.mail.comcast.net ([2001:558:fe2d:43:76:96:30:24]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCtTn-0001SK-68 for linux-arm-kernel@lists.infradead.org; Mon, 10 Feb 2014 16:13:10 +0000 Received: from omta23.emeryville.ca.mail.comcast.net ([76.96.30.90]) by qmta02.emeryville.ca.mail.comcast.net with comcast id Qdtb1n0011wfjNsA2gCikb; Mon, 10 Feb 2014 16:12:42 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta23.emeryville.ca.mail.comcast.net with comcast id QgCg1n0090MU7Qa8jgCgBH; 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 BD0B8402AE; Mon, 10 Feb 2014 09:12:39 -0700 (MST) From: Shuah Khan To: rjw@rjwysocki.net, linux@arm.linux.org.uk Subject: [RFT][PATCH 01/12] arm: change locomo platform and bus power management to use dev_pm_ops Date: Mon, 10 Feb 2014 09:12:24 -0700 Message-Id: <7483e110cf0e8938e4df73dbf7f9e8da1315e9af.1392040066.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=C4QuRisBtRSuwwluD5JW2ptM1/Dr7uwumhfzP5lIhk4=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=mFhjxWXxYnEe/qu2DMiUtV7XS+vKeIK6sAZn/0OIORob349Fb13jCjBCJ3BIZoRl7 nen7mXB6z+cEs+MQN5q6gODrYn2KnYIT6KeeYt35zXskXjXErb1ZdUPoX32inQRKcT 005ADUcH9gTCFTgI+K+gcl0HGAqXRV8Dc8hQnIWWb5prsOyHGurk5t88HL+I3Le4MB mb9y8qkBqwKVh8K6euaj70hWYMWLg9rpZNUBK+YJz31FFyPGHSeb4sAcBIwBMOZ4Ht B5kJVee4GKI674utSs0SysTTIdjHvK7Y2awwSzvbchi9vuVoa4zD4+f7Nv74PbCjQt xHWnYn9OPz1SA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140210_111307_452109_A48C1112 X-CRM114-Status: GOOD ( 15.17 ) 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 locomo 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/locomo.c | 93 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 15 deletions(-) diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index b55c362..a48effb 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c @@ -272,7 +272,7 @@ struct locomo_save_data { u16 LCM_SPIMD; }; -static int locomo_suspend(struct platform_device *dev, pm_message_t state) +static int __locomo_suspend(struct platform_device *dev, pm_message_t state) { struct locomo *lchip = platform_get_drvdata(dev); struct locomo_save_data *save; @@ -316,7 +316,22 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state) return 0; } -static int locomo_resume(struct platform_device *dev) +static int locomo_suspend(struct device *dev) +{ + return __locomo_suspend(to_platform_device(dev), PMSG_SUSPEND); +} + +static int locomo_freeze(struct device *dev) +{ + return __locomo_suspend(to_platform_device(dev), PMSG_FREEZE); +} + +static int locomo_poweroff(struct device *dev) +{ + return __locomo_suspend(to_platform_device(dev), PMSG_HIBERNATE); +} + +static int __locomo_resume(struct platform_device *dev) { struct locomo *lchip = platform_get_drvdata(dev); struct locomo_save_data *save; @@ -351,6 +366,11 @@ static int locomo_resume(struct platform_device *dev) return 0; } + +static int locomo_resume(struct device *dev) +{ + return __locomo_resume(to_platform_device(dev)); +} #endif @@ -510,6 +530,18 @@ static int locomo_remove(struct platform_device *dev) return 0; } +#ifdef CONFIG_PM +static const struct dev_pm_ops locomo_dev_pm_ops = { + .suspend = locomo_suspend, + .resume = locomo_resume, + /* Hibernate hooks */ + .freeze = locomo_freeze, + .thaw = locomo_resume, + .poweroff = locomo_poweroff, + .restore = locomo_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 @@ -519,12 +551,11 @@ static int locomo_remove(struct platform_device *dev) static struct platform_driver locomo_device_driver = { .probe = locomo_probe, .remove = locomo_remove, -#ifdef CONFIG_PM - .suspend = locomo_suspend, - .resume = locomo_resume, -#endif .driver = { .name = "locomo", +#ifdef CONFIG_PM + .pm = &locomo_dev_pm_ops, +#endif }, }; @@ -826,26 +857,45 @@ static int locomo_match(struct device *_dev, struct device_driver *_drv) return dev->devid == drv->devid; } -static int locomo_bus_suspend(struct device *dev, pm_message_t state) +static int __locomo_bus_suspend(struct device *dev, pm_message_t state) { struct locomo_dev *ldev = LOCOMO_DEV(dev); struct locomo_driver *drv = LOCOMO_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(ldev, state); - return ret; + return drv->suspend(ldev, state); + return 0; +} + +static int locomo_bus_suspend(struct device *dev) +{ + return __locomo_bus_suspend(dev, PMSG_SUSPEND); +} + +static int locomo_bus_freeze(struct device *dev) +{ + return __locomo_bus_suspend(dev, PMSG_FREEZE); +} + +static int locomo_bus_poweroff(struct device *dev) +{ + return __locomo_bus_suspend(dev, PMSG_HIBERNATE); } static int locomo_bus_resume(struct device *dev) { struct locomo_dev *ldev = LOCOMO_DEV(dev); struct locomo_driver *drv = LOCOMO_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(ldev); - return ret; + return drv->resume(ldev); + return 0; } static int locomo_bus_probe(struct device *dev) @@ -870,13 +920,26 @@ static int locomo_bus_remove(struct device *dev) return ret; } +#ifdef CONFIG_PM +static const struct dev_pm_ops locomo_bus_dev_pm_ops = { + .suspend = locomo_bus_suspend, + .resume = locomo_bus_resume, + /* Hibernate hooks */ + .freeze = locomo_bus_freeze, + .thaw = locomo_bus_resume, + .poweroff = locomo_bus_poweroff, + .restore = locomo_bus_resume, +}; +#endif + struct bus_type locomo_bus_type = { .name = "locomo-bus", .match = locomo_match, .probe = locomo_bus_probe, .remove = locomo_bus_remove, - .suspend = locomo_bus_suspend, - .resume = locomo_bus_resume, +#ifdef CONFIG_PM + .pm = &locomo_bus_dev_pm_ops, +#endif }; int locomo_driver_register(struct locomo_driver *driver)