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: 3620341 Return-Path: X-Original-To: patchwork-linux-pm@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 6281A9F382 for ; Mon, 10 Feb 2014 16:18:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D47D2010F for ; Mon, 10 Feb 2014 16:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C97F9201D3 for ; Mon, 10 Feb 2014 16:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbaBJQSs (ORCPT ); Mon, 10 Feb 2014 11:18:48 -0500 Received: from qmta09.emeryville.ca.mail.comcast.net ([76.96.30.96]:38400 "EHLO qmta09.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbaBJQSr (ORCPT ); Mon, 10 Feb 2014 11:18:47 -0500 X-Greylist: delayed 365 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Feb 2014 11:18:47 EST Received: from omta23.emeryville.ca.mail.comcast.net ([76.96.30.90]) by qmta09.emeryville.ca.mail.comcast.net with comcast id Qfqw1n0031wfjNsA9gCiEJ; 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 Cc: Shuah Khan , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, shuahkhan@gmail.com 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=igU+6J9Q74VVnCLvl1LdAD//tVS5N3rdP8OXLg5EvZb2Uyi5wZCCWJwq2ZjNV554T 49iFrIWfLLERioA/H0gdpRXDWK+XFOy98IoJVB7WBG7XS6UEfaEuOKLV+ujcnDr3W7 oKXv6xa6ko2i9rVjlY54qZMBmB12gag2qMc8RIC4Fr12cqqmcbEYmnkJI8oYAwvBo2 PDIGlkppVhSrNnhcKY/Bdtaa0emaIB366TTva4wXaiz3r0PjR/x+dX4qYp/qRbZPmw NiBqxrvk4mCLQJVT/83RGzdGpw/oHFfT+ooFDowadDF3457+mOh420WndN4Ic9A2je CqtoRFxRAFJOg== 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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)