From patchwork Tue Aug 18 21:08:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7033701 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A268BC05AC for ; Tue, 18 Aug 2015 21:08:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCF6820528 for ; Tue, 18 Aug 2015 21:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06C9820772 for ; Tue, 18 Aug 2015 21:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753933AbbHRVIa (ORCPT ); Tue, 18 Aug 2015 17:08:30 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:36707 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753602AbbHRVI3 (ORCPT ); Tue, 18 Aug 2015 17:08:29 -0400 Received: by wicja10 with SMTP id ja10so104603467wic.1; Tue, 18 Aug 2015 14:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=BXgIce8Nxe/ph6WISkHbhMT986AQ+/dYXg9zCfRRNEk=; b=TbC6DycBsBH5E19Q4og0LCb13mmFV7So6e6JG9QfnE4dC8Cije/JSxuRLokihhe+dh JRnGh3xy4Ie7v/SL9tpqha10/QJvNBtFkkcQ8lydzob44Kpuog068GMXR22s/4+ChRgM 4hR6L6oXRkPyzXDdwCT2nGBKQNfFIU3/iEvD0T4LxPnWmmcOJmaZPPzECqgArn/ZIFz+ l470UZLqf8MygVsbGf/ffsVxA15lrcoZ4yfV0lzkL90y5zGAL4VfIcK3dEqYm9frKgPX 7CVs/fKwPyy4TEHh9gB0r2rn5LD39k6g38T0ydAiYZctF00tLAtBqLxjac7ru4b6KNRX hfWQ== X-Received: by 10.180.99.39 with SMTP id en7mr45639154wib.49.1439932108275; Tue, 18 Aug 2015 14:08:28 -0700 (PDT) Received: from ?IPv6:2003:62:5f33:d300:704e:482e:50f5:2dd? (p200300625F33D300704E482E50F502DD.dip0.t-ipconnect.de. [2003:62:5f33:d300:704e:482e:50f5:2dd]) by smtp.googlemail.com with ESMTPSA id k4sm22947821wix.19.2015.08.18.14.08.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Aug 2015 14:08:27 -0700 (PDT) Message-ID: <55D39EB9.2090001@gmail.com> Date: Tue, 18 Aug 2015 23:08:09 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: linux-samsung-soc@vger.kernel.org CC: "linux-spi@vger.kernel.org" , Krzysztof Kozlowski Subject: [PATCH 3/3] spi: s3c64xx: simplify suspend/resume handlers Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 The runtime PM handlers take care of enabling / disabling the clock. Therefore use them to simplify the suspend / resume handlers. pm_runtime_suspend/resume internally check whether suspending/resuming is possible and return 1 in case PM state is suspended/active already. Currently there also seems to be a bug in the resume handler as suspend as well as resume check for !pm_runtime_disabled(dev). Signed-off-by: Heiner Kallweit --- drivers/spi/spi-s3c64xx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 15a6de1..78a6f04 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1242,10 +1242,9 @@ static int s3c64xx_spi_suspend(struct device *dev) if (ret) return ret; - if (!pm_runtime_suspended(dev)) { - clk_disable_unprepare(sdd->clk); - clk_disable_unprepare(sdd->src_clk); - } + ret = pm_runtime_suspend(dev); + if (ret < 0) + return ret; sdd->cur_speed = 0; /* Output Clock is stopped */ @@ -1257,14 +1256,14 @@ static int s3c64xx_spi_resume(struct device *dev) struct spi_master *master = dev_get_drvdata(dev); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_info *sci = sdd->cntrlr_info; + int ret; if (sci->cfg_gpio) sci->cfg_gpio(); - if (!pm_runtime_suspended(dev)) { - clk_prepare_enable(sdd->src_clk); - clk_prepare_enable(sdd->clk); - } + ret = pm_runtime_resume(dev); + if (ret < 0) + return ret; s3c64xx_spi_hwinit(sdd, sdd->port_id);