From patchwork Tue Oct 21 03:43:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 5109101 Return-Path: X-Original-To: patchwork-linux-spi@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 40BF19F30B for ; Tue, 21 Oct 2014 03:47:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5760F200E0 for ; Tue, 21 Oct 2014 03:47:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DCE620176 for ; Tue, 21 Oct 2014 03:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751666AbaJUDri (ORCPT ); Mon, 20 Oct 2014 23:47:38 -0400 Received: from eusmtp01.atmel.com ([212.144.249.243]:48811 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751181AbaJUDri (ORCPT ); Mon, 20 Oct 2014 23:47:38 -0400 Received: from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.347.0; Tue, 21 Oct 2014 05:47:28 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.347.0; Tue, 21 Oct 2014 11:46:59 +0800 From: Wenyou Yang To: CC: , , , , , Subject: [PATCH] spi/atmel: improve the system suspend/resume functions implementation Date: Tue, 21 Oct 2014 11:43:34 +0800 Message-ID: <1413863014-1791-1-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 To make it cleaner, the system suspend/resume directly call the runtime suspend/resume functions and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP. Signed-off-by: Wenyou Yang Acked-by: Kevin Hilman Acked-by: Nicolas Ferre --- drivers/spi/spi-atmel.c | 61 ++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 3f50014..6ed1893 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1451,11 +1451,30 @@ static int atmel_spi_remove(struct platform_device *pdev) } #ifdef CONFIG_PM -#ifdef CONFIG_PM_SLEEP +static int atmel_spi_runtime_suspend(struct device *dev) +{ + struct spi_master *master = dev_get_drvdata(dev); + struct atmel_spi *as = spi_master_get_devdata(master); + + clk_disable_unprepare(as->clk); + pinctrl_pm_select_sleep_state(dev); + + return 0; +} + +static int atmel_spi_runtime_resume(struct device *dev) +{ + struct spi_master *master = dev_get_drvdata(dev); + struct atmel_spi *as = spi_master_get_devdata(master); + + pinctrl_pm_select_default_state(dev); + + return clk_prepare_enable(as->clk); +} + static int atmel_spi_suspend(struct device *dev) { - struct spi_master *master = dev_get_drvdata(dev); - struct atmel_spi *as = spi_master_get_devdata(master); + struct spi_master *master = dev_get_drvdata(dev); int ret; /* Stop the queue running */ @@ -1465,23 +1484,19 @@ static int atmel_spi_suspend(struct device *dev) return ret; } - if (!pm_runtime_suspended(dev)) { - clk_disable_unprepare(as->clk); - pinctrl_pm_select_sleep_state(dev); - } + if (!pm_runtime_suspended(dev)) + atmel_spi_runtime_suspend(dev); return 0; } static int atmel_spi_resume(struct device *dev) { - struct spi_master *master = dev_get_drvdata(dev); - struct atmel_spi *as = spi_master_get_devdata(master); + struct spi_master *master = dev_get_drvdata(dev); int ret; if (!pm_runtime_suspended(dev)) { - pinctrl_pm_select_default_state(dev); - ret = clk_prepare_enable(as->clk); + ret = atmel_spi_runtime_resume(dev); if (ret) return ret; } @@ -1493,30 +1508,6 @@ static int atmel_spi_resume(struct device *dev) return ret; } -#endif - -#ifdef CONFIG_PM_RUNTIME -static int atmel_spi_runtime_suspend(struct device *dev) -{ - struct spi_master *master = dev_get_drvdata(dev); - struct atmel_spi *as = spi_master_get_devdata(master); - - clk_disable_unprepare(as->clk); - pinctrl_pm_select_sleep_state(dev); - - return 0; -} - -static int atmel_spi_runtime_resume(struct device *dev) -{ - struct spi_master *master = dev_get_drvdata(dev); - struct atmel_spi *as = spi_master_get_devdata(master); - - pinctrl_pm_select_default_state(dev); - - return clk_prepare_enable(as->clk); -} -#endif static const struct dev_pm_ops atmel_spi_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(atmel_spi_suspend, atmel_spi_resume)