From patchwork Fri Sep 7 07:42:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ley Foon Tan X-Patchwork-Id: 967255 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4268Yf6fJBz9sBv for ; Fri, 7 Sep 2018 17:43:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8B269C21DC1; Fri, 7 Sep 2018 07:42:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D34FDC21D4A; Fri, 7 Sep 2018 07:42:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9326DC21D4A; Fri, 7 Sep 2018 07:42:53 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lists.denx.de (Postfix) with ESMTPS id 9F8E1C21BE5 for ; Fri, 7 Sep 2018 07:42:52 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 00:42:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="83851389" Received: from lftan-mobl.gar.corp.intel.com (HELO ubuntu) ([10.226.248.86]) by fmsmga002.fm.intel.com with SMTP; 07 Sep 2018 00:42:31 -0700 Received: by ubuntu (sSMTP sendmail emulation); Fri, 07 Sep 2018 15:42:29 +0800 From: Ley Foon Tan To: u-boot@lists.denx.de, Jagan Teki Date: Fri, 7 Sep 2018 15:42:29 +0800 Message-Id: <1536306149-12550-1-git-send-email-ley.foon.tan@intel.com> X-Mailer: git-send-email 2.7.4 Cc: Marek Vasut , Chin Liang See Subject: [U-Boot] [PATCH] spi: designware_spi: Disable and free clock when remove driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Disable and free clock when remove driver. Signed-off-by: Ley Foon Tan --- drivers/spi/designware_spi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c index 5cca414..f4d36cf 100644 --- a/drivers/spi/designware_spi.c +++ b/drivers/spi/designware_spi.c @@ -516,8 +516,20 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode) static int dw_spi_remove(struct udevice *bus) { struct dw_spi_priv *priv = dev_get_priv(bus); + int ret; - return reset_release_bulk(&priv->resets); + ret = reset_release_bulk(&priv->resets); + if (ret) + return ret; + +#if CONFIG_IS_ENABLED(CLK) + ret = clk_disable(&priv->clk); + if (ret) + return ret; + + ret = clk_free(&priv->clk); +#endif + return ret; } static const struct dm_spi_ops dw_spi_ops = {