From patchwork Wed Oct 14 20:12:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 7398221 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E79E49F443 for ; Wed, 14 Oct 2015 20:13:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A69C206B6 for ; Wed, 14 Oct 2015 20:13:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 353D5209B4 for ; Wed, 14 Oct 2015 20:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754604AbbJNUND (ORCPT ); Wed, 14 Oct 2015 16:13:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:12100 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754577AbbJNUNB (ORCPT ); Wed, 14 Oct 2015 16:13:01 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 14 Oct 2015 13:13:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,682,1437462000"; d="scan'208";a="826777671" Received: from black.fi.intel.com ([10.237.72.93]) by orsmga002.jf.intel.com with ESMTP; 14 Oct 2015 13:12:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5995F505; Wed, 14 Oct 2015 23:12:26 +0300 (EEST) From: Andy Shevchenko To: linux-spi@vger.kernel.org, Mark Brown Cc: Andy Shevchenko Subject: [PATCH v1 08/10] spi: dw: introduce spi_shutdown_chip() Date: Wed, 14 Oct 2015 23:12:23 +0300 Message-Id: <1444853545-59868-9-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1444853545-59868-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1444853545-59868-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 This helper disables SPI controller and sets clock to 0. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-dw.c | 13 ++++++------- drivers/spi/spi-dw.h | 6 ++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index a2ee776..047ffbd 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -548,22 +548,21 @@ void dw_spi_remove_host(struct dw_spi *dws) if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws); - spi_enable_chip(dws, 0); - /* Disable clk */ - spi_set_clk(dws, 0); + + spi_shutdown_chip(dws); } EXPORT_SYMBOL_GPL(dw_spi_remove_host); int dw_spi_suspend_host(struct dw_spi *dws) { - int ret = 0; + int ret; ret = spi_master_suspend(dws->master); if (ret) return ret; - spi_enable_chip(dws, 0); - spi_set_clk(dws, 0); - return ret; + + spi_shutdown_chip(dws); + return 0; } EXPORT_SYMBOL_GPL(dw_spi_suspend_host); diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index b75ed32..35589a2 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -225,6 +225,12 @@ static inline void spi_reset_chip(struct dw_spi *dws) spi_enable_chip(dws, 1); } +static inline void spi_shutdown_chip(struct dw_spi *dws) +{ + spi_enable_chip(dws, 0); + spi_set_clk(dws, 0); +} + /* * Each SPI slave device to work with dw_api controller should * has such a structure claiming its working mode (poll or PIO/DMA),